33 #ifndef __H__UG__LIB_GRID__TOOLS__SURFACE_VIEW_IMPL__
34 #define __H__UG__LIB_GRID__TOOLS__SURFACE_VIEW_IMPL__
42 template <
class TElem>
51 m_validStates(validStates),
53 m_fromSI( (si >= 0) ? si : 0 ),
54 m_toSI( (si >= 0) ? si : (sv->subset_handler()->num_subsets() - 1) ),
55 m_si(start ? m_fromSI : m_toSI),
57 m_topLvl(gl.top() ? (sv->subset_handler()->num_levels()-1) : gl.level()),
58 m_lvl((start && gl.is_surface() && sv->is_adaptive()) ? 0 : m_topLvl),
60 m_elemIter(start ? sv->subset_handler()->begin<TElem>(m_si, m_lvl)
61 : sv->subset_handler()->end<TElem>(m_toSI, m_topLvl)),
62 m_iterEndSection(sv->subset_handler()->end<TElem>(m_si, m_lvl))
70 "Invalid subset: "<<
m_si<<
" [min: 0, max: "<<sv->
subset_handler()->num_subsets()<<
"]");
83 template <
class TElem>
98 template <
class TElem>
105 template <
class TElem>
117 m_elemIter = m_pSurfView->subset_handler()->begin<TElem>(m_si, m_lvl);
118 m_iterEndSection = m_pSurfView->subset_handler()->end<TElem>(m_si, m_lvl);
121 else if(m_lvl < m_topLvl)
126 m_elemIter = m_pSurfView->subset_handler()->begin<TElem>(m_si, m_lvl);
127 m_iterEndSection = m_pSurfView->subset_handler()->end<TElem>(m_si, m_lvl);
134 while(m_elemIter == m_iterEndSection);
138 template <
class TElem>
149 if(m_elemIter == m_iterEndSection){
150 if(!increment_section())
157 template <
class TElem>
165 template <
class TElem>
166 template <
class TGeomObj>
171 if(m_pSurfView->is_ghost(obj)){
172 if(m_gl.ghosts() && (m_lvl == m_topLvl))
return true;
180 && (m_lvl == m_topLvl)
186 return m_validStates.contains(oss);
194 template <
class TElem>
210 template <
class TElem>
225 template <
class TElem>
234 m_validStates(validStates),
236 m_fromSI( (si >= 0) ? si : 0 ),
237 m_toSI( (si >= 0) ? si : (sv->
subset_handler()->num_subsets() - 1) ),
238 m_si(start ? m_fromSI : m_toSI),
240 m_topLvl(gl.top() ? (sv->
subset_handler()->num_levels()-1) : gl.level()),
241 m_lvl((start && gl.is_surface() && sv->
is_adaptive()) ? 0 : m_topLvl),
253 "Invalid subset: "<<
m_si<<
" [min: 0, max: "<<sv->
subset_handler()->num_subsets()<<
"]");
266 template <
class TElem>
273 template <
class TElem>
285 m_elemIter = m_pSurfView->subset_handler()->begin<TElem>(m_si, m_lvl);
286 m_iterEndSection = m_pSurfView->subset_handler()->end<TElem>(m_si, m_lvl);
289 else if(m_lvl < m_topLvl)
294 m_elemIter = m_pSurfView->subset_handler()->begin<TElem>(m_si, m_lvl);
295 m_iterEndSection = m_pSurfView->subset_handler()->end<TElem>(m_si, m_lvl);
302 while(m_elemIter == m_iterEndSection);
306 template <
class TElem>
319 if(m_elemIter == m_iterEndSection){
320 if(!increment_section())
326 template <
class TElem>
334 template <
class TElem>
335 template <
class TGeomObj>
340 if(m_pSurfView->is_ghost(obj)){
341 if(m_gl.ghosts() && (m_lvl == m_topLvl))
return true;
349 && (m_lvl == m_topLvl)
355 return m_validStates.contains(oss);
362 template <
class TElem>
366 UG_ASSERT(si >= 0 && si < m_spMGSH->num_subsets(),
"Invalid subset: "<<si);
370 template <
class TElem>
374 UG_ASSERT(si >= 0 && si < m_spMGSH->num_subsets(),
"Invalid subset: "<<si);
378 template <
class TElem>
382 UG_ASSERT(si >= 0 && si < m_spMGSH->num_subsets(),
"Invalid subset: "<<si);
386 template <
class TElem>
390 UG_ASSERT(si >= 0 && si < m_spMGSH->num_subsets(),
"Invalid subset: "<<si);
394 template <
class TElem>
401 template <
class TElem>
408 template <
class TElem>
415 template <
class TElem>
441 template <
class TGeomObj>
447 if(lvl > topLvl)
return false;
451 if(gl.
ghosts() && (lvl == topLvl))
return true;
468 template <
class TGeomObj>
474 UG_THROW(
"SurfaceView::surface_state: Call only on objects contained "
475 "in the grid level. (Else result is undefined)");
481 UG_THROW(
"SurfaceView::surface_state: Call only on objects contained "
482 "in the grid level. (Else result is undefined)");
498 template <
class TGeomObj>
508 template <
class TGeomObj>
514 template <
class TGeomObj>
520 template <
class TElem>
530 template <
typename TElem,
typename TBaseElem>
535 bool clearContainer)
const
537 if(clearContainer) vAssElem.clear();
541 std::vector<TBaseElem*> vCoarseElem;
543 for(
size_t i = 0; i < vCoarseElem.size(); ++i)
546 vAssElem.push_back(vCoarseElem[i]);
556 TElem* parent =
dynamic_cast<TElem*
>(pParent);
557 if(parent == NULL)
return;
561 std::vector<TBaseElem*> vCoarseElem;
564 for(
size_t i = 0; i < vCoarseElem.size(); ++i)
567 vAssElem.push_back(vCoarseElem[i]);
576 std::vector<TBaseElem*> vCoarseElem;
578 for (
size_t i = 0; i < vCoarseElem.size(); ++i)
580 vAssElem.push_back(vCoarseElem[i]);
593 std::vector<TBaseElem*> vFineElem;
595 for (
size_t i = 0; i < vFineElem.size(); ++i)
597 vAssElem.push_back(vFineElem[i]);
Definition: smart_pointer.h:296
bool is_ghost(TElem *elem) const
returns true if the element is a ghost
Definition: distributed_grid_impl.hpp:67
bool contains_status(TGeomObj *o, byte status) const
returns true if the status of the given object contains the given status.
Definition: distributed_grid.h:135
bool contains(TStorageType flag) const
Definition: flags.h:69
bool partially_contains(TStorageType flag) const
Definition: flags.h:72
Definition: grid_level.h:42
bool top() const
returns if top level
Definition: grid_level.h:83
int level() const
returns the level
Definition: grid_level.h:74
bool ghosts() const
returns if ghosts are considered as part of the level
Definition: grid_level.h:80
The base class for all geometric objects, such as vertices, edges, faces, volumes,...
Definition: grid_base_objects.h:157
int get_level(TElem *elem) const
Definition: multi_grid.h:206
TChild * get_child(TElem *elem, size_t ind) const
returns the i-th child of the given child-type
Definition: multi_grid.h:268
GridObject * get_parent(GridObject *parent) const
Definition: multi_grid.cpp:180
size_t num_children(TElem *elem) const
returns the number of children of the given child-type
Definition: multi_grid.h:225
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
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
int m_si
Definition: surface_view.h:289
geometry_traits< TElem >::const_iterator m_elemIter
Definition: surface_view.h:292
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
int m_topLvl
Definition: surface_view.h:290
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
TElem * TValue
Definition: surface_view.h:184
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
GridLevel m_gl
Definition: surface_view.h:223
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
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
bool is_adaptive() const
returns if multigrid is adaptive
Definition: surface_view_impl.hpp:436
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
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
SmartPtr< MGSubsetHandler > m_spMGSH
Definition: surface_view.h:373
DistributedGridManager * m_distGridMgr
Definition: surface_view.h:376
MultiGrid * m_pMG
Definition: surface_view.h:375
@ 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_SHADOW
all shadows
Definition: surface_view.h:83
@ 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
@ SHADOW_RIM_COPY
Definition: surface_view.h:95
SmartPtr< MGSubsetHandler > subset_handler()
returns underlying subset handler
Definition: surface_view_impl.hpp:426
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
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
UG_API void CollectAssociated(std::vector< Vertex * > &vVertexOut, Grid &grid, GridObject *obj, bool clearContainer=true)
Definition: grid_util_impl.hpp:169
@ ES_V_MASTER
Definition: distributed_grid.h:60
base_type::TBaseElem TBaseElem
#define UG_ASSERT(expr, msg)
Definition: assert.h:70
#define UG_THROW(msg)
Definition: error.h:57
ConstSurfaceViewElementIterator< TElem > const_iterator
Definition: surface_view.h:300
SurfaceViewElementIterator< TElem > iterator
Definition: surface_view.h:299