ug4
element_storage.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-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__UG__element_storage__
34 #define __H__UG__element_storage__
35 
36 #include "grid_base_objects.h"
38 
39 namespace ug
40 {
42 template <class TElem>
44 {
45  public:
50 
52  {
54  }
55  // the destructor is important, since destruction order is undefined
56  // and since the AttachedElementList in SectionContainer tries to
57  // unregister itself fomt the assigned pipe.
60  }
61 
64 };
65 
66 
68 template<>
70 {
71  public:
72  typedef Vertex*& ElemRef;
73  typedef Vertex* ElemPtr;
74  typedef const Vertex* ConstElemPtr;
78 
79  static inline element_iterator elements_begin(ElemHandlerPtr pHandler) {return pHandler->m_sectionContainer.begin();}
80  static inline element_iterator elements_end(ElemHandlerPtr pHandler) {return pHandler->m_sectionContainer.end();}
81  static inline uint get_data_index(ConstElemHandlerPtr pHandler, ConstElemPtr elem) {return elem->grid_data_index();}
82  static inline void set_data_index(ElemHandlerPtr pHandler, ElemPtr elem, uint index){elem->set_grid_data_index(index);}
83 };
84 
85 template<>
87 {
88  public:
89  typedef Edge*& ElemRef;
90  typedef Edge* ElemPtr;
91  typedef const Edge* ConstElemPtr;
95 
96  static inline element_iterator elements_begin(ElemHandlerPtr pHandler) {return pHandler->m_sectionContainer.begin();}
97  static inline element_iterator elements_end(ElemHandlerPtr pHandler) {return pHandler->m_sectionContainer.end();}
98  static inline uint get_data_index(ConstElemHandlerPtr pHandler, ConstElemPtr elem) {return elem->grid_data_index();}
99  static inline void set_data_index(ElemHandlerPtr pHandler, ElemPtr elem, uint index){elem->set_grid_data_index(index);}
100 };
101 
102 template<>
104 {
105  public:
106  typedef Face*& ElemRef;
107  typedef Face* ElemPtr;
108  typedef const Face* ConstElemPtr;
112 
113  static inline element_iterator elements_begin(ElemHandlerPtr pHandler) {return pHandler->m_sectionContainer.begin();}
114  static inline element_iterator elements_end(ElemHandlerPtr pHandler) {return pHandler->m_sectionContainer.end();}
115  static inline uint get_data_index(ConstElemHandlerPtr pHandler, ConstElemPtr elem) {return elem->grid_data_index();}
116  static inline void set_data_index(ElemHandlerPtr pHandler, ElemPtr elem, uint index){elem->set_grid_data_index(index);}
117 };
118 
119 template<>
121 {
122  public:
123  typedef Volume*& ElemRef;
124  typedef Volume* ElemPtr;
125  typedef const Volume* ConstElemPtr;
129 
130  static inline element_iterator elements_begin(ElemHandlerPtr pHandler) {return pHandler->m_sectionContainer.begin();}
131  static inline element_iterator elements_end(ElemHandlerPtr pHandler) {return pHandler->m_sectionContainer.end();}
132  static inline uint get_data_index(ConstElemHandlerPtr pHandler, ConstElemPtr elem) {return elem->grid_data_index();}
133  static inline void set_data_index(ElemHandlerPtr pHandler, ElemPtr elem, uint index){elem->set_grid_data_index(index);}
134 };
135 
136 
137 
142 
143 
144 
147 template <class TElem>
150  EdgeElementStorage& edges, FaceElementStorage& faces,
151  VolumeElementStorage& vols);
152 
154  const VertexElementStorage& vrts, const EdgeElementStorage& edges,
155  const FaceElementStorage& faces, const VolumeElementStorage& vols);
156 };
157 
158 template <>
162  {return vrts;}
163 
165  const VertexElementStorage& vrts, const EdgeElementStorage& edges,
166  const FaceElementStorage& faces, const VolumeElementStorage& vols)
167  {return vrts;}
168 };
169 
170 template <>
174  {return edges;}
175 
176  static inline const ElementStorage<Edge>& element_storage(
177  const VertexElementStorage& vrts, const EdgeElementStorage& edges,
178  const FaceElementStorage& faces, const VolumeElementStorage& vols)
179  {return edges;}
180 };
181 
182 template <>
186  {return faces;}
187 
188  static inline const ElementStorage<Face>& element_storage(
189  const VertexElementStorage& vrts, const EdgeElementStorage& edges,
190  const FaceElementStorage& faces, const VolumeElementStorage& vols)
191  {return faces;}
192 };
193 
194 template <>
198  {return vols;}
199 
201  const VertexElementStorage& vrts, const EdgeElementStorage& edges,
202  const FaceElementStorage& faces, const VolumeElementStorage& vols)
203  {return vols;}
204 };
205 
206 
209 template <class TElem>
216 
222 
228 
234 };
235 
236 template <>
243  {return vrts;}
244 
250  {return vrts;}
251 
257  {return vrts;}
258 
264  {return vrts;}
265 };
266 
267 template <>
274  {return edges;}
275 
281  {return edges;}
282 
288  {return edges;}
289 
295  {return edges;}
296 };
297 
298 template <>
305  {return faces;}
306 
312  {return faces;}
313 
319  {return faces;}
320 
326  {return faces;}
327 };
328 
329 template <>
336  {return vols;}
337 
343  {return vols;}
344 
350  {return vols;}
351 
357  {return vols;}
358 };
359 
360 }// end of namespace
361 
362 #endif
A linked list of elements living in an attachment.
Definition: attached_list.h:182
void set_pipe(TAttachmentPipe *pipe)
set the attachment pipe on which the list shall operate
Definition: attached_list.h:275
Handles data which has been attached to the pipe using callbacks for the element.
Definition: attachment_pipe.h:337
Base-class for edges.
Definition: grid_base_objects.h:397
This struct is used to hold GridObjects and their attachment pipes.
Definition: element_storage.h:44
ElementStorage()
Definition: element_storage.h:51
AttachmentPipe m_attachmentPipe
holds elements
Definition: element_storage.h:63
SectionContainer m_sectionContainer
Definition: element_storage.h:62
ug::SectionContainer< TElem *, AttachedElementList > SectionContainer
Definition: element_storage.h:49
ug::AttachedElementList< AttachmentPipe > AttachedElementList
Definition: element_storage.h:47
ug::AttachmentPipe< TElem *, ElementStorage< TElem > > AttachmentPipe
Definition: element_storage.h:46
~ElementStorage()
Definition: element_storage.h:58
Faces are 2-dimensional objects.
Definition: grid_base_objects.h:510
uint grid_data_index() const
Returns the grid attachment data index of a geometric object.
Definition: grid_base_objects.h:205
void set_grid_data_index(uint index)
ATTENTION: Use this method with extreme care!
Definition: grid_base_objects.h:212
Container & get_container()
returns the container for raw access.
Definition: section_container.h:116
iterator begin()
Definition: section_container.h:77
iterator end()
Definition: section_container.h:78
Base-class for all vertex-types.
Definition: grid_base_objects.h:231
Volumes are 3-dimensional objects.
Definition: grid_base_objects.h:754
Edge * ElemPtr
Definition: element_storage.h:90
static element_iterator elements_end(ElemHandlerPtr pHandler)
Definition: element_storage.h:97
static element_iterator elements_begin(ElemHandlerPtr pHandler)
Definition: element_storage.h:96
ElementStorage< Edge > * ElemHandlerPtr
Definition: element_storage.h:92
static void set_data_index(ElemHandlerPtr pHandler, ElemPtr elem, uint index)
Definition: element_storage.h:99
ElementStorage< Edge >::SectionContainer::iterator element_iterator
Definition: element_storage.h:94
Edge *& ElemRef
Definition: element_storage.h:89
const Edge * ConstElemPtr
Definition: element_storage.h:91
const ElementStorage< Edge > * ConstElemHandlerPtr
Definition: element_storage.h:93
static uint get_data_index(ConstElemHandlerPtr pHandler, ConstElemPtr elem)
Definition: element_storage.h:98
static element_iterator elements_end(ElemHandlerPtr pHandler)
Definition: element_storage.h:114
static element_iterator elements_begin(ElemHandlerPtr pHandler)
Definition: element_storage.h:113
ElementStorage< Face >::SectionContainer::iterator element_iterator
Definition: element_storage.h:111
static void set_data_index(ElemHandlerPtr pHandler, ElemPtr elem, uint index)
Definition: element_storage.h:116
Face *& ElemRef
Definition: element_storage.h:106
const Face * ConstElemPtr
Definition: element_storage.h:108
static uint get_data_index(ConstElemHandlerPtr pHandler, ConstElemPtr elem)
Definition: element_storage.h:115
ElementStorage< Face > * ElemHandlerPtr
Definition: element_storage.h:109
const ElementStorage< Face > * ConstElemHandlerPtr
Definition: element_storage.h:110
Face * ElemPtr
Definition: element_storage.h:107
static void set_data_index(ElemHandlerPtr pHandler, ElemPtr elem, uint index)
Definition: element_storage.h:82
Vertex *& ElemRef
Definition: element_storage.h:72
ElementStorage< Vertex > * ElemHandlerPtr
Definition: element_storage.h:75
static element_iterator elements_end(ElemHandlerPtr pHandler)
Definition: element_storage.h:80
static uint get_data_index(ConstElemHandlerPtr pHandler, ConstElemPtr elem)
Definition: element_storage.h:81
const Vertex * ConstElemPtr
Definition: element_storage.h:74
ElementStorage< Vertex >::SectionContainer::iterator element_iterator
Definition: element_storage.h:77
static element_iterator elements_begin(ElemHandlerPtr pHandler)
Definition: element_storage.h:79
const ElementStorage< Vertex > * ConstElemHandlerPtr
Definition: element_storage.h:76
Vertex * ElemPtr
Definition: element_storage.h:73
static void set_data_index(ElemHandlerPtr pHandler, ElemPtr elem, uint index)
Definition: element_storage.h:133
ElementStorage< Volume >::SectionContainer::iterator element_iterator
Definition: element_storage.h:128
Volume * ElemPtr
Definition: element_storage.h:124
ElementStorage< Volume > * ElemHandlerPtr
Definition: element_storage.h:126
static element_iterator elements_end(ElemHandlerPtr pHandler)
Definition: element_storage.h:131
Volume *& ElemRef
Definition: element_storage.h:123
const ElementStorage< Volume > * ConstElemHandlerPtr
Definition: element_storage.h:127
static element_iterator elements_begin(ElemHandlerPtr pHandler)
Definition: element_storage.h:130
const Volume * ConstElemPtr
Definition: element_storage.h:125
static uint get_data_index(ConstElemHandlerPtr pHandler, ConstElemPtr elem)
Definition: element_storage.h:132
define the interface that enables you to use your own types as element-types in an AttachmentPipe.
Definition: attachment_pipe.h:305
unsigned int uint
Definition: types.h:114
the ug namespace
ElementStorage< Volume > VolumeElementStorage
Definition: element_storage.h:141
ElementStorage< Edge > EdgeElementStorage
Definition: element_storage.h:139
ElementStorage< Face > FaceElementStorage
Definition: element_storage.h:140
ElementStorage< Vertex > VertexElementStorage
Definition: element_storage.h:138
static ElementStorage< Edge > & element_storage(VertexElementStorage &vrts, EdgeElementStorage &edges, FaceElementStorage &faces, VolumeElementStorage &vols)
Definition: element_storage.h:172
static const ElementStorage< Edge > & element_storage(const VertexElementStorage &vrts, const EdgeElementStorage &edges, const FaceElementStorage &faces, const VolumeElementStorage &vols)
Definition: element_storage.h:176
static const ElementStorage< Face > & element_storage(const VertexElementStorage &vrts, const EdgeElementStorage &edges, const FaceElementStorage &faces, const VolumeElementStorage &vols)
Definition: element_storage.h:188
static ElementStorage< Face > & element_storage(VertexElementStorage &vrts, EdgeElementStorage &edges, FaceElementStorage &faces, VolumeElementStorage &vols)
Definition: element_storage.h:184
static const ElementStorage< Vertex > & element_storage(const VertexElementStorage &vrts, const EdgeElementStorage &edges, const FaceElementStorage &faces, const VolumeElementStorage &vols)
Definition: element_storage.h:164
static ElementStorage< Vertex > & element_storage(VertexElementStorage &vrts, EdgeElementStorage &edges, FaceElementStorage &faces, VolumeElementStorage &vols)
Definition: element_storage.h:160
static ElementStorage< Volume > & element_storage(VertexElementStorage &vrts, EdgeElementStorage &edges, FaceElementStorage &faces, VolumeElementStorage &vols)
Definition: element_storage.h:196
static const ElementStorage< Volume > & element_storage(const VertexElementStorage &vrts, const EdgeElementStorage &edges, const FaceElementStorage &faces, const VolumeElementStorage &vols)
Definition: element_storage.h:200
Helper class to access the correct element storage from its element type.
Definition: element_storage.h:148
static ElementStorage< TElem > & element_storage(VertexElementStorage &vrts, EdgeElementStorage &edges, FaceElementStorage &faces, VolumeElementStorage &vols)
static const ElementStorage< TElem > & element_storage(const VertexElementStorage &vrts, const EdgeElementStorage &edges, const FaceElementStorage &faces, const VolumeElementStorage &vols)
static ElementStorage< Edge >::SectionContainer * section_container(VertexElementStorage::SectionContainer *vrts, EdgeElementStorage::SectionContainer *edges, FaceElementStorage::SectionContainer *faces, VolumeElementStorage::SectionContainer *vols)
Definition: element_storage.h:283
static const ElementStorage< Edge >::SectionContainer * section_container(const VertexElementStorage::SectionContainer *vrts, const EdgeElementStorage::SectionContainer *edges, const FaceElementStorage::SectionContainer *faces, const VolumeElementStorage::SectionContainer *vols)
Definition: element_storage.h:290
static const ElementStorage< Edge >::SectionContainer & section_container(const VertexElementStorage::SectionContainer &vrts, const EdgeElementStorage::SectionContainer &edges, const FaceElementStorage::SectionContainer &faces, const VolumeElementStorage::SectionContainer &vols)
Definition: element_storage.h:276
static ElementStorage< Edge >::SectionContainer & section_container(VertexElementStorage::SectionContainer &vrts, EdgeElementStorage::SectionContainer &edges, FaceElementStorage::SectionContainer &faces, VolumeElementStorage::SectionContainer &vols)
Definition: element_storage.h:269
static ElementStorage< Face >::SectionContainer * section_container(VertexElementStorage::SectionContainer *vrts, EdgeElementStorage::SectionContainer *edges, FaceElementStorage::SectionContainer *faces, VolumeElementStorage::SectionContainer *vols)
Definition: element_storage.h:314
static const ElementStorage< Face >::SectionContainer * section_container(const VertexElementStorage::SectionContainer *vrts, const EdgeElementStorage::SectionContainer *edges, const FaceElementStorage::SectionContainer *faces, const VolumeElementStorage::SectionContainer *vols)
Definition: element_storage.h:321
static ElementStorage< Face >::SectionContainer & section_container(VertexElementStorage::SectionContainer &vrts, EdgeElementStorage::SectionContainer &edges, FaceElementStorage::SectionContainer &faces, VolumeElementStorage::SectionContainer &vols)
Definition: element_storage.h:300
static const ElementStorage< Face >::SectionContainer & section_container(const VertexElementStorage::SectionContainer &vrts, const EdgeElementStorage::SectionContainer &edges, const FaceElementStorage::SectionContainer &faces, const VolumeElementStorage::SectionContainer &vols)
Definition: element_storage.h:307
static ElementStorage< Vertex >::SectionContainer & section_container(VertexElementStorage::SectionContainer &vrts, EdgeElementStorage::SectionContainer &edges, FaceElementStorage::SectionContainer &faces, VolumeElementStorage::SectionContainer &vols)
Definition: element_storage.h:238
static const ElementStorage< Vertex >::SectionContainer & section_container(const VertexElementStorage::SectionContainer &vrts, const EdgeElementStorage::SectionContainer &edges, const FaceElementStorage::SectionContainer &faces, const VolumeElementStorage::SectionContainer &vols)
Definition: element_storage.h:245
static const ElementStorage< Vertex >::SectionContainer * section_container(const VertexElementStorage::SectionContainer *vrts, const EdgeElementStorage::SectionContainer *edges, const FaceElementStorage::SectionContainer *faces, const VolumeElementStorage::SectionContainer *vols)
Definition: element_storage.h:259
static ElementStorage< Vertex >::SectionContainer * section_container(VertexElementStorage::SectionContainer *vrts, EdgeElementStorage::SectionContainer *edges, FaceElementStorage::SectionContainer *faces, VolumeElementStorage::SectionContainer *vols)
Definition: element_storage.h:252
static const ElementStorage< Volume >::SectionContainer * section_container(const VertexElementStorage::SectionContainer *vrts, const EdgeElementStorage::SectionContainer *edges, const FaceElementStorage::SectionContainer *faces, const VolumeElementStorage::SectionContainer *vols)
Definition: element_storage.h:352
static ElementStorage< Volume >::SectionContainer & section_container(VertexElementStorage::SectionContainer &vrts, EdgeElementStorage::SectionContainer &edges, FaceElementStorage::SectionContainer &faces, VolumeElementStorage::SectionContainer &vols)
Definition: element_storage.h:331
static ElementStorage< Volume >::SectionContainer * section_container(VertexElementStorage::SectionContainer *vrts, EdgeElementStorage::SectionContainer *edges, FaceElementStorage::SectionContainer *faces, VolumeElementStorage::SectionContainer *vols)
Definition: element_storage.h:345
static const ElementStorage< Volume >::SectionContainer & section_container(const VertexElementStorage::SectionContainer &vrts, const EdgeElementStorage::SectionContainer &edges, const FaceElementStorage::SectionContainer &faces, const VolumeElementStorage::SectionContainer &vols)
Definition: element_storage.h:338
Helper class to access the correct element storage from its element type.
Definition: element_storage.h:210
static ElementStorage< TElem >::SectionContainer * section_container(VertexElementStorage::SectionContainer *vrts, EdgeElementStorage::SectionContainer *edges, FaceElementStorage::SectionContainer *faces, VolumeElementStorage::SectionContainer *vols)
static const ElementStorage< TElem >::SectionContainer * section_container(const VertexElementStorage::SectionContainer *vrts, const EdgeElementStorage::SectionContainer *edges, const FaceElementStorage::SectionContainer *faces, const VolumeElementStorage::SectionContainer *vols)
static const ElementStorage< TElem >::SectionContainer & section_container(const VertexElementStorage::SectionContainer &vrts, const EdgeElementStorage::SectionContainer &edges, const FaceElementStorage::SectionContainer &faces, const VolumeElementStorage::SectionContainer &vols)
static ElementStorage< TElem >::SectionContainer & section_container(VertexElementStorage::SectionContainer &vrts, EdgeElementStorage::SectionContainer &edges, FaceElementStorage::SectionContainer &faces, VolumeElementStorage::SectionContainer &vols)