ug4
hanging_node_refiner_multi_grid.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__HANGIN_NODE_REFINER_MULTI_GRID__
34 #define __H__UG__HANGIN_NODE_REFINER_MULTI_GRID__
35 
38 
39 namespace ug
40 {
41 
44 
46 
68 {
69  public:
71  using BaseClass::mark;
72 
82  };
83 
84  public:
88 
90 
91  virtual void grid_to_be_destroyed(Grid* grid);
92 
93  virtual void assign_grid(MultiGrid& mg);
94  virtual Grid* get_associated_grid() {return m_pMG;}//depreciated
95  virtual Grid* grid() {return m_pMG;}
96  virtual MultiGrid* multi_grid() {return m_pMG;}
97 
98  virtual bool adaptivity_supported() const {return true;}
99  virtual bool coarsening_supported() const {return true;}
100 
101  protected:
103  virtual void num_marked_edges_local(std::vector<int>& numMarkedEdgesOut);
105  virtual void num_marked_faces_local(std::vector<int>& numMarkedFacesOut);
107  virtual void num_marked_volumes_local(std::vector<int>& numMarkedVolsOut);
108 
109  template <class TElem>
110  void num_marked_elems(std::vector<int>& numMarkedElemsOut);
111 
113 
134  virtual bool perform_coarsening();
135 
136  void save_coarsen_marks_to_file(ISelector& sel, const char* filename);
137  void debug_save(ISelector& sel, const char* filename);
138 
140  virtual bool refinement_is_allowed(Vertex* elem);
142  virtual bool refinement_is_allowed(Edge* elem);
144  virtual bool refinement_is_allowed(Face* elem);
146  virtual bool refinement_is_allowed(Volume* elem);
147 
149 
155  void set_grid(MultiGrid* mg);
156 
157  virtual void assign_hnode_marks();
158 
160  virtual void pre_refine();
161 
163 
164  virtual void pre_coarsen() {};
165 
167 
168  virtual void post_coarsen() {};
169 
170 
176  virtual void process_constraining_edge(ConstrainingEdge* cge);
177 
178  virtual void refine_edge_with_normal_vertex(Edge* e,
179  Vertex** newCornerVrts = NULL);
180  virtual void refine_edge_with_hanging_vertex(Edge* e,
181  Vertex** newCornerVrts = NULL);
182 
183  virtual void refine_face_with_normal_vertex(Face* f,
184  Vertex** newCornerVrts = NULL);
185  virtual void refine_face_with_hanging_vertex(Face* f,
186  Vertex** newCornerVrts = NULL);
187 
189  Vertex** newVolumeVrts = NULL);
190  /* \} */
191 
193  virtual Vertex* get_center_vertex(Edge* e);
194 
196  virtual void set_center_vertex(Edge* e, Vertex* v);
197 
199  virtual Vertex* get_center_vertex(Face* f);
200 
202  virtual void set_center_vertex(Face* f, Vertex* v);
203 
204 
206 
209  template <class TElem>
210  void collect_child_corners(std::vector<Vertex*>& cornersOut, TElem* elem)
211  {
212  cornersOut.resize(elem->num_vertices());
213  for(size_t i = 0; i < elem->num_vertices(); ++i){
214  //UG_ASSERT(m_pMG->get_child_vertex(elem->vertex(i)), "A child vertex has to exists!");
215  cornersOut[i] = m_pMG->get_child_vertex(elem->vertex(i));
216  }
217  }
218 
220 
223 
225 
229 
231  template <class TElem>
233 
235 
237  template <class TElem>
239 
241 
249 // template <class TElem>
250 // void classify_selection();
251 
253 
255  //template <class TElem>
256  //void adjust_coarsen_marks_on_side_elements();
257 
259 
260 // template <class TElem>
261 // bool deselect_invalid_coarsen_families();
262 //
263 // template <class TElem>
264 // void deselect_isolated_sides();
265 //
266 // template <class TElem>
267 // void deselect_uncoarsenable_parents();
268 
270 
276  virtual void collect_objects_for_coarsen(bool scheduleCoarseningBeginsMessage = false);
277 
278 
280  // Callbacks for PARALLELIZATION
281 
283 
288 // virtual bool continue_collect_objects_for_coarsen(bool continueRequired)
289 // {return continueRequired;}
290 
292 
296 // virtual void broadcast_vertex_coarsen_marks() {}
297 // virtual void broadcast_edge_coarsen_marks() {}
298 // virtual void broadcast_face_coarsen_marks() {}
301 
303  virtual bool contains_edges() {return m_pMG->num<Edge>() > 0;}
304 
306 
307  virtual bool contains_faces() {return m_pMG->num<Face>() > 0;}
308 
310 
311  virtual bool contains_volumes() {return m_pMG->num<Volume>() > 0;}
312 
319  //virtual void assign_hnode_coarsen_marks();
320 
321  virtual void broadcast_marks_horizontally(bool vertices, bool edges, bool faces,
322  bool allowDeselection = false) {}
323  virtual void broadcast_marks_vertically(bool vertices, bool edges,
324  bool faces, bool volumes,
325  bool allowDeselection = false) {}
326 
327  virtual void copy_marks_to_vmasters(bool vertices, bool edges,
328  bool faces, bool volumes) {}
329 
330  virtual void copy_marks_to_vslaves(bool vertices, bool edges,
331  bool faces, bool volumes) {}
332 
333  virtual bool one_proc_true(bool localProcTrue) {return localProcTrue;}
334 
335  private:
337 };
338 
340 
341 }// end of namespace
342 
343 #endif
contains elements of type
Definition: grid_objects_1d.h:279
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
Specialization of ug::HangingNodeRefiner for ug::MultiGrid.
Definition: hanging_node_refiner_multi_grid.h:68
virtual ~HangingNodeRefiner_MultiGrid()
Definition: hanging_node_refiner_multi_grid.cpp:86
virtual void refine_edge_with_hanging_vertex(Edge *e, Vertex **newCornerVrts=NULL)
calls base implementation and replaces cge with a normal edge.
Definition: hanging_node_refiner_multi_grid.cpp:314
void set_grid(MultiGrid *mg)
performs registration and deregistration at a grid.
Definition: hanging_node_refiner_multi_grid.cpp:135
virtual void post_coarsen()
called after elements have been removed in coarsening
Definition: hanging_node_refiner_multi_grid.h:168
virtual void num_marked_volumes_local(std::vector< int > &numMarkedVolsOut)
returns the number of (globally) marked volumes on this level of the hierarchy
Definition: hanging_node_refiner_multi_grid.cpp:116
virtual void pre_refine()
creates required vertices in higher levels.
Definition: hanging_node_refiner_multi_grid.cpp:224
virtual void copy_marks_to_vmasters(bool vertices, bool edges, bool faces, bool volumes)
Definition: hanging_node_refiner_multi_grid.h:327
void save_coarsen_marks_to_file(ISelector &sel, const char *filename)
Definition: hanging_node_refiner_multi_grid.cpp:668
virtual void assign_hnode_marks()
Definition: hanging_node_refiner_multi_grid.cpp:173
virtual bool one_proc_true(bool localProcTrue)
Definition: hanging_node_refiner_multi_grid.h:333
virtual void refine_edge_with_normal_vertex(Edge *e, Vertex **newCornerVrts=NULL)
calls base implementation and replaces cge with a normal edge.
Definition: hanging_node_refiner_multi_grid.cpp:303
virtual bool contains_faces()
allows to check whether a distributed grid contains faces
Definition: hanging_node_refiner_multi_grid.h:307
virtual void restrict_selection_to_coarsen_families()
Deselects all elements which have an unselected sibling.
Definition: hanging_node_refiner_multi_grid.cpp:426
virtual bool perform_coarsening()
performs coarsening on the elements marked with RM_COARSEN.
Definition: hanging_node_refiner_multi_grid.cpp:1437
virtual bool contains_edges()
called to check, whether another iteration of collect_objects_for_coarsen has to be performed.
Definition: hanging_node_refiner_multi_grid.h:303
virtual void refine_volume_with_normal_vertex(Volume *v, Vertex **newVolumeVrts=NULL)
calls base implementation and replaces cge with a normal edge.
Definition: hanging_node_refiner_multi_grid.cpp:347
virtual void pre_coarsen()
called before elements are removed in coarsening
Definition: hanging_node_refiner_multi_grid.h:164
virtual Grid * get_associated_grid()
DEPRECIATED! Use grid(). Has to return the associated grid. Pure virtual.
Definition: hanging_node_refiner_multi_grid.h:94
virtual MultiGrid * multi_grid()
Definition: hanging_node_refiner_multi_grid.h:96
void debug_save(ISelector &sel, const char *filename)
temporary method, which will be removed when debugging is done.
Definition: hanging_node_refiner_multi_grid.cpp:676
virtual void refine_face_with_normal_vertex(Face *f, Vertex **newCornerVrts=NULL)
calls base implementation and replaces cge with a normal edge.
Definition: hanging_node_refiner_multi_grid.cpp:325
virtual void refine_face_with_hanging_vertex(Face *f, Vertex **newCornerVrts=NULL)
calls base implementation and replaces cge with a normal edge.
Definition: hanging_node_refiner_multi_grid.cpp:336
HNodeCoarsenMarks
Definition: hanging_node_refiner_multi_grid.h:73
@ HNCM_NO_NBRS
Definition: hanging_node_refiner_multi_grid.h:75
@ HNCM_ALL
Definition: hanging_node_refiner_multi_grid.h:79
@ HNCM_INVALID
Definition: hanging_node_refiner_multi_grid.h:80
@ HNCM_PARTIAL
Definition: hanging_node_refiner_multi_grid.h:77
@ HNCM_UNKNOWN
Definition: hanging_node_refiner_multi_grid.h:81
@ HNCM_REPLACE
Definition: hanging_node_refiner_multi_grid.h:78
@ HNCM_NONE
Definition: hanging_node_refiner_multi_grid.h:76
@ HNCM_FIRST
Definition: hanging_node_refiner_multi_grid.h:74
void collect_child_corners(std::vector< Vertex * > &cornersOut, TElem *elem)
collects corner vertices and fills them into the associated vector
Definition: hanging_node_refiner_multi_grid.h:210
virtual bool coarsening_supported() const
returns true, if the refiner supports coarsening.
Definition: hanging_node_refiner_multi_grid.h:99
virtual void collect_objects_for_coarsen(bool scheduleCoarseningBeginsMessage=false)
adjusts the selection marks to those specified in HNodeCoarsenMarks.
Definition: hanging_node_refiner_multi_grid.cpp:1054
virtual bool adaptivity_supported() const
returns whether the refiner is able to perform adaptive refinement
Definition: hanging_node_refiner_multi_grid.h:98
virtual Vertex * get_center_vertex(Edge *e)
Returns the vertex associated with the edge.
Definition: hanging_node_refiner_multi_grid.cpp:358
virtual void process_constraining_edge(ConstrainingEdge *cge)
calls base implementation and replaces cge with a normal edge.
Definition: hanging_node_refiner_multi_grid.cpp:288
void num_marked_elems(std::vector< int > &numMarkedElemsOut)
Definition: hanging_node_refiner_multi_grid.cpp:124
virtual Grid * grid()
Returns the grid associated with the refiner.
Definition: hanging_node_refiner_multi_grid.h:95
virtual void set_center_vertex(Edge *e, Vertex *v)
Associates a vertex with the edge.
Definition: hanging_node_refiner_multi_grid.cpp:365
virtual void assign_grid(MultiGrid &mg)
Definition: hanging_node_refiner_multi_grid.cpp:98
virtual void num_marked_edges_local(std::vector< int > &numMarkedEdgesOut)
returns the number of (globally) marked edges on this level of the hierarchy
Definition: hanging_node_refiner_multi_grid.cpp:104
HangingNodeRefiner_MultiGrid(SPRefinementProjector projector=SPNULL)
Definition: hanging_node_refiner_multi_grid.cpp:68
virtual void restrict_selection_to_surface_coarsen_elements()
Makes sure that only surface elements are marked and that only coarsen marks are used.
Definition: hanging_node_refiner_multi_grid.cpp:391
virtual void copy_marks_to_vslaves(bool vertices, bool edges, bool faces, bool volumes)
Definition: hanging_node_refiner_multi_grid.h:330
virtual void broadcast_marks_horizontally(bool vertices, bool edges, bool faces, bool allowDeselection=false)
Definition: hanging_node_refiner_multi_grid.h:321
virtual void broadcast_marks_vertically(bool vertices, bool edges, bool faces, bool volumes, bool allowDeselection=false)
Definition: hanging_node_refiner_multi_grid.h:323
MultiGrid * m_pMG
Definition: hanging_node_refiner_multi_grid.h:336
virtual void num_marked_faces_local(std::vector< int > &numMarkedFacesOut)
returns the number of (globally) marked faces on this level of the hierarchy
Definition: hanging_node_refiner_multi_grid.cpp:110
HangingNodeRefinerBase< MGSelector > BaseClass
Definition: hanging_node_refiner_multi_grid.h:70
virtual void grid_to_be_destroyed(Grid *grid)
Definition: hanging_node_refiner_multi_grid.cpp:92
virtual bool refinement_is_allowed(Vertex *elem)
a callback that allows to deny refinement of special vertices
Definition: hanging_node_refiner_multi_grid.cpp:145
virtual bool contains_volumes()
allows to check whether a distributed grid contains volumes
Definition: hanging_node_refiner_multi_grid.h:311
Base class for a hanging-node refiner.
Definition: hanging_node_refiner_base.h:92
virtual bool mark(Vertex *v, RefinementMark refMark=RM_REFINE)
Marks an element for refinement. Default implementation is empty.
Definition: refiner_interface.h:103
@ HNRM_MAX
Definition: hanging_node_refiner_base.h:104
SPRefinementProjector projector()
Definition: refiner_interface.h:78
base-implementation of a selector
Definition: selector_interface.h:126
Definition: multi_grid.h:72
size_t num(int level) const
Definition: multi_grid.h:154
Vertex * get_child_vertex(TElem *elem) const
Returns the child vertex of the given element or NULL if there is none.
Definition: multi_grid.h:276
Base-class for all vertex-types.
Definition: grid_base_objects.h:231
Volumes are 3-dimensional objects.
Definition: grid_base_objects.h:754
const NullSmartPtr SPNULL
The equivalent to NULL for smart pointers.
Definition: smart_pointer.h:90
std::pair< counting_iterator< size_t >, counting_iterator< size_t > > vertices(ug::BidirectionalMatrix< T > const &M)
Definition: bidirectional_boost.h:60
the ug namespace