33 #ifndef __H__UG_ELEMENT_ANGLES
34 #define __H__UG_ELEMENT_ANGLES
90 "Only two edges may be adjacent to a vertex in a face element.");
92 if(sidesOut[0] == NULL)
101 "Exactly two edges should be adjacent to a vertex in a face element.")
118 vector<Face*> vNeighbourFacesToEdge;
129 bool allMarked =
true;
140 "Only two faces may be adjacent to an edge in a volume element.")
142 if(sidesOut[0] == NULL)
153 "Exactly two faces should be adjacent to an edge in a volume element.")
162 template <
class TElem,
class TAAPosVRT>
166 template <
class TAAPosVRT>
179 LOG(
"WARNING: autoenabling GRIDOPT_AUTOGENERATE_SIDES in GetNeighbours(Face).\n");
184 typedef typename TAAPosVRT::ValueType ValueType;
188 ValueType vNorm1, vNorm2;
189 ValueType vDir1, vDir2;
192 Edge* vNeighbourEdgesToVertex[2];
197 for(
uint vrtIter = 0; vrtIter < numFaceVrts; ++vrtIter)
206 if(vrt != vNeighbourEdgesToVertex[0]->vertex(0))
207 adjacentVrt1 = vNeighbourEdgesToVertex[0]->
vertex(0);
209 adjacentVrt1 = vNeighbourEdgesToVertex[0]->
vertex(1);
211 if(vrt != vNeighbourEdgesToVertex[1]->vertex(0))
212 adjacentVrt2 = vNeighbourEdgesToVertex[1]->
vertex(0);
214 adjacentVrt2 = vNeighbourEdgesToVertex[1]->
vertex(1);
216 VecSubtract(vDir1, aaPos[adjacentVrt1], aaPos[vrt]);
217 VecSubtract(vDir2, aaPos[adjacentVrt2], aaPos[vrt]);
224 tmpAngle = acos(
VecDot(vDir1, vDir2));
227 if(tmpAngle < minAngle)
234 minAngle = 180/
PI * minAngle;
244 template <
class TAAPosVRT>
251 template <
class TAAPosVRT>
258 template <
class TAAPosVRT>
265 template <
class TAAPosVRT>
272 template <
class TAAPosVRT>
284 template <
class TElem,
class TAAPosVRT>
288 template <
class TAAPosVRT>
295 template <
class TAAPosVRT>
302 template <
class TAAPosVRT>
309 template <
class TAAPosVRT>
316 template <
class TAAPosVRT>
329 LOG(
"WARNING: autoenabling GRIDOPT_AUTOGENERATE_SIDES in GetNeighbours(Face).\n");
336 number minDihedral = 360.0;
338 Face* vNeighbourFacesToEdge[2];
341 for(
uint eIter = 0; eIter < numElementEdges; ++eIter)
356 for(
size_t i = 0; i < vNeighbourFacesToEdge[0]->
num_vertices(); ++i)
358 if(vNeighbourFacesToEdge[0]->vertex(i) != e->
vertex(0) && vNeighbourFacesToEdge[0]->
vertex(i) != e->
vertex(1))
359 adjacentVrt1 = vNeighbourFacesToEdge[0]->
vertex(i);
362 for(
size_t i = 0; i < vNeighbourFacesToEdge[1]->
num_vertices(); ++i)
364 if(vNeighbourFacesToEdge[1]->vertex(i) != e->
vertex(0) && vNeighbourFacesToEdge[1]->
vertex(i) != e->
vertex(1))
365 adjacentVrt2 = vNeighbourFacesToEdge[1]->
vertex(i);
378 tmpAngle = acos(
VecDot(vNorm1, vNorm2));
379 tmpAngle =
PI - tmpAngle;
382 if(tmpAngle < minDihedral)
384 minDihedral = tmpAngle;
389 minDihedral = 180/
PI * minDihedral;
400 template <
class TElem,
class TAAPosVRT>
404 template <
class TAAPosVRT>
417 LOG(
"WARNING: autoenabling GRIDOPT_AUTOGENERATE_SIDES in GetNeighbours(Face).\n");
422 typedef typename TAAPosVRT::ValueType ValueType;
426 ValueType vNorm1, vNorm2;
427 ValueType vDir1, vDir2;
430 Edge* vNeighbourEdgesToVertex[2];
435 for(
uint vrtIter = 0; vrtIter < numFaceVrts; ++vrtIter)
444 if(vrt != vNeighbourEdgesToVertex[0]->vertex(0))
445 adjacentVrt1 = vNeighbourEdgesToVertex[0]->
vertex(0);
447 adjacentVrt1 = vNeighbourEdgesToVertex[0]->
vertex(1);
449 if(vrt != vNeighbourEdgesToVertex[1]->vertex(0))
450 adjacentVrt2 = vNeighbourEdgesToVertex[1]->
vertex(0);
452 adjacentVrt2 = vNeighbourEdgesToVertex[1]->
vertex(1);
454 VecSubtract(vDir1, aaPos[adjacentVrt1], aaPos[vrt]);
455 VecSubtract(vDir2, aaPos[adjacentVrt2], aaPos[vrt]);
462 tmpAngle = acos(
VecDot(vDir1, vDir2));
465 if(tmpAngle > maxAngle)
472 maxAngle = 180/
PI * maxAngle;
482 template <
class TAAPosVRT>
489 template <
class TAAPosVRT>
496 template <
class TAAPosVRT>
503 template <
class TAAPosVRT>
515 template <
class TElem,
class TAAPosVRT>
519 template <
class TAAPosVRT>
526 template <
class TAAPosVRT>
533 template <
class TAAPosVRT>
540 template <
class TAAPosVRT>
553 LOG(
"WARNING: autoenabling GRIDOPT_AUTOGENERATE_SIDES in GetNeighbours(Face).\n");
562 Face* vNeighbourFacesToEdge[2];
565 for(
uint eIter = 0; eIter < numElementEdges; ++eIter)
579 for(
size_t i = 0; i < vNeighbourFacesToEdge[0]->
num_vertices(); ++i)
581 if(vNeighbourFacesToEdge[0]->vertex(i) != e->
vertex(0) && vNeighbourFacesToEdge[0]->
vertex(i) != e->
vertex(1))
582 adjacentVrt1 = vNeighbourFacesToEdge[0]->
vertex(i);
585 for(
size_t i = 0; i < vNeighbourFacesToEdge[1]->
num_vertices(); ++i)
587 if(vNeighbourFacesToEdge[1]->vertex(i) != e->
vertex(0) && vNeighbourFacesToEdge[1]->
vertex(i) != e->
vertex(1))
588 adjacentVrt2 = vNeighbourFacesToEdge[1]->
vertex(i);
601 tmpAngle = acos(
VecDot(vNorm1, vNorm2));
602 tmpAngle =
PI - tmpAngle;
605 if(tmpAngle > maxDihedral)
607 maxDihedral = tmpAngle;
612 maxDihedral = 180/
PI * maxDihedral;
623 template <
class TElem,
class TAAPosVRT>
627 template <
class TAAPosVRT>
640 LOG(
"WARNING: autoenabling GRIDOPT_AUTOGENERATE_SIDES in GetNeighbours(Face).\n");
645 typedef typename TAAPosVRT::ValueType ValueType;
649 ValueType vNorm1, vNorm2;
650 ValueType vDir1, vDir2;
652 Edge* vNeighbourEdgesToVertex[2];
657 for(
uint vrtIter = 0; vrtIter < numFaceVrts; ++vrtIter)
666 if(vrt != vNeighbourEdgesToVertex[0]->vertex(0))
667 adjacentVrt1 = vNeighbourEdgesToVertex[0]->
vertex(0);
669 adjacentVrt1 = vNeighbourEdgesToVertex[0]->
vertex(1);
671 if(vrt != vNeighbourEdgesToVertex[1]->vertex(0))
672 adjacentVrt2 = vNeighbourEdgesToVertex[1]->
vertex(0);
674 adjacentVrt2 = vNeighbourEdgesToVertex[1]->
vertex(1);
676 VecSubtract(vDir1, aaPos[adjacentVrt1], aaPos[vrt]);
677 VecSubtract(vDir2, aaPos[adjacentVrt2], aaPos[vrt]);
684 tmpAngle = acos(
VecDot(vDir1, vDir2));
687 tmpAngle = 180/
PI * tmpAngle;
689 vAnglesOut.push_back(tmpAngle);
694 template <
class TAAPosVRT>
707 LOG(
"WARNING: autoenabling GRIDOPT_AUTOGENERATE_SIDES in GetNeighbours(Face).\n");
715 Face* vNeighbourFacesToEdge[2];
718 for(
uint eIter = 0; eIter < numElementEdges; ++eIter)
732 for(
size_t i = 0; i < vNeighbourFacesToEdge[0]->
num_vertices(); ++i)
734 if(vNeighbourFacesToEdge[0]->vertex(i) != e->
vertex(0) && vNeighbourFacesToEdge[0]->
vertex(i) != e->
vertex(1))
735 adjacentVrt1 = vNeighbourFacesToEdge[0]->
vertex(i);
738 for(
size_t i = 0; i < vNeighbourFacesToEdge[1]->
num_vertices(); ++i)
740 if(vNeighbourFacesToEdge[1]->vertex(i) != e->
vertex(0) && vNeighbourFacesToEdge[1]->
vertex(i) != e->
vertex(1))
741 adjacentVrt2 = vNeighbourFacesToEdge[1]->
vertex(i);
754 tmpAngle = acos(
VecDot(vNorm1, vNorm2));
755 tmpAngle =
PI - tmpAngle;
758 tmpAngle = 180.0/
PI * tmpAngle;
760 vAnglesOut.push_back(tmpAngle);
767 template <
class TIterator,
class TAAPosVRT>
774 if(elementsBegin == elementsEnd)
783 for(; elementsBegin != elementsEnd; ++elementsBegin)
788 if(curSmallestMinAngle < smallestMinAngle)
790 elementWithSmallestMinAngle = curElement;
791 smallestMinAngle = curSmallestMinAngle;
795 return elementWithSmallestMinAngle;
801 template <
class TIterator,
class TAAPosVRT>
808 if(elementsBegin == elementsEnd)
817 for(; elementsBegin != elementsEnd; ++elementsBegin)
822 if(curLargestMaxAngle > largestMaxAngle)
824 elementWithLargestMaxAngle = curElement;
825 largestMaxAngle = curLargestMaxAngle;
829 return elementWithLargestMaxAngle;
Base-class for edges.
Definition: grid_base_objects.h:397
virtual Vertex * vertex(size_t index) const
Definition: grid_base_objects.h:366
Faces are 2-dimensional objects.
Definition: grid_base_objects.h:510
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
EdgeContainer::iterator AssociatedEdgeIterator
used to iterate over associated edges of vertices, faces and volumes
Definition: grid.h:249
void end_marking()
ends a marking sequence. Call this method when you're done with marking.
Definition: grid.cpp:1285
AssociatedEdgeIterator associated_edges_begin(Vertex *vrt)
DO NOT INVOKE! Subject to change.
Definition: grid.cpp:882
bool option_is_enabled(uint option) const
see set_options for a description of valid parameters.
Definition: grid.cpp:721
bool is_marked(GridObject *obj) const
returns true if the object is marked, false if not.
Definition: grid_impl.hpp:843
AssociatedEdgeIterator associated_edges_end(Vertex *vrt)
DO NOT INVOKE! Subject to change.
Definition: grid.cpp:892
Edge * get_edge(Vertex *v1, Vertex *v2)
returns the edge between v1 and v2, if it exists. Returns NULL if not.
Definition: grid.cpp:1069
void mark(GridObject *obj)
marks the object. Calls are only valid between calls to Grid::begin_marking and Grid::end_marking.
Definition: grid_impl.hpp:773
void begin_marking()
begin marking.
Definition: grid.cpp:1262
FaceContainer::iterator AssociatedFaceIterator
used to iterate over associated faces of vertices, edges and volumes
Definition: grid.h:251
void enable_options(uint options)
see set_options for a description of valid parameters.
Definition: grid.cpp:711
A volume element with 6 quadrilateral sides.
Definition: grid_objects_3d.h:227
A volume element with 2 triangle and 3 quadrilateral sides.
Definition: grid_objects_3d.h:360
A volume element with 4 triangle and 1 quadrilateral sides.
Definition: grid_objects_3d.h:493
the most simple volume-element.
Definition: grid_objects_3d.h:91
Base-class for all vertex-types.
Definition: grid_base_objects.h:231
Volumes are 3-dimensional objects.
Definition: grid_base_objects.h:754
virtual uint num_edges() const
Definition: grid_base_objects.h:782
virtual Vertex * vertex(size_t index) const
Definition: grid_base_objects.h:727
virtual size_t num_vertices() const
Definition: grid_base_objects.h:729
bool FaceContains(Face *f, EdgeVertices *ev)
returns true if the given face contains the two given vertices
Definition: grid_util.cpp:561
UG_API void CollectAssociated(std::vector< Vertex * > &vVertexOut, Grid &grid, GridObject *obj, bool clearContainer=true)
Definition: grid_util_impl.hpp:169
@ GRIDOPT_AUTOGENERATE_SIDES
sides are automatically created
Definition: grid_constants.h:102
#define UG_ASSERT(expr, msg)
Definition: assert.h:70
#define LOG(msg)
Definition: common.h:60
#define UG_API
Definition: ug_config.h:65
unsigned int uint
Definition: types.h:114
double number
Definition: types.h:124
void VecNormalize(vector_t &vOut, const vector_t &v)
scales a vector_t to unit length
Definition: math_vector_functions_common_impl.hpp:501
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
void VecCross(vector_t &vOut, const vector_t &v1, const vector_t &v2)
calculates the cross product of two Vectors of dimension 3. It makes no sense to use VecCross for vec...
Definition: math_vector_functions_common_impl.hpp:437
vector_t::value_type VecDot(const vector_t &v1, const vector_t &v2)
returns the dot-product of two vector_ts
Definition: math_vector_functions_common_impl.hpp:385
Definition: smart_pointer.h:814
void CalculateAngles(vector< number > &vAnglesOut, Grid &grid, Volume *v, TAAPosVRT &aaPos)
Volume.
Definition: element_angles.h:695
UG_API void CollectAssociatedSides(Face *sidesOut[2], Grid &grid, Volume *v, Edge *e)
Collects all faces (= 2) which exist in the given volume and which share the given edge.
Definition: element_angles.h:107
const number PI
Definition: math_constants.h:45
TIterator::value_type FindElementWithSmallestMinAngle(Grid &grid, TIterator elementsBegin, TIterator elementsEnd, TAAPosVRT &aaPos)
Definition: element_angles.h:769
number CalculateMinDihedral(Grid &grid, Volume *v, TAAPosVRT &aaPos)
Volume.
Definition: element_angles.h:317
number CalculateMaxAngle(Grid &grid, Volume *vol, TAAPosVRT &aaPos)
Volume.
Definition: element_angles.h:504
number CalculateMaxDihedral(Grid &grid, Volume *v, TAAPosVRT &aaPos)
Volume.
Definition: element_angles.h:541
TIterator::value_type FindElementWithLargestMaxAngle(Grid &grid, TIterator elementsBegin, TIterator elementsEnd, TAAPosVRT &aaPos)
Definition: element_angles.h:803
number CalculateMinAngle(Grid &grid, Volume *vol, TAAPosVRT &aaPos)
Volume.
Definition: element_angles.h:273
T value_type
Definition: sparsematrix_interface.h:2