33 #ifndef __H__UG_ELEMENT_ASPECT_RATIOS
34 #define __H__UG_ELEMENT_ASPECT_RATIOS
66 template <
class TAAPosVRT>
73 typedef typename TAAPosVRT::ValueType ValueType;
75 number minHeight, tmpMinHeight;
76 ValueType v = aaPos[face->
vertex(2)];
83 for(
uint i = 1; i < 3; ++i)
85 v = aaPos[face->
vertex((i+2)%3)];
89 if(tmpMinHeight < minHeight)
91 minHeight = tmpMinHeight;
98 UG_ASSERT(
false,
"Error. Face is not a triangle.");
109 template <
class TElem,
class TAAPosVRT>
113 template <
class TAAPosVRT>
117 box_t box(aaPos[vrts[0]], aaPos[vrts[0]]);
119 box = box_t(box, aaPos[vrts[i]]);
121 const number xDist = box.max.x() - box.min.x();
122 const number yDist = box.max.y() - box.min.y();
123 return xDist > yDist ? xDist/yDist : yDist/xDist;
127 template <
class TAAPosVRT>
136 maxEdgeLength =
EdgeLength(longestEdge, aaPos);
150 return 2/std::sqrt(3.0) * minTriangleHeight / maxEdgeLength;
154 template <
class TAAPosVRT>
171 UG_THROW(
"Note: Currently only faces of type triangle and quadrilateral"
172 " supported in aspect ratio calculation.");
180 template <
class TAAPosVRT>
194 template <
class TAAPosVRT>
201 template <
class TAAPosVRT>
207 template <
class TAAPosVRT>
229 UG_THROW(
"Note: Currently only volumes of type tetrahedron, hexahedron"
230 "and pyramids supported in aspect ratio calculation.");
244 template <
class TElem,
class TAAPosVRT>
248 template <
class TAAPosVRT>
251 UG_THROW(
"CalculateVolToRMSFaceAreaRatio: Currently only volumes of type tetrahedron"
252 " supported in volume to root-mean-square face area ratio calculation.");
257 template <
class TAAPosVRT>
279 template <
class TAAPosVRT>
292 template <
class TAAPosVRT>
309 UG_THROW(
"CalculateVolToRMSFaceAreaRatio: Currently only volumes of type tetrahedron"
310 " supported in volume to root-mean-square face area ratio calculation.");
321 template <
class TIterator,
class TAAPosVRT>
327 if(facesBegin == facesEnd)
331 Face* largestFace = *facesBegin;
335 for(; facesBegin != facesEnd; ++facesBegin){
336 Face* curFace = *facesBegin;
338 if(curArea > largestArea){
339 largestFace = curFace;
340 largestArea = curArea;
350 template <
class TIterator,
class TAAPosVRT>
357 if(volumesBegin == volumesEnd)
366 for(; volumesBegin != volumesEnd; ++volumesBegin)
368 Volume* curVolume = *volumesBegin;
371 if(curVolumeVolume < smallestVolumeVolume)
373 smallestVolume = curVolume;
374 smallestVolumeVolume = curVolumeVolume;
378 return smallestVolume;
384 template <
class TIterator,
class TAAPosVRT>
391 if(volumesBegin == volumesEnd)
400 for(; volumesBegin != volumesEnd; ++volumesBegin)
402 Volume* curVolume = *volumesBegin;
405 if(curVolumeVolume > largestVolumeVolume)
407 largestVolume = curVolume;
408 largestVolumeVolume = curVolumeVolume;
412 return largestVolume;
418 template <
class TIterator,
class TAAPosVRT>
421 TIterator elemsEnd, TAAPosVRT& aaPos)
426 if(elemsBegin == elemsEnd)
435 for(; elemsBegin != elemsEnd; ++elemsBegin)
441 if(curSmallestAspectRatio < smallestAspectRatio)
443 elementWithSmallestAspectRatio = curElement;
444 smallestAspectRatio = curSmallestAspectRatio;
448 return elementWithSmallestAspectRatio;
454 template <
class TIterator,
class TAAPosVRT>
457 TIterator elemsEnd, TAAPosVRT& aaPos)
462 if(elemsBegin == elemsEnd)
471 for(; elemsBegin != elemsEnd; ++elemsBegin)
477 if(curSmallestAspectRatio > largestAspectRatio)
479 elementWithLargestAspectRatio = curElement;
480 largestAspectRatio = curSmallestAspectRatio;
484 return elementWithLargestAspectRatio;
490 template <
class TIterator,
class TAAPosVRT>
493 TIterator elemsEnd, TAAPosVRT& aaPos)
498 if(elemsBegin == elemsEnd)
507 for(; elemsBegin != elemsEnd; ++elemsBegin)
513 if(curSmallestRatio < smallestRatio)
515 elementWithSmallestRatio = curElement;
516 smallestRatio = curSmallestRatio;
520 return elementWithSmallestRatio;
526 template <
class TIterator,
class TAAPosVRT>
529 TIterator elemsEnd, TAAPosVRT& aaPos)
534 if(elemsBegin == elemsEnd)
543 for(; elemsBegin != elemsEnd; ++elemsBegin)
549 if(curSmallestRatio > largestRatio)
551 elementWithLargestRatio = curElement;
552 largestRatio = curSmallestRatio;
556 return elementWithLargestRatio;
virtual Face::ConstVertexArray vertices() const
Definition: grid_objects_2d.h:266
virtual size_t num_vertices() const
Definition: grid_objects_2d.h:267
Base-class for edges.
Definition: grid_base_objects.h:397
Faces are 2-dimensional objects.
Definition: grid_base_objects.h:510
virtual ReferenceObjectID reference_object_id() const
Definition: grid_base_objects.h:550
virtual Vertex * vertex(size_t index) const
Definition: grid_base_objects.h:486
virtual size_t num_vertices() const
Definition: grid_base_objects.h:488
Manages the elements of a grid and their interconnection.
Definition: grid.h:132
A volume element with 6 quadrilateral sides.
Definition: grid_objects_3d.h:227
A volume element with 4 triangle and 1 quadrilateral sides.
Definition: grid_objects_3d.h:493
a face with four points.
Definition: grid_objects_2d.h:323
the most simple volume-element.
Definition: grid_objects_3d.h:91
the most simple form of a face
Definition: grid_objects_2d.h:174
Base-class for all vertex-types.
Definition: grid_base_objects.h:231
Volumes are 3-dimensional objects.
Definition: grid_base_objects.h:754
virtual ReferenceObjectID reference_object_id() const
Definition: grid_base_objects.h:927
static number FaceArea(TDomain &dom, ISubsetHandler &sh, int si, size_t lvl)
Definition: domain_bridge.cpp:262
UG_API number EdgeLength(const EdgeVertices *e, TAAPosVRT &aaPos)
Calculates the length of the given edge.
Definition: edge_util_impl.hpp:80
UG_API void CollectAssociated(std::vector< Vertex * > &vVertexOut, Grid &grid, GridObject *obj, bool clearContainer=true)
Definition: grid_util_impl.hpp:169
number CalculateVolume(Volume *elem, TAAPos aaPos)
Calculates the volume of the given element.
Definition: volume_calculation_impl.hpp:43
UG_API number CalculateHexahedronVolToRMSFaceAreaRatio(Grid &grid, Hexahedron *hex, Grid::VertexAttachmentAccessor< APosition > &aaPos)
Definition: volume_util.cpp:313
UG_API number CalculateTetrahedronVolToRMSFaceAreaRatio(Grid &grid, Tetrahedron *tet, Grid::VertexAttachmentAccessor< APosition > &aaPos)
Definition: volume_util.cpp:285
number CalculatePyramidAspectRatio(Grid &grid, Pyramid *pyr, Grid::VertexAttachmentAccessor< AVector3 > &aaPos)
calculates the aspect ratio of a pyramidal element Pyramid aspect ratio (AR) is the ratio of the heig...
Definition: volume_util.cpp:228
number CalculateHexahedronAspectRatio(Grid &grid, Hexahedron *hex, Grid::VertexAttachmentAccessor< AVector3 > &aaPos)
calculates the aspect ratio of a hexahedral element
Definition: volume_util.cpp:171
number CalculateTetrahedronAspectRatio(Grid &grid, Tetrahedron *tet, Grid::VertexAttachmentAccessor< AVector3 > &aaPos)
calculates the aspect ratio of a tetrahedral element
Definition: volume_util.cpp:138
#define UG_ASSERT(expr, msg)
Definition: assert.h:70
#define UG_THROW(msg)
Definition: error.h:57
unsigned int uint
Definition: types.h:114
double number
Definition: types.h:124
number DistancePointToRay(const vector_t &v, const vector_t &from, const vector_t &dir)
calculates the distance of a point to a ray
Definition: math_util_impl.hpp:225
void VecSubtract(vector_t &vOut, const vector_t &v1, const vector_t &v2)
subtracts v2 from v1 and stores the result in a vOut
Definition: math_vector_functions_common_impl.hpp:226
Definition: smart_pointer.h:814
TIterator::value_type FindElementWithLargestVolToRMSFaceAreaRatio(Grid &grid, TIterator elemsBegin, TIterator elemsEnd, TAAPosVRT &aaPos)
Definition: element_aspect_ratios.h:528
TIterator::value_type FindElementWithSmallestVolToRMSFaceAreaRatio(Grid &grid, TIterator elemsBegin, TIterator elemsEnd, TAAPosVRT &aaPos)
Definition: element_aspect_ratios.h:492
@ ROID_TETRAHEDRON
Definition: grid_base_objects.h:80
@ ROID_QUADRILATERAL
Definition: grid_base_objects.h:79
@ ROID_PYRAMID
Definition: grid_base_objects.h:83
@ ROID_HEXAHEDRON
Definition: grid_base_objects.h:81
@ ROID_TRIANGLE
Definition: grid_base_objects.h:78
Edge * FindLongestEdge(TEdgeIterator edgesBegin, TEdgeIterator edgesEnd, TAAPosVRT &aaPos)
Definition: edge_util_impl.hpp:332
number CalculateVolToRMSFaceAreaRatio(Grid &grid, Volume *vol, TAAPosVRT &aaPos)
Volume.
Definition: element_aspect_ratios.h:293
TIterator::value_type FindLargestVolume(TIterator volumesBegin, TIterator volumesEnd, TAAPosVRT &aaPos)
Definition: element_aspect_ratios.h:386
TIterator::value_type FindElementWithSmallestAspectRatio(Grid &grid, TIterator elemsBegin, TIterator elemsEnd, TAAPosVRT &aaPos)
Definition: element_aspect_ratios.h:420
TIterator::value_type FindSmallestVolume(TIterator volumesBegin, TIterator volumesEnd, TAAPosVRT &aaPos)
Definition: element_aspect_ratios.h:352
TIterator::value_type FindElementWithLargestAspectRatio(Grid &grid, TIterator elemsBegin, TIterator elemsEnd, TAAPosVRT &aaPos)
Definition: element_aspect_ratios.h:456
number CalculateAspectRatio(Grid &grid, Volume *vol, TAAPosVRT &aaPos)
Volume.
Definition: element_aspect_ratios.h:208
Face * FindLargestFace(TIterator facesBegin, TIterator facesEnd, TAAPosVRT &aaPos)
Definition: element_aspect_ratios.h:322
number CalculateMinTriangleHeight(Face *face, TAAPosVRT &aaPos)
Definition: element_aspect_ratios.h:67
T value_type
Definition: sparsematrix_interface.h:2