Loading [MathJax]/extensions/tex2jax.js
ug4
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
subset_handler_interface_impl.hpp
Go to the documentation of this file.
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__LIBGRID__SUBSET_HANDLER_INTERFACE_IMPL__
34#define __H__LIBGRID__SUBSET_HANDLER_INTERFACE_IMPL__
35
37
38namespace ug
39{
40/*
41template <>
42inline AttachmentPipe<Vertex*, ISubsetHandler>&
43ISubsetHandler::get_attachment_pipe<Vertex>(int subsetIndex)
44{
45 assert(subset_attachments_are_enabled() && "ERROR - you have to enable subset-attachments for this subset-handler before executing this mehtod.");
46 return *m_vertexAttachmentPipes[subsetIndex];
47}
48
49template <>
50inline AttachmentPipe<Edge*, ISubsetHandler>&
51ISubsetHandler::get_attachment_pipe<Edge>(int subsetIndex)
52{
53 assert(subset_attachments_are_enabled() && "ERROR - you have to enable subset-attachments for this subset-handler before executing this mehtod.");
54 return *m_edgeAttachmentPipes[subsetIndex];
55}
56
57template <>
58inline AttachmentPipe<Face*, ISubsetHandler>&
59ISubsetHandler::get_attachment_pipe<Face>(int subsetIndex)
60{
61 assert(subset_attachments_are_enabled() && "ERROR - you have to enable subset-attachments for this subset-handler before executing this mehtod.");
62 return *m_faceAttachmentPipes[subsetIndex];
63}
64
65template <>
66inline AttachmentPipe<Volume*, ISubsetHandler>&
67ISubsetHandler::get_attachment_pipe<Volume>(int subsetIndex)
68{
69 assert(subset_attachments_are_enabled() && "ERROR - you have to enable subset-attachments for this subset-handler before executing this mehtod.");
70 return *m_volumeAttachmentPipes[subsetIndex];
71}
72*/
73
75get_subset_index(Vertex* elem) const
76{
78 return m_aaSubsetIndexVRT[elem];
79 return -1;
80}
81
83get_subset_index(Edge* elem) const
84{
86 return m_aaSubsetIndexEDGE[elem];
87 return -1;
88}
89
91get_subset_index(Face* elem) const
92{
94 return m_aaSubsetIndexFACE[elem];
95 return -1;
96}
97
99get_subset_index(Volume* elem) const
100{
102 return m_aaSubsetIndexVOL[elem];
103 return -1;
104}
105
107subset_assigned(Vertex* v, int subsetIndex)
108{
109 /*if(subset_attachments_are_enabled())
110 {
111 if(get_subset_index(v) != -1)
112 get_attachment_pipe<Vertex>(get_subset_index(v)).unregister_element(v);
113
114 if(subsetIndex != -1)
115 get_attachment_pipe<Vertex>(subsetIndex).register_element(v);
116 }*/
117
118 m_aaSubsetIndexVRT[v] = subsetIndex;
119}
120
122subset_assigned(Edge* e, int subsetIndex)
123{
124 /*if(subset_attachments_are_enabled())
125 {
126 if(get_subset_index(e) != -1)
127 get_attachment_pipe<Edge>(get_subset_index(e)).unregister_element(e);
128
129 if(subsetIndex != -1)
130 get_attachment_pipe<Edge>(subsetIndex).register_element(e);
131 }*/
132
133 m_aaSubsetIndexEDGE[e] = subsetIndex;
134}
135
136inline void
138subset_assigned(Face* f, int subsetIndex)
139{
140 /*if(subset_attachments_are_enabled())
141 {
142 if(get_subset_index(f) != -1)
143 get_attachment_pipe<Face>(get_subset_index(f)).unregister_element(f);
144
145 if(subsetIndex != -1)
146 get_attachment_pipe<Face>(subsetIndex).register_element(f);
147 }*/
148
149 m_aaSubsetIndexFACE[f] = subsetIndex;
150}
151
152inline void
154subset_assigned(Volume* v, int subsetIndex)
155{
156 /*if(subset_attachments_are_enabled())
157 {
158 if(get_subset_index(v) != -1)
159 get_attachment_pipe<Volume>(get_subset_index(v)).unregister_element(v);
160
161 if(subsetIndex != -1)
162 get_attachment_pipe<Volume>(subsetIndex).register_element(v);
163 }*/
164
165 m_aaSubsetIndexVOL[v] = subsetIndex;
166}
167
168template <class TIterator>
170assign_subset(TIterator iterBegin, TIterator iterEnd, int subsetIndex)
171{
172 typename TIterator::value_type elem;
173 while(iterBegin != iterEnd)
174 {
175 elem = *iterBegin;
176 ++iterBegin;
177 assign_subset(elem, subsetIndex);
178 }
179}
180
181inline void
183subset_required(int index)
184{
185 if(index >= (int)m_subsetInfos.size())
187}
188
189inline void
191subset_required(int index) const
192{
193 if(index >= num_subsets()){
194 UG_THROW("Can't create new subsets in const ISubsetHandler. "
195 << "num current subsets: " << num_subsets()
196 << " required subset: " << index);
197 }
198}
199
201// attachment handling
202/*
203template <class TGeomObjClass>
204void ISubsetHandler::
205attach_to(IAttachment& attachment, int subsetIndex)
206{
207 assert(subset_attachments_are_enabled() && "ERROR - you have to enable subset-attachments for this subset-handler before executing this mehtod.");
208 STATIC_ASSERT(geometry_traits<TGeomObjClass>::BASE_OBJECT_ID != -1,
209 invalid_GeomObjClass);
210
211 subset_info_required(subsetIndex);
212
213 int objType = geometry_traits<TGeomObjClass>::BASE_OBJECT_ID;
214 switch(objType)
215 {
216 case VERTEX:
217 get_attachment_pipe<Vertex>(subsetIndex).attach(attachment, 0);
218 break;
219 case EDGE:
220 get_attachment_pipe<Edge>(subsetIndex).attach(attachment, 0);
221 break;
222 case FACE:
223 get_attachment_pipe<Face>(subsetIndex).attach(attachment, 0);
224 break;
225 case VOLUME:
226 get_attachment_pipe<Volume>(subsetIndex).attach(attachment, 0);
227 break;
228 };
229}
230*/
231/*
232template <class TGeomObjClass, class TAttachment>
233void ISubsetHandler::
234attach_to_dv(TAttachment& attachment, int subsetIndex,
235 const typename TAttachment::ValueType& defaultValue)
236{
237 assert(subset_attachments_are_enabled() && "ERROR - you have to enable subset-attachments for this subset-handler before executing this mehtod.");
238 STATIC_ASSERT(geometry_traits<TGeomObjClass>::BASE_OBJECT_ID != -1,
239 invalid_GeomObjClass);
240
241 subset_info_required(subsetIndex);
242
243 int objType = geometry_traits<TGeomObjClass>::BASE_OBJECT_ID;
244 switch(objType)
245 {
246 case VERTEX:
247 get_attachment_pipe<Vertex>(subsetIndex).attach(attachment, defaultValue, 0);
248 break;
249 case EDGE:
250 get_attachment_pipe<Edge>(subsetIndex).attach(attachment, defaultValue, 0);
251 break;
252 case FACE:
253 get_attachment_pipe<Face>(subsetIndex).attach(attachment, defaultValue, 0);
254 break;
255 case VOLUME:
256 get_attachment_pipe<Volume>(subsetIndex).attach(attachment, defaultValue, 0);
257 break;
258 };
259}
260*/
261/*
262template <class TGeomObjClass>
263void ISubsetHandler::detach_from(IAttachment& attachment, int subsetIndex)
264{
265 assert(subset_attachments_are_enabled() && "ERROR - you have to enable subset-attachments for this subset-handler before executing this mehtod.");
266 STATIC_ASSERT(geometry_traits<TGeomObjClass>::BASE_OBJECT_ID != -1,
267 invalid_GeomObjClass);
268
269 assert(subsetIndex >= 0 && subsetIndex < (int)num_subsets() && "bad subset index.");
270
271 int objType = geometry_traits<TGeomObjClass>::BASE_OBJECT_ID;
272 switch(objType)
273 {
274 case VERTEX:
275 get_attachment_pipe<Vertex>(subsetIndex).detach(attachment);
276 break;
277 case EDGE:
278 get_attachment_pipe<Edge>(subsetIndex).detach(attachment);
279 break;
280 case FACE:
281 get_attachment_pipe<Face>(subsetIndex).detach(attachment);
282 break;
283 case VOLUME:
284 get_attachment_pipe<Volume>(subsetIndex).detach(attachment);
285 break;
286 };
287}
288*/
289/*
290template <class TGeomObj, class TAttachment>
291inline typename TAttachment::ContainerType*
292ISubsetHandler::get_attachment_data_container(TAttachment& attachment, int subsetIndex)
293{
294 assert(subset_attachments_are_enabled() && "ERROR - you have to enable subset-attachments for this subset-handler before executing this mehtod.");
295 return get_attachment_pipe<TGeomObj>(subsetIndex).get_data_container(attachment);
296}
297*/
298
300// attachments_traits
301/*
302inline uint
303attachment_traits<Vertex*, ISubsetHandler>::
304get_data_index(ElemHandlerPtr pHandler, ConstElemPtr elem)
305{
306 return pHandler->get_attachment_data_index(elem);
307}
308
309inline void
310attachment_traits<Vertex*, ISubsetHandler>::
311set_data_index(ElemHandlerPtr pHandler, ElemPtr elem, uint index)
312{
313 pHandler->set_attachment_data_index(elem, index);
314}
315
316inline uint
317attachment_traits<Edge*, ISubsetHandler>::
318get_data_index(ElemHandlerPtr pHandler, ConstElemPtr elem)
319{
320 return pHandler->get_attachment_data_index(elem);
321}
322
323inline void
324attachment_traits<Edge*, ISubsetHandler>::
325set_data_index(ElemHandlerPtr pHandler, ElemPtr elem, uint index)
326{
327 pHandler->set_attachment_data_index(elem, index);
328}
329
330inline uint
331attachment_traits<Face*, ISubsetHandler>::
332get_data_index(ElemHandlerPtr pHandler, ConstElemPtr elem)
333{
334 return pHandler->get_attachment_data_index(elem);
335}
336
337inline void
338attachment_traits<Face*, ISubsetHandler>::
339set_data_index(ElemHandlerPtr pHandler, ElemPtr elem, uint index)
340{
341 pHandler->set_attachment_data_index(elem, index);
342}
343
344inline uint
345attachment_traits<Volume*, ISubsetHandler>::
346get_data_index(ElemHandlerPtr pHandler, ConstElemPtr elem)
347{
348 return pHandler->get_attachment_data_index(elem);
349}
350
351inline void
352attachment_traits<Volume*, ISubsetHandler>::
353set_data_index(ElemHandlerPtr pHandler, ElemPtr elem, uint index)
354{
355 pHandler->set_attachment_data_index(elem, index);
356}
358}// end of namespace
359
360#endif
Base-class for edges.
Definition grid_base_objects.h:397
Faces are 2-dimensional objects.
Definition grid_base_objects.h:510
void subset_assigned(Vertex *v, int subsetIndex)
Definition subset_handler_interface_impl.hpp:107
Grid::FaceAttachmentAccessor< ASubsetIndex > m_aaSubsetIndexFACE
Definition subset_handler_interface.h:756
SubsetInfoVec m_subsetInfos
Definition subset_handler_interface.h:742
void subset_required(int index)
if the subset with the given index does not yet exist, it will be created.
Definition subset_handler_interface_impl.hpp:183
void assign_subset(TIterator iterBegin, TIterator iterEnd, int subsetIndex)
Definition subset_handler_interface_impl.hpp:170
Grid::VolumeAttachmentAccessor< ASubsetIndex > m_aaSubsetIndexVOL
Definition subset_handler_interface.h:757
void create_required_subsets(int index)
creates all required infos (and pipes) up to the given index.
Definition subset_handler_interface.cpp:235
int get_subset_index(GridObject *elem) const
Definition subset_handler_interface.cpp:560
int num_subsets() const
returns the number of subset-infos (return value is int, since SubsetIndices are of type int)
Definition subset_handler_interface.h:317
bool elements_are_supported(uint shElements) const
returns true if the given element-types are supported.
Definition subset_handler_interface.cpp:310
Grid::EdgeAttachmentAccessor< ASubsetIndex > m_aaSubsetIndexEDGE
Definition subset_handler_interface.h:755
Grid::VertexAttachmentAccessor< ASubsetIndex > m_aaSubsetIndexVRT
Definition subset_handler_interface.h:754
Base-class for all vertex-types.
Definition grid_base_objects.h:231
Volumes are 3-dimensional objects.
Definition grid_base_objects.h:754
@ SHE_VOLUME
Definition subset_handler_interface.h:65
@ SHE_EDGE
Definition subset_handler_interface.h:63
@ SHE_VERTEX
Definition subset_handler_interface.h:62
@ SHE_FACE
Definition subset_handler_interface.h:64
#define UG_THROW(msg)
Definition error.h:57
the ug namespace