Loading [MathJax]/extensions/tex2jax.js
ug4
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
hanging_node_refiner_base.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__HANGING_NODE_REFINER_BASE__
34#define __H__UG__HANGING_NODE_REFINER_BASE__
35
36#include <queue>
37#include <vector>
38#include "lib_grid/lg_base.h"
39#include "refiner_interface.h"
41
42namespace ug
43{
44
47
49
90template <class TSelector>
92{
93 public:
94 using IRefiner::mark;
95
96 typedef TSelector selector_t;
97
106
107 public:
109 virtual ~HangingNodeRefinerBase();
110
111 virtual void grid_to_be_destroyed(Grid* grid);
112
114
120 void enable_node_dependency_order_1(bool bEnable);
125 void add_ref_mark_adjuster(SPIRefMarkAdjuster adjuster) {m_refMarkAdjusters.push_back(adjuster);}
126
127
128 virtual void clear_marks();
129
131
132 virtual bool mark(Vertex* v, RefinementMark refMark = RM_REFINE);
133 virtual bool mark(Edge* e, RefinementMark refMark = RM_REFINE);
134 virtual bool mark(Face* f, RefinementMark refMark = RM_REFINE);
135 virtual bool mark(Volume* v, RefinementMark refMark = RM_REFINE);
139
140 virtual void mark_neighborhood(
141 size_t numIterations,
142 RefinementMark refMark,
143 bool sideNbrsOnly);
144
146
147 virtual RefinementMark get_mark(Vertex* v) const;
148 virtual RefinementMark get_mark(Edge* e) const;
149 virtual RefinementMark get_mark(Face* f) const;
150 virtual RefinementMark get_mark(Volume* v) const;
154 inline bool marked_refine(Edge* elem) const
155 {
156 return (m_selMarkedElements.get_selection_status(elem)
157 & RM_REFINE) != 0;
158 }
159
160 template <class TElem>
161 inline bool marked_refine(TElem* elem) const
162 {
163 return (m_selMarkedElements.get_selection_status(elem)
164 & (RM_CLOSURE | RM_LOCAL | RM_FULL)) != 0;
165 }
166
167 template <class TElem>
168 inline bool marked_adaptive(TElem* elem) const
169 {
170 return (m_selMarkedElements.get_selection_status(elem)
171 & (RM_CLOSURE | RM_LOCAL));
172 }
173
174 template <class TElem>
175 inline bool marked_regular(TElem* elem) const
176 {
177 return marked_refine(elem) && (!(marked_adaptive(elem)));
178 }
179
180 template <class TElem>
181 inline bool marked_coarsen(TElem* elem) const
182 {
183 return (m_selMarkedElements.get_selection_status(elem)
185 }
186
187
188
189 virtual bool save_marks_to_file(const char* filename);
190
191 protected:
192 typedef typename TSelector::template traits<Vertex>::iterator sel_vrt_iter;
193 typedef typename TSelector::template traits<Edge>::iterator sel_edge_iter;
194 typedef typename TSelector::template traits<Face>::iterator sel_face_iter;
195 typedef typename TSelector::template traits<Volume>::iterator sel_vol_iter;
196
198
219 void perform_refinement();
220
221
223 virtual bool refinement_is_allowed(Vertex* elem) {return true;}
225 virtual bool refinement_is_allowed(Edge* elem) {return true;}
227 virtual bool refinement_is_allowed(Face* elem) {return true;}
229 virtual bool refinement_is_allowed(Volume* elem) {return true;}
230
232
240 void set_grid(typename TSelector::grid_type* grid);
241
243
251 virtual void collect_objects_for_refine();
252
257 virtual bool continue_collect_objects_for_refine(bool continueRequired)
258 {return continueRequired;}
259
267 virtual void assign_hnode_marks();
268
271 virtual void pre_refine() {}
272
274 virtual void post_refine() {}
275
277 // refine methods
279
284 virtual void process_constrained_edge(ConstrainedEdge* cde);
286 virtual void refine_edge_with_normal_vertex(Edge* e,
287 Vertex** newCornerVrts = NULL);
289 Vertex** newCornerVrts = NULL);
290
291 virtual void process_constrained_face(ConstrainedFace* cdf);
293 virtual void refine_face_with_normal_vertex(Face* f,
294 Vertex** newCornerVrts = NULL);
296 Vertex** newCornerVrts = NULL);
297
299 Vertex** newVolumeVrts = NULL);
303 // helpers. Make sure that everything is initialized properly
304 // before calling these methods.
305 // you should use this methods instead of directly marking elements.
306 inline bool is_marked(Vertex* v) {return m_selMarkedElements.is_selected(v);}
307 //inline void mark(Vertex* v) {mark(v);}
308
309 inline bool is_marked(Edge* e) {return m_selMarkedElements.is_selected(e);}
310 //inline void mark(Edge* e) {mark(e);}
311
313
316 virtual Vertex* get_center_vertex(Edge* e) = 0;
317
319 virtual void set_center_vertex(Edge* e, Vertex* v) = 0;
320
321 inline bool is_marked(Face* f) {return m_selMarkedElements.is_selected(f);}
322 //inline void mark(Face* f) {mark(f);}
323
325
328 virtual Vertex* get_center_vertex(Face* f) = 0;
329
331 virtual void set_center_vertex(Face* f, Vertex* v) = 0;
332
333 inline bool is_marked(Volume* v) {return m_selMarkedElements.is_selected(v);}
334 //inline void mark(Volume* v) {mark(v);}
335
336
337 template <class TElem>
338 inline bool marked_to_normal(TElem* elem) const {return (m_selMarkedElements.get_selection_status(elem) & HNRM_TO_NORMAL) == HNRM_TO_NORMAL;}
339
340 template <class TElem>
341 inline bool marked_to_constrained(TElem* elem) const {return (m_selMarkedElements.get_selection_status(elem) & HNRM_TO_CONSTRAINED) == HNRM_TO_CONSTRAINED;}
342
343 template <class TElem>
344 inline bool marked_to_constraining(TElem* elem) const {return (m_selMarkedElements.get_selection_status(elem) & HNRM_TO_CONSTRAINING) == HNRM_TO_CONSTRAINING;}
345
346 template <class TElem>
347 void add_hmark(TElem* elem, HNodeRefMarks mark);
348
349 template <class TElem>
350 void remove_hmark(TElem* elem, uint mark);
351
353
354 template <class TElem>
356
358
360
361 inline bool adjusting_ref_marks() const {return m_adjustingRefMarks;}
362
363 private:
366
367 protected:
369 std::vector<SPIRefMarkAdjuster> m_refMarkAdjusters;
370
371 private:
373 std::vector<Vertex*> m_newlyMarkedRefVrts;
374 std::vector<Edge*> m_newlyMarkedRefEdges;
375 std::vector<Face*> m_newlyMarkedRefFaces;
376 std::vector<Volume*> m_newlyMarkedRefVols;
377 //todo: Use the following vectors during coarsening...
378 /*
379 std::vector<Vertex*> m_newlyMarkedCoarseVrts;
380 std::vector<Edge*> m_newlyMarkedCoarseEdges;
381 std::vector<Face*> m_newlyMarkedCoarseFaces;
382 std::vector<Volume*> m_newlyMarkedCoarseVols;
383 */
385 //bool m_automarkHigherDimensionalObjects; <-- unused
387};
388
390
391}// end of namespace
392
393#endif
This edge is a sub-edge of a.
Definition grid_objects_1d.h:146
This class stores the constraining object.
Definition grid_objects_2d.h:383
A vertex appearing on edges or faces.
Definition grid_objects_0d.h:110
contains elements of type
Definition grid_objects_1d.h:279
This class is used to store constrained geometric objects.
Definition grid_objects_2d.h:562
Base-class for edges.
Definition grid_base_objects.h:397
Faces are 2-dimensional objects.
Definition grid_base_objects.h:510
Manages the elements of a grid and their interconnection.
Definition grid.h:132
Definition grid_observer.h:80
Base class for a hanging-node refiner.
Definition hanging_node_refiner_base.h:92
bool remove_coarsen_marks()
removes coarsen marks from the selection
Definition hanging_node_refiner_base.cpp:993
virtual void collect_objects_for_refine()
marks unmarked elements that have to be refined due to marked neighbors.
Definition hanging_node_refiner_base.cpp:1012
TSelector::template traits< Face >::iterator sel_face_iter
Definition hanging_node_refiner_base.h:194
bool marked_to_constrained(TElem *elem) const
Definition hanging_node_refiner_base.h:341
std::vector< Volume * > m_newlyMarkedRefVols
Definition hanging_node_refiner_base.h:376
virtual ~HangingNodeRefinerBase()
Definition hanging_node_refiner_base.cpp:85
bool adjusting_ref_marks() const
Definition hanging_node_refiner_base.h:361
virtual void grid_to_be_destroyed(Grid *grid)
Definition hanging_node_refiner_base.cpp:115
virtual void process_constraining_edge(ConstrainingEdge *cge)
called to refine the specified element.
Definition hanging_node_refiner_base.cpp:1474
virtual void process_constrained_face(ConstrainedFace *cdf)
called to refine the specified element.
Definition hanging_node_refiner_base.cpp:1887
std::vector< Vertex * > m_newlyMarkedRefVrts
Definition hanging_node_refiner_base.h:373
bool marked_refine(TElem *elem) const
Definition hanging_node_refiner_base.h:161
virtual void refine_face_with_hanging_vertex(Face *f, Vertex **newCornerVrts=NULL)
called to refine the specified element.
Definition hanging_node_refiner_base.cpp:1674
Grid * m_pGrid
Definition hanging_node_refiner_base.h:372
virtual bool refinement_is_allowed(Face *elem)
a callback that allows to deny refinement of special faces
Definition hanging_node_refiner_base.h:227
bool is_marked(Face *f)
Definition hanging_node_refiner_base.h:321
bool is_marked(Vertex *v)
Definition hanging_node_refiner_base.h:306
bool m_adjustingRefMarks
true during collect_objects_for_refine
Definition hanging_node_refiner_base.h:386
bool marked_refine(Edge *elem) const
Definition hanging_node_refiner_base.h:154
virtual bool refinement_is_allowed(Volume *elem)
a callback that allows to deny refinement of special volumes
Definition hanging_node_refiner_base.h:229
void perform_refinement()
performs refinement on the marked elements.
Definition hanging_node_refiner_base.cpp:643
void add_hmark(TElem *elem, HNodeRefMarks mark)
Definition hanging_node_refiner_base.cpp:1332
TSelector::template traits< Volume >::iterator sel_vol_iter
Definition hanging_node_refiner_base.h:195
virtual void mark_neighborhood(size_t numIterations, RefinementMark refMark, bool sideNbrsOnly)
Marks the neighborhood of the current selection.
Definition hanging_node_refiner_base.cpp:196
virtual void pre_refine()
Definition hanging_node_refiner_base.h:271
virtual void refine_face_with_normal_vertex(Face *f, Vertex **newCornerVrts=NULL)
called to refine the specified element.
Definition hanging_node_refiner_base.cpp:1595
virtual void post_refine()
Definition hanging_node_refiner_base.h:274
virtual void refine_edge_with_hanging_vertex(Edge *e, Vertex **newCornerVrts=NULL)
called to refine the specified element.
Definition hanging_node_refiner_base.cpp:1551
TSelector m_selMarkedElements
Definition hanging_node_refiner_base.h:368
virtual RefinementMark get_mark(Vertex *v) const
Returns the mark of a given element.
Definition hanging_node_refiner_base.cpp:474
TSelector::template traits< Edge >::iterator sel_edge_iter
Definition hanging_node_refiner_base.h:193
std::vector< Face * > m_newlyMarkedRefFaces
Definition hanging_node_refiner_base.h:375
void set_grid(typename TSelector::grid_type *grid)
performs registration and deregistration at a grid.
Definition hanging_node_refiner_base.cpp:95
virtual void set_center_vertex(Edge *e, Vertex *v)=0
Associates a vertex with the edge (pure virtual).
bool marked_adaptive(TElem *elem) const
Definition hanging_node_refiner_base.h:168
bool is_marked(Edge *e)
Definition hanging_node_refiner_base.h:309
virtual void process_constraining_face(ConstrainingFace *cgf)
called to refine the specified element.
Definition hanging_node_refiner_base.cpp:1921
virtual bool mark(Vertex *v, RefinementMark refMark=RM_REFINE)
Marks a element for refinement.
Definition hanging_node_refiner_base.cpp:132
TSelector::template traits< Vertex >::iterator sel_vrt_iter
Definition hanging_node_refiner_base.h:192
std::vector< Edge * > m_newlyMarkedRefEdges
Definition hanging_node_refiner_base.h:374
bool is_marked(Volume *v)
Definition hanging_node_refiner_base.h:333
virtual void refine_edge_with_normal_vertex(Edge *e, Vertex **newCornerVrts=NULL)
called to refine the specified element.
Definition hanging_node_refiner_base.cpp:1520
virtual Vertex * get_center_vertex(Face *f)=0
Returns the vertex associated with the face.
bool node_dependency_order_1_enabled()
enables or disables node-dependency-order-1.
Definition hanging_node_refiner_base.h:121
virtual void process_constrained_vertex(ConstrainedVertex *cdv)
called to refine the specified element.
Definition hanging_node_refiner_base.cpp:1393
bool marked_regular(TElem *elem) const
Definition hanging_node_refiner_base.h:175
virtual bool refinement_is_allowed(Edge *elem)
a callback that allows to deny refinement of special edges
Definition hanging_node_refiner_base.h:225
bool m_nodeDependencyOrder1
Definition hanging_node_refiner_base.h:384
virtual void set_center_vertex(Face *f, Vertex *v)=0
Associates a vertex with the face (pure virtual).
virtual bool refinement_is_allowed(Vertex *elem)
a callback that allows to deny refinement of special vertices
Definition hanging_node_refiner_base.h:223
virtual void refine_volume_with_normal_vertex(Volume *v, Vertex **newVolumeVrts=NULL)
called to refine the specified element.
Definition hanging_node_refiner_base.cpp:2004
TSelector selector_t
Definition hanging_node_refiner_base.h:96
TSelector & get_refmark_selector()
returns the selector which is internally used to mark elements.
Definition hanging_node_refiner_base.h:359
HNodeRefMarks
Definition hanging_node_refiner_base.h:100
@ HNRM_MAX
Definition hanging_node_refiner_base.h:104
@ HNRM_TO_CONSTRAINED
Definition hanging_node_refiner_base.h:102
@ HNRM_TO_NORMAL
Definition hanging_node_refiner_base.h:101
@ HNRM_TO_CONSTRAINING
Definition hanging_node_refiner_base.h:103
bool marked_to_constraining(TElem *elem) const
Definition hanging_node_refiner_base.h:344
virtual void process_constrained_edge(ConstrainedEdge *cde)
called to refine the specified element.
Definition hanging_node_refiner_base.cpp:1439
virtual bool save_marks_to_file(const char *filename)
Writes the associated grid and marks to a file. Pure virtual.
Definition hanging_node_refiner_base.cpp:507
virtual void assign_hnode_marks()
Definition hanging_node_refiner_base.cpp:1092
virtual Vertex * get_center_vertex(Edge *e)=0
Returns the vertex associated with the edge.
bool marked_coarsen(TElem *elem) const
Definition hanging_node_refiner_base.h:181
void enable_node_dependency_order_1(bool bEnable)
enables or disables node-dependency-order-1.
Definition hanging_node_refiner_base.cpp:634
std::vector< SPIRefMarkAdjuster > m_refMarkAdjusters
Definition hanging_node_refiner_base.h:369
void remove_hmark(TElem *elem, uint mark)
Definition hanging_node_refiner_base.cpp:1362
void add_ref_mark_adjuster(SPIRefMarkAdjuster adjuster)
Add a refmark adjuster, which will be called while marks are adjusted during refinement / coarsening.
Definition hanging_node_refiner_base.h:125
virtual void clear_marks()
clears all marks. Default implementation is empty
Definition hanging_node_refiner_base.cpp:121
bool marked_to_normal(TElem *elem) const
Definition hanging_node_refiner_base.h:338
virtual bool continue_collect_objects_for_refine(bool continueRequired)
Definition hanging_node_refiner_base.h:257
The refiner interface allows to mark elements for refinement and to call refine.
Definition refiner_interface.h:67
virtual bool mark(Vertex *v, RefinementMark refMark=RM_REFINE)
Marks an element for refinement. Default implementation is empty.
Definition refiner_interface.h:103
SPRefinementProjector projector()
Definition refiner_interface.h:78
virtual Grid * grid()=0
Returns the grid associated with the refiner.
Base-class for all vertex-types.
Definition grid_base_objects.h:231
Volumes are 3-dimensional objects.
Definition grid_base_objects.h:754
SmartPtr< IRefMarkAdjuster > SPIRefMarkAdjuster
Definition ref_mark_adjuster_interface.h:103
RefinementMark
refinement-marks allow to specify how an element shall be processed during refinement.
Definition refiner_interface.h:48
@ RM_COARSEN
the element is coarsened (only valid for adaptive multi-grid refinement)
Definition refiner_interface.h:56
@ RM_REFINE
DEPRECATED. Use RM_FULL instead.
Definition refiner_interface.h:55
@ RM_CLOSURE
Refines elements according to associated marked edges.
Definition refiner_interface.h:50
@ RM_LOCAL
Refines elements according to a local refinement mark (use 'mark_local')
Definition refiner_interface.h:53
@ RM_FULL
Fully refines an element and all associated sides and edges.
Definition refiner_interface.h:54
const NullSmartPtr SPNULL
The equivalent to NULL for smart pointers.
Definition smart_pointer.h:90
unsigned int uint
Definition types.h:114
the ug namespace