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__LIBGRID__SUBSET_HANDLER_INTERFACE_IMPL__
34 : #define __H__LIBGRID__SUBSET_HANDLER_INTERFACE_IMPL__
35 :
36 : #include "subset_handler_interface.h"
37 :
38 : namespace ug
39 : {
40 : /*
41 : template <>
42 : inline AttachmentPipe<Vertex*, ISubsetHandler>&
43 : ISubsetHandler::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 :
49 : template <>
50 : inline AttachmentPipe<Edge*, ISubsetHandler>&
51 : ISubsetHandler::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 :
57 : template <>
58 : inline AttachmentPipe<Face*, ISubsetHandler>&
59 : ISubsetHandler::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 :
65 : template <>
66 : inline AttachmentPipe<Volume*, ISubsetHandler>&
67 : ISubsetHandler::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 :
74 0 : inline int ISubsetHandler::
75 : get_subset_index(Vertex* elem) const
76 : {
77 0 : if(elements_are_supported(SHE_VERTEX))
78 0 : return m_aaSubsetIndexVRT[elem];
79 : return -1;
80 : }
81 :
82 0 : inline int ISubsetHandler::
83 : get_subset_index(Edge* elem) const
84 : {
85 0 : if(elements_are_supported(SHE_EDGE))
86 0 : return m_aaSubsetIndexEDGE[elem];
87 : return -1;
88 : }
89 :
90 0 : inline int ISubsetHandler::
91 : get_subset_index(Face* elem) const
92 : {
93 0 : if(elements_are_supported(SHE_FACE))
94 0 : return m_aaSubsetIndexFACE[elem];
95 : return -1;
96 : }
97 :
98 0 : inline int ISubsetHandler::
99 : get_subset_index(Volume* elem) const
100 : {
101 0 : if(elements_are_supported(SHE_VOLUME))
102 0 : return m_aaSubsetIndexVOL[elem];
103 : return -1;
104 : }
105 :
106 : inline void ISubsetHandler::
107 : subset_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 0 : m_aaSubsetIndexVRT[v] = subsetIndex;
119 0 : }
120 :
121 : inline void ISubsetHandler::
122 : subset_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 0 : m_aaSubsetIndexEDGE[e] = subsetIndex;
134 0 : }
135 :
136 : inline void
137 : ISubsetHandler::
138 : subset_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 0 : m_aaSubsetIndexFACE[f] = subsetIndex;
150 0 : }
151 :
152 : inline void
153 : ISubsetHandler::
154 : subset_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 0 : m_aaSubsetIndexVOL[v] = subsetIndex;
166 0 : }
167 :
168 : template <class TIterator>
169 : void ISubsetHandler::
170 : assign_subset(TIterator iterBegin, TIterator iterEnd, int subsetIndex)
171 : {
172 : typename TIterator::value_type elem;
173 0 : while(iterBegin != iterEnd)
174 : {
175 0 : elem = *iterBegin;
176 : ++iterBegin;
177 0 : assign_subset(elem, subsetIndex);
178 : }
179 : }
180 :
181 : inline void
182 : ISubsetHandler::
183 : subset_required(int index)
184 : {
185 0 : if(index >= (int)m_subsetInfos.size())
186 0 : create_required_subsets(index);
187 : }
188 :
189 : inline void
190 0 : ISubsetHandler::
191 : subset_required(int index) const
192 : {
193 0 : if(index >= num_subsets()){
194 0 : UG_THROW("Can't create new subsets in const ISubsetHandler. "
195 : << "num current subsets: " << num_subsets()
196 : << " required subset: " << index);
197 : }
198 0 : }
199 :
200 : ////////////////////////////////////////////////////////////////////////
201 : // attachment handling
202 : /*
203 : template <class TGeomObjClass>
204 : void ISubsetHandler::
205 : attach_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 : /*
232 : template <class TGeomObjClass, class TAttachment>
233 : void ISubsetHandler::
234 : attach_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 : /*
262 : template <class TGeomObjClass>
263 : void 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 : /*
290 : template <class TGeomObj, class TAttachment>
291 : inline typename TAttachment::ContainerType*
292 : ISubsetHandler::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 :
299 : ////////////////////////////////////////////////////////////////////////
300 : // attachments_traits
301 : /*
302 : inline uint
303 : attachment_traits<Vertex*, ISubsetHandler>::
304 : get_data_index(ElemHandlerPtr pHandler, ConstElemPtr elem)
305 : {
306 : return pHandler->get_attachment_data_index(elem);
307 : }
308 :
309 : inline void
310 : attachment_traits<Vertex*, ISubsetHandler>::
311 : set_data_index(ElemHandlerPtr pHandler, ElemPtr elem, uint index)
312 : {
313 : pHandler->set_attachment_data_index(elem, index);
314 : }
315 :
316 : inline uint
317 : attachment_traits<Edge*, ISubsetHandler>::
318 : get_data_index(ElemHandlerPtr pHandler, ConstElemPtr elem)
319 : {
320 : return pHandler->get_attachment_data_index(elem);
321 : }
322 :
323 : inline void
324 : attachment_traits<Edge*, ISubsetHandler>::
325 : set_data_index(ElemHandlerPtr pHandler, ElemPtr elem, uint index)
326 : {
327 : pHandler->set_attachment_data_index(elem, index);
328 : }
329 :
330 : inline uint
331 : attachment_traits<Face*, ISubsetHandler>::
332 : get_data_index(ElemHandlerPtr pHandler, ConstElemPtr elem)
333 : {
334 : return pHandler->get_attachment_data_index(elem);
335 : }
336 :
337 : inline void
338 : attachment_traits<Face*, ISubsetHandler>::
339 : set_data_index(ElemHandlerPtr pHandler, ElemPtr elem, uint index)
340 : {
341 : pHandler->set_attachment_data_index(elem, index);
342 : }
343 :
344 : inline uint
345 : attachment_traits<Volume*, ISubsetHandler>::
346 : get_data_index(ElemHandlerPtr pHandler, ConstElemPtr elem)
347 : {
348 : return pHandler->get_attachment_data_index(elem);
349 : }
350 :
351 : inline void
352 : attachment_traits<Volume*, ISubsetHandler>::
353 : set_data_index(ElemHandlerPtr pHandler, ElemPtr elem, uint index)
354 : {
355 : pHandler->set_attachment_data_index(elem, index);
356 : }
357 : */
358 : }// end of namespace
359 :
360 : #endif
|