Loading [MathJax]/extensions/tex2jax.js
ug4
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
surface_view.h
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__UG__LIB_GRID__TOOLS__SURFACE_VIEW__
34#define __H__UG__LIB_GRID__TOOLS__SURFACE_VIEW__
35
36#ifdef UG_PARALLEL
38#endif
39
40#include "lib_grid/multi_grid.h"
44#include "common/util/flags.h"
45
46namespace ug{
47
52
61{
62 public:
73 // each grid-object has exactly on of these states (begin)
75 MG_SURFACE_PURE = 1 << 1,
76 MG_SURFACE_RIM = 1 << 2,
79 // each grid-object has exactly on of these states (end)
80
81 // combo-states with flags as in multi-grid (begin)
87 // combo-states with flags as in multi-grid (end)
88
90
91 // combo-states with flags as in level-view (begin)
97
103 // combo-states with flags as in level-view (end)
104 };
107
108 public:
110 bool adaptiveMG = true);
111
112 ~SurfaceView();
113
116
119
121 inline bool is_adaptive() const;
122
124 template <class TGeomObj>
125 inline bool is_contained(TGeomObj* obj, const GridLevel& gl,
126 SurfaceState validStates = ALL) const;
127
129 template <class TElem>
130 SurfaceState surface_state(TElem* elem, const GridLevel& gl) const;
131
133
134 template <class TGeomObj>
135 inline bool is_ghost(TGeomObj* obj) const;
136
138
141 template <class TGeomObj>
142 inline bool is_shadowed(TGeomObj* obj) const;
143
145
149 template <class TGeomObj>
150 inline bool is_shadowing(TGeomObj* obj) const;
151
154
156
161 template <class TElem>
162 SurfaceState surface_state(TElem* elem) const {return m_aaSurfState[elem];}
163
165 template <typename TElem, typename TBaseElem>
166 void collect_associated(std::vector<TBaseElem*>& vAssElem,
167 TElem* elem,
168 const GridLevel& gl,
169 bool clearContainer = true) const;
170
171 public:
172 template <class TElem> class SurfaceViewElementIterator;
173 template <class TElem> class ConstSurfaceViewElementIterator;
174
176 template <class TElem>
178 {
179 public:
181
182 private:
184 typedef TElem* TValue;
185
186 friend class SurfaceView;
187 friend class ConstSurfaceViewElementIterator<TElem>;
188
190 SurfaceView* surfView,
191 const GridLevel& gl,
192 SurfaceState validStates,
193 int si = -1);
194
195 public:
196 this_type operator ++() {increment(); return *this;}
197 this_type operator ++(int unused) {this_type i = *this; increment(); return i;}
198
199 bool operator ==(const this_type& iter) const {return equal(iter);}
200 bool operator !=(const this_type& iter) const {return !equal(iter);}
201
203
204 private:
206 inline bool equal(SurfaceViewElementIterator<TElem> const& other) const;
207
209 template <class TGeomObj>
210 inline bool is_contained(TGeomObj* obj) const;
211
213 void increment();
214
216 bool increment_section();
217
219 inline TValue dereference() const;
220
221 private:
227 int m_si;
229 int m_lvl;
232 };
233
235 template <class TElem>
237 {
238 public:
240
242
243 private:
245 // \todo: should return const TElem*
246 typedef TElem* TValue;
247 //typedef const TElem* TValue;
248
249 friend class SurfaceView;
250
252 const SurfaceView* surfView,
253 const GridLevel& gl,
254 SurfaceState validStates,
255 int si = -1);
256
257 public:
258 this_type operator ++() {increment(); return *this;}
259 this_type operator ++(int unused) {this_type i = *this; increment(); return i;}
260
261 bool operator ==(const this_type& iter) const {return equal(iter);}
262 bool operator !=(const this_type& iter) const {return !equal(iter);}
263
265
266 private:
268 inline bool equal(ConstSurfaceViewElementIterator<TElem> const& other) const;
269
271 template <class TGeomObj>
272 inline bool is_contained(TGeomObj* obj) const;
273
275 void increment();
276
278 bool increment_section();
279
281 inline TValue dereference() const;
282
283 private:
289 int m_si;
291 int m_lvl;
294 };
295
296 public:
297 template <class TElem>
302
305 template <class TElem>
307 begin(int si, const GridLevel& gl, SurfaceState validStates);
308
309 template <class TElem>
311 end(int si, const GridLevel& gl, SurfaceState validStates);
312
313 template <class TElem>
315 begin(int si, const GridLevel& gl, SurfaceState validStates) const;
316
317 template <class TElem>
319 end(int si, const GridLevel& gl, SurfaceState validStates) const;
320
321 template <class TElem>
323 begin(const GridLevel& gl, SurfaceState validStates);
324
325 template <class TElem>
327 end(const GridLevel& gl, SurfaceState validStates);
328
329 template <class TElem>
331 begin(const GridLevel& gl, SurfaceState validStates) const;
332
333 template <class TElem>
335 end(const GridLevel& gl, SurfaceState validStates) const;
337
338 private:
340
344 template <class TElem>
345 bool is_local_surface_view_element(TElem* elem);
346
348 template <class TElem>
350
352
355 template <class TElem, class TSide>
356 void mark_sides_as_surface_or_shadow(TElem* elem,
357 byte surfaceState = MG_SURFACE_PURE);
358
359 template <class TElem>
360 void mark_shadowing(bool markSides = false);
361
363 template <class TElem>
365
366 template <class TElem>
367 SurfaceState& surface_state(TElem* elem) {return m_aaSurfState[elem];}
368
369 template <class TElem>
370 bool is_vmaster(TElem* elem) const;
371
372 private:
379};
380
383}// end of namespace
384
385
387// include implementation
388#include "surface_view_impl.hpp"
389
390#endif
Definition smart_pointer.h:296
Definition smart_pointer.h:108
A generic specialization of IAttachment.
Definition attachment_pipe.h:263
manages the layouts and interfaces which are associated with a distributed grid.
Definition distributed_grid.h:88
Helps maintaining, activating and deactivating a set of flags from an enum.
Definition flags.h:63
Definition grid_level.h:42
Accesses attachements in different element types at the same time.
Definition attachment_util.h:56
Definition multi_grid.h:72
Const iterator to traverse the surface of a multi-grid hierarchy.
Definition surface_view.h:237
void increment()
returns next valid iterator
Definition surface_view_impl.hpp:308
int m_toSI
Definition surface_view.h:288
bool operator==(const this_type &iter) const
Definition surface_view.h:261
geometry_traits< TElem >::const_iterator m_iterEndSection
Definition surface_view.h:293
bool increment_section()
returns begin-iterator of next non-empty section, returns false if not available
Definition surface_view_impl.hpp:275
const SurfaceView * m_pSurfView
Definition surface_view.h:284
ConstSurfaceViewElementIterator< TElem > this_type
Definition surface_view.h:244
int m_si
Definition surface_view.h:289
int m_fromSI
Definition surface_view.h:287
geometry_traits< TElem >::const_iterator m_elemIter
Definition surface_view.h:292
this_type operator++()
Definition surface_view.h:258
SurfaceState m_validStates
Definition surface_view.h:286
ConstSurfaceViewElementIterator()
Definition surface_view_impl.hpp:212
bool equal(ConstSurfaceViewElementIterator< TElem > const &other) const
returns if this iterator equals another
Definition surface_view_impl.hpp:268
bool is_contained(TGeomObj *obj) const
returns if valid element, i.e. contained in iterator loop
Definition surface_view_impl.hpp:337
GridLevel m_gl
Definition surface_view.h:285
TValue operator*()
Definition surface_view.h:264
int m_topLvl
Definition surface_view.h:290
bool operator!=(const this_type &iter) const
Definition surface_view.h:262
TElem * TValue
Definition surface_view.h:246
TValue dereference() const
dereference
Definition surface_view_impl.hpp:329
int m_lvl
Definition surface_view.h:291
Iterator to traverse the surface of a multi-grid hierarchy.
Definition surface_view.h:178
geometry_traits< TElem >::iterator m_iterEndSection
Definition surface_view.h:231
SurfaceViewElementIterator< TElem > this_type
Definition surface_view.h:183
TElem * TValue
Definition surface_view.h:184
bool operator!=(const this_type &iter) const
Definition surface_view.h:200
bool is_contained(TGeomObj *obj) const
returns if valid element, i.e. contained in iterator loop
Definition surface_view_impl.hpp:168
int m_lvl
Definition surface_view.h:229
bool equal(SurfaceViewElementIterator< TElem > const &other) const
returns if this iterator equals another
Definition surface_view_impl.hpp:100
geometry_traits< TElem >::iterator m_elemIter
Definition surface_view.h:230
SurfaceState m_validStates
Definition surface_view.h:224
int m_fromSI
Definition surface_view.h:225
void increment()
returns next valid iterator
Definition surface_view_impl.hpp:140
SurfaceView * m_pSurfView
Definition surface_view.h:222
TValue dereference() const
dereference
Definition surface_view_impl.hpp:160
bool increment_section()
returns begin-iterator of next non-empty section, returns false if not available
Definition surface_view_impl.hpp:107
SurfaceViewElementIterator()
Definition surface_view_impl.hpp:85
int m_topLvl
Definition surface_view.h:228
bool operator==(const this_type &iter) const
Definition surface_view.h:199
GridLevel m_gl
Definition surface_view.h:223
TValue operator*()
Definition surface_view.h:202
this_type operator++()
Definition surface_view.h:196
int m_toSI
Definition surface_view.h:226
int m_si
Definition surface_view.h:227
Represents the surface view of a multi-grid hierarchy.
Definition surface_view.h:61
SurfaceState surface_state(TElem *elem) const
returns an or combination of current surface states
Definition surface_view.h:162
traits< TElem >::iterator end(int si, const GridLevel &gl, SurfaceState validStates)
Definition surface_view_impl.hpp:372
bool is_shadowing(TGeomObj *obj) const
returns true if the given element is a shadowing element
Definition surface_view_impl.hpp:515
Attachment< SurfaceState > ASurfaceState
Definition surface_view.h:106
bool is_adaptive() const
returns if multigrid is adaptive
Definition surface_view_impl.hpp:436
void mark_sides_as_surface_or_shadow(TElem *elem, byte surfaceState=MG_SURFACE_PURE)
recursively marks sides and sides of sides as surface or shadow
Definition surface_view.cpp:200
bool is_contained(TGeomObj *obj, const GridLevel &gl, SurfaceState validStates=ALL) const
returns if the element is contained in the surface view
Definition surface_view_impl.hpp:442
SurfaceState & surface_state(TElem *elem)
Definition surface_view.h:367
bool m_adaptiveMG
Definition surface_view.h:374
bool is_shadowed(TGeomObj *obj) const
returns if the element is shadowed and thus not contained in the surface view
Definition surface_view_impl.hpp:509
~SurfaceView()
Definition surface_view.cpp:332
void mark_shadowing(bool markSides=false)
Definition surface_view.cpp:245
SmartPtr< MGSubsetHandler > m_spMGSH
Definition surface_view.h:373
bool is_local_surface_view_element(TElem *elem)
returns true if the element is a surface element locally
Definition surface_view.cpp:112
DistributedGridManager * m_distGridMgr
Definition surface_view.h:376
ASurfaceState m_aSurfState
Definition surface_view.h:377
MultiGrid * m_pMG
Definition surface_view.h:375
void refresh_surface_states()
refresh_surface_states must be called after a grid change
Definition surface_view.cpp:123
SurfaceConstants
Definition surface_view.h:72
@ MG_SURFACE_PURE
surface, i.e., without children (inner)
Definition surface_view.h:75
@ MG_SHADOW_RIM
all rim-shadows
Definition surface_view.h:82
@ MG_ALL_BUT_SHADOW_COPY
surface + rim-non-copy-shadows
Definition surface_view.h:85
@ SHADOW_PURE
pseudo-state
Definition surface_view.h:92
@ MG_SHADOW_PURE
full-covered (inner)
Definition surface_view.h:74
@ MG_SHADOW
all shadows
Definition surface_view.h:83
@ SHADOW_RIM
Definition surface_view.h:98
@ SHADOW_RIM_NONCOPY
Definition surface_view.h:96
@ ALL_BUT_SHADOW_COPY
Definition surface_view.h:101
@ SURFACE
Definition surface_view.h:100
@ SURFACE_RIM
Definition surface_view.h:94
@ TREAT_TOP_LVL_SHADOWS_AS_SURFACE_PURE
Definition surface_view.h:89
@ MG_SURFACE_RIM
surface, i.e., without children (at rim)
Definition surface_view.h:76
@ ALL
Definition surface_view.h:102
@ MG_SHADOW_RIM_NONCOPY
covered (at rim) with non-identical child(ren)
Definition surface_view.h:78
@ SHADOW_RIM_COPY
Definition surface_view.h:95
@ SHADOW
Definition surface_view.h:99
@ MG_SHADOW_RIM_COPY
covered (at rim) with identical child
Definition surface_view.h:77
@ MG_ALL
all (except pure-shadow)
Definition surface_view.h:86
@ MG_SURFACE
all surface
Definition surface_view.h:84
@ SURFACE_PURE
Definition surface_view.h:93
SmartPtr< MGSubsetHandler > subset_handler()
returns underlying subset handler
Definition surface_view_impl.hpp:426
MultiElementAttachmentAccessor< ASurfaceState > m_aaSurfState
Definition surface_view.h:378
SurfaceState surface_state(TElem *elem, const GridLevel &gl) const
returns the surface states, when considered as part of grid level
bool is_vmaster(TElem *elem) const
Definition surface_view_impl.hpp:521
traits< TElem >::iterator begin(int si, const GridLevel &gl, SurfaceState validStates)
Definition surface_view_impl.hpp:364
Flag< SurfaceConstants, byte, SS_NONE > SurfaceState
Definition surface_view.h:105
void adjust_parallel_surface_states()
adjusts surface states in a parallel environment
Definition surface_view.cpp:289
void collect_associated(std::vector< TBaseElem * > &vAssElem, TElem *elem, const GridLevel &gl, bool clearContainer=true) const
returns the adjacent elements w.r.t. the grid level
Definition surface_view_impl.hpp:532
bool is_ghost(TGeomObj *obj) const
returns if the element is ghost
Definition surface_view_impl.hpp:499
Definition grid_base_object_traits.h:68
the ug namespace
Definition surface_view.h:298
ConstSurfaceViewElementIterator< TElem > const_iterator
Definition surface_view.h:300
SurfaceViewElementIterator< TElem > iterator
Definition surface_view.h:299