ug4
face_util.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009-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__LIB_GRID__FACE_UTIL__
34 #define __H__LIB_GRID__FACE_UTIL__
35 
36 #include "lib_grid/grid/grid.h"
39 
40 namespace ug
41 {
42 
53 // GetFaceIndex
55 
58 UG_API int GetFaceIndex(Volume* vol, Face* f);
59 
60 
62 // CalculateNormal
64 
77 UG_API
78 void CalculateNormal(vector3& vNormOut, const FaceVertices* face,
79  Grid::AttachmentAccessor<Vertex, APosition>& aaPos);
80 
82 // CalculateNormal
84 
97 UG_API
98 void CalculateNormalNoNormalize(vector3& vNormOut, FaceVertices* face,
99  Grid::AttachmentAccessor<Vertex, APosition>& aaPos);
100 
102 // CalculateFaceNormals
104 
109 UG_API
110 void CalculateFaceNormals(Grid& grid, const FaceIterator& facesBegin,
111  const FaceIterator& facesEnd,
112  AVector3& aPos, AVector3& aNorm);
113 
116 int NumAssociatedVolumes(Grid& grid, Face* f);
117 
119 // IsVolumeBoundaryFace
121 
126 UG_API
127 bool IsVolumeBoundaryFace(Grid& grid, Face* f);
128 
130 // IsVolumeBoundaryFace
132 
135 UG_API
136 bool IsVolumeBoundaryFace(Grid& grid, ConstrainedFace* f);
137 
139 // IsVolumeBoundaryFace
141 
144 UG_API
145 bool IsVolumeBoundaryFace(Grid& grid, ConstrainingFace* f);
146 
149 template <class TFace>
150 UG_API
151 bool IsBoundaryFace3D(Grid& grid, TFace* f)
152 {return IsVolumeBoundaryFace(grid, f);}
153 
156 template <class TFace>
157 UG_API
158 bool LiesOnBoundary(Grid& grid, TFace* f)
159 {return IsBoundaryFace3D(grid, f);}
160 
162 // FaceArea
164 template <class TAAPosVRT>
165 UG_API
166 number FaceArea(FaceVertices* f, TAAPosVRT& aaPos);
167 
169 // FaceArea
171 template <class TIterator, class TAAPosVRT>
172 UG_API
173 number FaceArea(TIterator facesBegin, TIterator facesEnd, TAAPosVRT& aaPos);
174 
177 
181 template <class TIterator, class TAAPosVRT>
182 UG_API
183 Face* FindSmallestFace(TIterator facesBegin, TIterator facesEnd, TAAPosVRT& aaPos);
184 
186 // FaceQuality
188 
195 UG_API
196 number FaceQuality(FaceVertices* f, Grid::VertexAttachmentAccessor<APosition> aaPos);
197 
199 // AreaFaceQuality
201 
205 template <class TIterator>
206 UG_API
207 number AreaFaceQuality(TIterator facesBegin, TIterator facesEnd,
208  Grid::VertexAttachmentAccessor<APosition>& aaPos);
209 
211 // TriangleQuality
213 
221 
223 // Triangulate
225 
232 UG_API
233 void Triangulate(Grid& grid, Quadrilateral* q,
234  Grid::VertexAttachmentAccessor<APosition>* paaPos = NULL);
235 
237 // Triangulate
239 
246 UG_API
247 void Triangulate(Grid& grid,
248  QuadrilateralIterator iterBegin,
249  QuadrilateralIterator iterEnd,
250  Grid::VertexAttachmentAccessor<APosition>* paaPos = NULL);
251 
252 UG_API
253 inline void Triangulate(Grid& grid,
254  Grid::VertexAttachmentAccessor<APosition>* paaPos = NULL);
255 
257 // GetNeighbours
259 
262 UG_API
263 void GetNeighbours(std::vector<Face*>& vFacesOut, Grid& grid, Face* f,
264  int side, bool clearContainer = true);
265 
266 
269 // template methods
271 // CalculateCenter
273 
282 template<class TVertexPositionAttachmentAccessor>
283 UG_API
284 typename TVertexPositionAttachmentAccessor::ValueType
285 CalculateCenter(const FaceVertices* f, TVertexPositionAttachmentAccessor& aaPosVRT);
291 
294 template<class TAAPosVRT, class TAAWeightVRT>
295 UG_API
296 typename TAAPosVRT::ValueType
297 CalculateCenter(const FaceVertices* f, TAAPosVRT& aaPos, TAAWeightVRT& aaWeight);
298 
299 
302 
305 template <class vector_t, class TAAPos>
306 UG_API bool
307 ContainsPoint(const FaceVertices* f, const vector_t& p, TAAPos aaPos);
308 
309 
311 // project points to surface
312 template <class TTriangleIterator, class TAAPosVRT>
313 UG_API
314 bool ProjectPointToSurface(vector3& vOut, const vector3& v, const vector3& n,
315  TTriangleIterator trisBegin, TTriangleIterator trisEnd,
316  TAAPosVRT& aaPos, bool compareNormals = false);
317 
319 
325 template <class TAAPosVRT>
326 UG_API
327 int PointFaceTest(vector3& v, Face* f, TAAPosVRT& aaPos);
328 
331 
332 template <class TAAPosVRT>
333 UG_API
334 bool IsDegenerated(Face* f, TAAPosVRT& aaPos, number threshold = SMALL);
335 
336 
339 
344 UG_API
345 void InsertCenterVertex(Grid& g, Face* f, Vertex* vrt, bool eraseOldFace);
346 
348 
349 }// end of namespace
350 
352 // include implementation
353 #include "face_util_impl.hpp"
354 
355 #endif
Manages the elements of a grid and their interconnection.
Definition: grid.h:132
static number FaceArea(TDomain &dom, ISubsetHandler &sh, int si, size_t lvl)
Definition: domain_bridge.cpp:262
bool LiesOnBoundary(Grid &grid, Edge *e)
returns true, if the edge lies on a 2d or 3d boundary
Definition: edge_util.cpp:169
int CalculateNormal(vector3 &vNormOut, Grid &grid, Edge *e, Grid::AttachmentAccessor< Vertex, APosition > &aaPos, Grid::AttachmentAccessor< Face, ANormal > *paaNormFACE)
Calculates the normal of the given edge.
Definition: edge_util.cpp:314
int CalculateNormalNoNormalize(vector3 &vNormOut, Grid &grid, Edge *e, Grid::VertexAttachmentAccessor< APosition > &aaPos, Grid::FaceAttachmentAccessor< ANormal > *paaNormFACE)
Calculates the normal of the given edge.
Definition: edge_util.cpp:358
UG_API bool ContainsPoint(const EdgeVertices *e, const vector_t &p, TAAPos aaPos)
Returns true if the given point lies on the given edge.
Definition: edge_util_impl.hpp:513
UG_API bool IsDegenerated(Face *f, TAAPosVRT &aaPos, number threshold=SMALL)
returns true if the given face is degenerated.
Definition: face_util_impl.hpp:218
UG_API bool IsBoundaryFace3D(Grid &grid, TFace *f)
A wrapper for IsVolumeBoundaryFace.
Definition: face_util.h:151
void CalculateFaceNormals(Grid &grid, const FaceIterator &facesBegin, const FaceIterator &facesEnd, AVector3 &aPos, AVector3 &aNorm)
calculates the normal of each face. Presumes that all faces are flat.
Definition: face_util.cpp:128
int NumAssociatedVolumes(Grid &grid, Face *f)
returns the number of associated volumes of the specified face
Definition: face_util.cpp:147
number FaceQuality(FaceVertices *f, Grid::VertexAttachmentAccessor< APosition > aaPos)
a simple measure for the quality of a face
Definition: face_util.cpp:203
void GetNeighbours(std::vector< Face * > &vFacesOut, Grid &grid, Face *f, int side, bool clearContainer)
collects neighbours of the given side of a face.
Definition: face_util.cpp:363
UG_API number AreaFaceQuality(TIterator facesBegin, TIterator facesEnd, Grid::VertexAttachmentAccessor< APosition > &aaPos)
returns a value between 0 (bad) and 1 (good) that describes the quality of the area.
Definition: face_util_impl.hpp:43
UG_API int PointFaceTest(vector3 &v, Face *f, TAAPosVRT &aaPos)
Definition: face_util_impl.hpp:201
UG_API bool ProjectPointToSurface(vector3 &vOut, const vector3 &v, const vector3 &n, TTriangleIterator trisBegin, TTriangleIterator trisEnd, TAAPosVRT &aaPos, bool compareNormals=false)
Definition: face_util_impl.hpp:153
void Triangulate(Grid &grid, Quadrilateral *q, Grid::VertexAttachmentAccessor< APosition > *paaPos)
removes the quadrilateral and replaces it by two triangles.
Definition: face_util.cpp:273
int GetFaceIndex(Volume *vol, Face *f)
returns the index at which face f is found in the given object
Definition: face_util.cpp:46
UG_API Face * FindSmallestFace(TIterator facesBegin, TIterator facesEnd, TAAPosVRT &aaPos)
Returns the face with the smallest area.
Definition: face_util_impl.hpp:260
void InsertCenterVertex(Grid &g, Face *f, Vertex *vrt, bool eraseOldFace)
Refines the face by connecting its sides with the new center.
Definition: face_util.cpp:394
number TriangleQuality(vector3 &v1, vector3 &v2, vector3 &v3)
a simple measure for the quality of a triangle
Definition: face_util.cpp:242
bool IsVolumeBoundaryFace(Grid &grid, Face *f)
returns true if the given face is a boundary face.
Definition: face_util.cpp:177
#define UG_API
Definition: ug_config.h:65
double number
Definition: types.h:124
void CalculateCenter(vector_t &centerOut, const vector_t *pointSet, size_t numPoints)
calculates the center of a point-set
Definition: math_util_impl.hpp:98
MathVector< 3, number > vector3
a 3d vector
Definition: ugmath_types.h:72
the ug namespace
geometry_traits< Quadrilateral >::iterator QuadrilateralIterator
Definition: grid_objects_2d.h:366
ElementStorage< Face >::SectionContainer::iterator FaceIterator
Definition: grid_base_object_traits.h:79
const number SMALL
Definition: math_constants.h:41
Attachment< vector3 > AVector3
Definition: common_attachments.h:62