Loading [MathJax]/extensions/tex2jax.js
ug4
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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
40namespace ug
41{
42
53// GetFaceIndex
55
58UG_API int GetFaceIndex(Volume* vol, Face* f);
59
60
62// CalculateNormal
64
77UG_API
78void CalculateNormal(vector3& vNormOut, const FaceVertices* face,
79 Grid::AttachmentAccessor<Vertex, APosition>& aaPos);
80
82// CalculateNormal
84
97UG_API
98void CalculateNormalNoNormalize(vector3& vNormOut, FaceVertices* face,
99 Grid::AttachmentAccessor<Vertex, APosition>& aaPos);
100
102// CalculateFaceNormals
104
109UG_API
110void CalculateFaceNormals(Grid& grid, const FaceIterator& facesBegin,
111 const FaceIterator& facesEnd,
112 AVector3& aPos, AVector3& aNorm);
113
116int NumAssociatedVolumes(Grid& grid, Face* f);
117
119// IsVolumeBoundaryFace
121
126UG_API
127bool IsVolumeBoundaryFace(Grid& grid, Face* f);
128
130// IsVolumeBoundaryFace
132
135UG_API
136bool IsVolumeBoundaryFace(Grid& grid, ConstrainedFace* f);
137
139// IsVolumeBoundaryFace
141
144UG_API
145bool IsVolumeBoundaryFace(Grid& grid, ConstrainingFace* f);
146
149template <class TFace>
150UG_API
151bool IsBoundaryFace3D(Grid& grid, TFace* f)
152{return IsVolumeBoundaryFace(grid, f);}
153
156template <class TFace>
157UG_API
158bool LiesOnBoundary(Grid& grid, TFace* f)
159{return IsBoundaryFace3D(grid, f);}
160
162// FaceArea
164template <class TAAPosVRT>
165UG_API
166number FaceArea(FaceVertices* f, TAAPosVRT& aaPos);
167
169// FaceArea
171template <class TIterator, class TAAPosVRT>
172UG_API
173number FaceArea(TIterator facesBegin, TIterator facesEnd, TAAPosVRT& aaPos);
174
177
181template <class TIterator, class TAAPosVRT>
182UG_API
183Face* FindSmallestFace(TIterator facesBegin, TIterator facesEnd, TAAPosVRT& aaPos);
184
186// FaceQuality
188
195UG_API
196number FaceQuality(FaceVertices* f, Grid::VertexAttachmentAccessor<APosition> aaPos);
197
199// AreaFaceQuality
201
205template <class TIterator>
206UG_API
207number AreaFaceQuality(TIterator facesBegin, TIterator facesEnd,
208 Grid::VertexAttachmentAccessor<APosition>& aaPos);
209
211// TriangleQuality
213
221
223// Triangulate
225
232UG_API
233void Triangulate(Grid& grid, Quadrilateral* q,
234 Grid::VertexAttachmentAccessor<APosition>* paaPos = NULL);
235
237// Triangulate
239
246UG_API
247void Triangulate(Grid& grid,
248 QuadrilateralIterator iterBegin,
249 QuadrilateralIterator iterEnd,
250 Grid::VertexAttachmentAccessor<APosition>* paaPos = NULL);
251
252UG_API
253inline void Triangulate(Grid& grid,
254 Grid::VertexAttachmentAccessor<APosition>* paaPos = NULL);
255
257// GetNeighbours
259
262UG_API
263void GetNeighbours(std::vector<Face*>& vFacesOut, Grid& grid, Face* f,
264 int side, bool clearContainer = true);
265
266
269// template methods
271// CalculateCenter
273
282template<class TVertexPositionAttachmentAccessor>
283UG_API
284typename TVertexPositionAttachmentAccessor::ValueType
285CalculateCenter(const FaceVertices* f, TVertexPositionAttachmentAccessor& aaPosVRT);
291
294template<class TAAPosVRT, class TAAWeightVRT>
295UG_API
296typename TAAPosVRT::ValueType
297CalculateCenter(const FaceVertices* f, TAAPosVRT& aaPos, TAAWeightVRT& aaWeight);
298
299
302
305template <class vector_t, class TAAPos>
306UG_API bool
307ContainsPoint(const FaceVertices* f, const vector_t& p, TAAPos aaPos);
308
309
311// project points to surface
312template <class TTriangleIterator, class TAAPosVRT>
313UG_API
314bool ProjectPointToSurface(vector3& vOut, const vector3& v, const vector3& n,
315 TTriangleIterator trisBegin, TTriangleIterator trisEnd,
316 TAAPosVRT& aaPos, bool compareNormals = false);
317
319
325template <class TAAPosVRT>
326UG_API
327int PointFaceTest(vector3& v, Face* f, TAAPosVRT& aaPos);
328
331
332template <class TAAPosVRT>
333UG_API
334bool IsDegenerated(Face* f, TAAPosVRT& aaPos, number threshold = SMALL);
335
336
339
344UG_API
345void 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 Face * FindSmallestFace(TIterator facesBegin, TIterator facesEnd, TAAPosVRT &aaPos)
Returns the face with the smallest area.
Definition face_util_impl.hpp:260
UG_API bool IsBoundaryFace3D(Grid &grid, TFace *f)
A wrapper for IsVolumeBoundaryFace.
Definition face_util.h:151
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
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
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
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