ug4
refinement_projector.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016: 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_refinement_projector
34 #define __H__UG_refinement_projector
35 
37 #include "common/error.h"
38 #include "lib_grid/grid/geometry.h"
39 #include "lib_grid/grid/sub_grid.h"
41 
42 namespace ug{
43 
45 
56 public:
58 
62  {}
63 
66  {}
67 
69  SPElementCallback concernedElems) :
71  m_concernedElementsCallback (concernedElems)
72  {}
73 
74  virtual ~RefinementProjector () {}
75 
77  {
79  }
80 
81  virtual SPIGeometry3d geometry () const {return m_geometry;}
82 
83 
86 
95  virtual bool refinement_begins_requires_subgrid () const {return false;}
96 
98 
107  virtual void refinement_begins(const ISubGrid* sg)
108  {
110  "Please set a valid geometry to RefinementProjectors "
111  "before using them during refinement.");
113  "subgrid required in 'RefinementProjector::refinement_begins' "
114  "but not provided.");
115  }
116 
118  virtual void refinement_ends() {}
119 
121  virtual number new_vertex(Vertex* vrt, Vertex* parent)
122  {
123  set_pos(vrt, pos(parent));
124  return 1;
125  }
126 
128  virtual number new_vertex(Vertex* vrt, Edge* parent)
129  {
130  set_pos(vrt, geom().element_center(parent));
131  return 1;
132  }
133 
135  virtual number new_vertex(Vertex* vrt, Face* parent)
136  {
137  set_pos(vrt, geom().element_center(parent));
138  return 1;
139  }
140 
142  virtual number new_vertex(Vertex* vrt, Volume* parent)
143  {
144  set_pos(vrt, geom().element_center(parent));
145  return 1;
146  }
147 
148 protected:
149  vector3 pos (Vertex* v) const
150  {
151  // UG_COND_THROW(m_geometry.invalid(),
152  // "Invalid Geometry in IRefinementProjector. Please make "
153  // "sure to set a valid adaptor through 'set_geometry_adaptor'.");
154  return m_geometry->pos(v);
155  }
156 
157  void set_pos(Vertex* v, const vector3& p)
158  {
159  // UG_COND_THROW(m_geometry.invalid(),
160  // "Invalid Geometry in IRefinementProjector. Please make "
161  // "sure to set a valid adaptor through 'set_geometry_adaptor'.");
162  m_geometry->set_pos(v, p);
163  }
164 
165  IGeometry3d& geom () {return *m_geometry;}
166  const IGeometry3d& geom () const {return *m_geometry;}
167 
168  template <class TElem>
169  bool is_concerned (TElem* e) {
170  return (*m_concernedElementsCallback)(e);
171  }
172 
173 private:
175 
176  template <class Archive>
177  void serialize( Archive& ar, const unsigned int version)
178  {
179  }
180 
183 };
184 
186 
187 }// end of namespace
188 
189 #endif //__H__UG_refinement_projector
parameterString p
bool invalid() const
returns true if the pointer is invalid, false if not.
Definition: smart_pointer.h:212
callback that always returns true
Definition: basic_callbacks.h:50
Base-class for edges.
Definition: grid_base_objects.h:397
Faces are 2-dimensional objects.
Definition: grid_base_objects.h:510
provides a grid and access to the coordinates of the vertices
Definition: geometry.h:63
Instances represent a part of a grid.
Definition: sub_grid.h:44
Adjusts vertex coordinates during refinement.
Definition: refinement_projector.h:55
virtual ~RefinementProjector()
Definition: refinement_projector.h:74
RefinementProjector()
Definition: refinement_projector.h:57
RefinementProjector(SPIGeometry3d geometry, SPElementCallback concernedElems)
Definition: refinement_projector.h:68
SPIGeometry3d m_geometry
Definition: refinement_projector.h:181
void set_pos(Vertex *v, const vector3 &p)
Definition: refinement_projector.h:157
virtual void set_concerned_elements(SPElementCallback cb)
Definition: refinement_projector.h:84
bool is_concerned(TElem *e)
Definition: refinement_projector.h:169
IGeometry3d & geom()
Definition: refinement_projector.h:165
virtual bool refinement_begins_requires_subgrid() const
Definition: refinement_projector.h:95
virtual number new_vertex(Vertex *vrt, Face *parent)
called when a new vertex was created from an old face.
Definition: refinement_projector.h:135
virtual number new_vertex(Vertex *vrt, Vertex *parent)
called when a new vertex was created from an old vertex.
Definition: refinement_projector.h:121
virtual number new_vertex(Vertex *vrt, Volume *parent)
called when a new vertex was created from an old volume.
Definition: refinement_projector.h:142
RefinementProjector(SPIGeometry3d geometry)
Definition: refinement_projector.h:59
virtual void refinement_begins(const ISubGrid *sg)
called before refinement begins
Definition: refinement_projector.h:107
virtual void set_geometry(SPIGeometry3d geometry)
Definition: refinement_projector.h:76
vector3 pos(Vertex *v) const
Definition: refinement_projector.h:149
SPElementCallback m_concernedElementsCallback
Definition: refinement_projector.h:182
friend class boost::serialization::access
Definition: refinement_projector.h:174
const IGeometry3d & geom() const
Definition: refinement_projector.h:166
virtual void refinement_ends()
called when refinement is done
Definition: refinement_projector.h:118
virtual SPIGeometry3d geometry() const
Definition: refinement_projector.h:81
RefinementProjector(SPElementCallback cb)
Definition: refinement_projector.h:64
virtual number new_vertex(Vertex *vrt, Edge *parent)
called when a new vertex was created from an old edge.
Definition: refinement_projector.h:128
void serialize(Archive &ar, const unsigned int version)
Definition: refinement_projector.h:177
Base-class for all vertex-types.
Definition: grid_base_objects.h:231
Volumes are 3-dimensional objects.
Definition: grid_base_objects.h:754
#define UG_COND_THROW(cond, msg)
UG_COND_THROW(cond, msg) : performs a UG_THROW(msg) if cond == true.
Definition: error.h:61
double number
Definition: types.h:124
the ug namespace
SmartPtr< RefinementProjector > SPRefinementProjector
Definition: refinement_projector.h:185
SmartPtr< T, FreePolicy > make_sp(T *inst)
returns a SmartPtr for the passed raw pointer
Definition: smart_pointer.h:836
function ProblemDisc new(problemDesc, dom)