ug4
parallel_grid_layout.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009-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__
34 #define __H__LIB_GRID__PARALLEL_GRID_LAYOUT__
35 
36 #include <vector>
37 #include <list>
38 #include <map>
39 #include <algorithm>
42 #include "grid_object_id.h"
43 
44 // specialize pcl::type_traits for Vertex, Edge, Face and Volume
45 namespace pcl
46 {
48 template <>
50 {
51  typedef ug::Vertex* Elem;
52 };
53 
55 template <>
57 {
58  typedef ug::Edge* Elem;
59 };
60 
62 template <>
64 {
65  typedef ug::Face* Elem;
66 };
67 
69 template <>
71 {
72  typedef ug::Volume* Elem;
73 };
74 
75 }// end of namespace pcl
76 
77 namespace ug
78 {
79 
83 
102 {
103  INT_NONE = 0,
105  INT_H_SLAVE = 1<<1,
106  INT_V_MASTER = 1<<2,
107  INT_V_SLAVE = 1<<3,
108 };
109 
110 // declare vertex-, edge-, face- and volume-layouts
111 // we're using std::list as interface-element container, since we
112 // require interface-element-iterators that stay valid even if the
113 // interface is altered.
114 // Make sure that those layouts match the ones in GridLayoutMap.
115 typedef pcl::MultiLevelLayout<
117 typedef pcl::MultiLevelLayout<
119 typedef pcl::MultiLevelLayout<
121 typedef pcl::MultiLevelLayout<
123 
124 
126 // GridLayoutMap
128 
152 {
153  public:
154  typedef int Key;
155 
157  template <class TType>
158  struct Types
159  {
162  typedef typename Interface::Element Element;
163  typedef std::map<Key, Layout> Map;
164  };
165 
166  public:
168  template <class TType>
169  bool
170  has_layout(const Key& key) const;
171 
173  template <class TType>
174  typename Types<TType>::Layout&
175  get_layout(const Key& key);
176 
177  template <class TType>
178  const typename Types<TType>::Layout&
179  get_layout(const Key& key) const;
180 
182 
185  template <class TType>
187  layouts_begin();
188 
189  template <class TType>
191  layouts_begin() const;
195 
198  template <class TType>
200  layouts_end();
201 
202  template <class TType>
204  layouts_end() const;
208 
209  template <class TType>
212 
214  template <class TType>
215  void erase_layout(const Key& key);
216 
217  void clear();
218 
221 
222  private:
223  template <class TType>
224  inline typename Types<TType>::Map&
225  get_layout_map();
226 
227  template <class TType>
228  inline const typename Types<TType>::Map&
229  get_layout_map() const;
230 
232  // \{
233  inline Types<Vertex>::Map&
235 
236  inline const Types<Vertex>::Map&
237  get_layout_map(Vertex*) const;
238 
239  inline Types<Edge>::Map&
241 
242  inline const Types<Edge>::Map&
243  get_layout_map(Edge*) const;
244 
245  inline Types<Face>::Map&
247 
248  inline const Types<Face>::Map&
249  get_layout_map(Face*) const;
250 
251  inline Types<Volume>::Map&
253 
254  inline const Types<Volume>::Map&
255  get_layout_map(Volume*) const;
256  // \}
257 
258  private:
263 };
264 
266 }// end of namespace
267 
269 // include implementation
271 
272 #endif
the standard multi-level-layout implementation
Definition: pcl_communication_structs.h:615
You may add elements to this interface and iterate over them.
Definition: pcl_communication_structs.h:207
type_traits< TType >::Elem Element
Definition: pcl_communication_structs.h:232
Base-class for edges.
Definition: grid_base_objects.h:397
Faces are 2-dimensional objects.
Definition: grid_base_objects.h:510
lets you access layouts by type and key
Definition: parallel_grid_layout.h:152
Types< TType >::Map::iterator erase_layout(typename Types< TType >::Map::iterator iter)
erases the specified layout
Definition: parallel_grid_layout_impl.hpp:100
Types< Face >::Map m_faceLayoutMap
Definition: parallel_grid_layout.h:261
Types< TType >::Map::iterator layouts_end()
end-iterator to the layout-map for the given type.
Definition: parallel_grid_layout_impl.hpp:86
bool has_layout(const Key &key) const
checks whether the layout associated with the given key exists for the given type.
Definition: parallel_grid_layout_impl.hpp:44
Types< Vertex >::Map m_vertexLayoutMap
Definition: parallel_grid_layout.h:259
Types< Edge >::Map m_edgeLayoutMap
Definition: parallel_grid_layout.h:260
void remove_empty_interfaces()
removes empty interfaces.
Definition: parallel_grid_layout.cpp:79
Types< TType >::Map & get_layout_map()
Definition: parallel_grid_layout_impl.hpp:128
int Key
Definition: parallel_grid_layout.h:154
Types< TType >::Layout & get_layout(const Key &key)
creates the required layout if it doesn't exist already.
Definition: parallel_grid_layout_impl.hpp:52
void clear()
Definition: parallel_grid_layout_impl.hpp:118
Types< TType >::Map::iterator layouts_begin()
begin-iterator to the layout-map for the given type.
Definition: parallel_grid_layout_impl.hpp:72
Types< Volume >::Map m_volumeLayoutMap
Definition: parallel_grid_layout.h:262
Base-class for all vertex-types.
Definition: grid_base_objects.h:231
Volumes are 3-dimensional objects.
Definition: grid_base_objects.h:754
Definition: parallel_grid_layout.h:46
the ug namespace
pcl::MultiLevelLayout< pcl::OrderedInterface< Volume, std::list > > VolumeLayout
Definition: parallel_grid_layout.h:122
pcl::MultiLevelLayout< pcl::OrderedInterface< Face, std::list > > FaceLayout
Definition: parallel_grid_layout.h:120
pcl::MultiLevelLayout< pcl::OrderedInterface< Edge, std::list > > EdgeLayout
Definition: parallel_grid_layout.h:118
InterfaceNodeTypes
Definition: parallel_grid_layout.h:102
@ INT_NONE
Definition: parallel_grid_layout.h:103
@ INT_V_MASTER
vertical master node
Definition: parallel_grid_layout.h:106
@ INT_H_MASTER
horizontal master node
Definition: parallel_grid_layout.h:104
@ INT_H_SLAVE
horizontal slave node
Definition: parallel_grid_layout.h:105
@ INT_V_SLAVE
vertical slave node
Definition: parallel_grid_layout.h:107
pcl::MultiLevelLayout< pcl::OrderedInterface< Vertex, std::list > > VertexLayout
Definition: parallel_grid_layout.h:116
ug::Edge * Elem
Definition: parallel_grid_layout.h:58
ug::Face * Elem
Definition: parallel_grid_layout.h:65
ug::Vertex * Elem
Definition: parallel_grid_layout.h:51
ug::Volume * Elem
Definition: parallel_grid_layout.h:72
associate internally used types with an external typename
Definition: pcl_communication_structs.h:64
defines the types that are used by a LayoutMap for a given TType.
Definition: parallel_grid_layout.h:159
pcl::MultiLevelLayout< Interface > Layout
Definition: parallel_grid_layout.h:161
pcl::OrderedInterface< TType, std::list > Interface
Definition: parallel_grid_layout.h:160
std::map< Key, Layout > Map
Definition: parallel_grid_layout.h:163
Interface::Element Element
Definition: parallel_grid_layout.h:162