Line data Source code
1 : /*
2 : * Copyright (c) 2010-2015: G-CSC, Goethe University Frankfurt
3 : * Author: Sebastian Reiter
4 : *
5 : * This file is part of UG4.
6 : *
7 : * UG4 is free software: you can redistribute it and/or modify it under the
8 : * terms of the GNU Lesser General Public License version 3 (as published by the
9 : * Free Software Foundation) with the following additional attribution
10 : * requirements (according to LGPL/GPL v3 §7):
11 : *
12 : * (1) The following notice must be displayed in the Appropriate Legal Notices
13 : * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
14 : *
15 : * (2) The following notice must be displayed at a prominent place in the
16 : * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
17 : *
18 : * (3) The following bibliography is recommended for citation and must be
19 : * preserved in all covered files:
20 : * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
21 : * parallel geometric multigrid solver on hierarchically distributed grids.
22 : * Computing and visualization in science 16, 4 (2013), 151-164"
23 : * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
24 : * flexible software system for simulating pde based models on high performance
25 : * computers. Computing and visualization in science 16, 4 (2013), 165-179"
26 : *
27 : * This program is distributed in the hope that it will be useful,
28 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 : * GNU Lesser General Public License for more details.
31 : */
32 :
33 : #ifndef __H__LIB_GRID__PARALLEL_GRID_LAYOUT_IMPL__
34 : #define __H__LIB_GRID__PARALLEL_GRID_LAYOUT_IMPL__
35 :
36 : #include "parallel_grid_layout.h"
37 :
38 : namespace ug
39 : {
40 : ////////////////////////////////////////////////////////////////////////
41 : // GridLayoutMap - implementation
42 : template <class TType>
43 : bool GridLayoutMap::
44 : has_layout(const Key& key) const
45 : {
46 : const typename Types<TType>::Map& m = get_layout_map<TType>();
47 : return m.find(key) != m.end();
48 : }
49 :
50 : template <class TType>
51 : typename GridLayoutMap::Types<TType>::Layout& GridLayoutMap::
52 : get_layout(const Key& key)
53 : {
54 : typename Types<TType>::Map& m = get_layout_map<TType>();
55 : return m[key];
56 : }
57 :
58 : template <class TType>
59 0 : const typename GridLayoutMap::Types<TType>::Layout& GridLayoutMap::
60 : get_layout(const Key& key) const
61 : {
62 : const typename Types<TType>::Map& m = get_layout_map<TType>();
63 : typename Types<TType>::Map::const_iterator iter = m.find(key);
64 0 : if(iter == m.end()){
65 0 : UG_THROW("The specified layout can not be found in the GridLayoutMap.");
66 : }
67 0 : return iter->second;
68 : }
69 :
70 : template <class TType>
71 : typename GridLayoutMap::Types<TType>::Map::iterator GridLayoutMap::
72 : layouts_begin()
73 : {
74 : return get_layout_map<TType>().begin();
75 : }
76 :
77 : template <class TType>
78 : typename GridLayoutMap::Types<TType>::Map::const_iterator GridLayoutMap::
79 : layouts_begin() const
80 : {
81 : return get_layout_map<TType>().begin();
82 : }
83 :
84 : template <class TType>
85 : typename GridLayoutMap::Types<TType>::Map::iterator GridLayoutMap::
86 : layouts_end()
87 : {
88 : return get_layout_map<TType>().end();
89 : }
90 :
91 : template <class TType>
92 : typename GridLayoutMap::Types<TType>::Map::const_iterator GridLayoutMap::
93 : layouts_end() const
94 : {
95 : return get_layout_map<TType>().end();
96 : }
97 :
98 : template <class TType>
99 : typename GridLayoutMap::Types<TType>::Map::iterator GridLayoutMap::
100 : erase_layout(typename GridLayoutMap::Types<TType>::Map::iterator iter)
101 : {
102 : typename Types<TType>::Map& m = get_layout_map<TType>();
103 : typename Types<TType>::Map::iterator tIter = iter++;
104 : m.erase(tIter);
105 : return iter;
106 : }
107 :
108 : template <class TType>
109 : void GridLayoutMap::
110 : erase_layout(const Key& key)
111 : {
112 : typename Types<TType>::Map& m = get_layout_map<TType>();
113 : typename Types<TType>::Map::iterator iter = m.find(key);
114 : if(iter != m.end())
115 : m.erase(iter);
116 : }
117 :
118 : inline void GridLayoutMap::clear()
119 : {
120 : m_vertexLayoutMap = Types<Vertex>::Map();
121 : m_edgeLayoutMap = Types<Edge>::Map();
122 : m_faceLayoutMap = Types<Face>::Map();
123 : m_volumeLayoutMap = Types<Volume>::Map();
124 : }
125 :
126 : template <class TType>
127 : inline typename GridLayoutMap::Types<TType>::Map& GridLayoutMap::
128 : get_layout_map()
129 : {
130 : TType* dummy = NULL;// set to NULL to avoid warnings
131 : return get_layout_map(dummy);
132 : }
133 :
134 : template <class TType>
135 : inline const typename GridLayoutMap::Types<TType>::Map& GridLayoutMap::
136 : get_layout_map() const
137 : {
138 : TType* dummy = NULL;// set to NULL to avoid warnings
139 : return get_layout_map(dummy);
140 : }
141 :
142 : inline GridLayoutMap::Types<Vertex>::Map& GridLayoutMap::
143 : get_layout_map(Vertex*)
144 : {
145 : return m_vertexLayoutMap;
146 : }
147 :
148 : inline const GridLayoutMap::Types<Vertex>::Map& GridLayoutMap::
149 : get_layout_map(Vertex*) const
150 : {
151 : return m_vertexLayoutMap;
152 : }
153 :
154 : inline GridLayoutMap::Types<Edge>::Map& GridLayoutMap::
155 : get_layout_map(Edge*)
156 : {
157 : return m_edgeLayoutMap;
158 : }
159 :
160 : inline const GridLayoutMap::Types<Edge>::Map& GridLayoutMap::
161 : get_layout_map(Edge*) const
162 : {
163 : return m_edgeLayoutMap;
164 : }
165 :
166 : inline GridLayoutMap::Types<Face>::Map& GridLayoutMap::
167 : get_layout_map(Face*)
168 : {
169 : return m_faceLayoutMap;
170 : }
171 :
172 : inline const GridLayoutMap::Types<Face>::Map& GridLayoutMap::
173 : get_layout_map(Face*) const
174 : {
175 : return m_faceLayoutMap;
176 : }
177 :
178 : inline GridLayoutMap::Types<Volume>::Map& GridLayoutMap::
179 : get_layout_map(Volume*)
180 : {
181 : return m_volumeLayoutMap;
182 : }
183 :
184 : inline const GridLayoutMap::Types<Volume>::Map& GridLayoutMap::
185 : get_layout_map(Volume*) const
186 : {
187 : return m_volumeLayoutMap;
188 : }
189 :
190 : }// end of namespace
191 :
192 : #endif
|