OGS
MeshLib::CellRule Class Reference

Detailed Description

Definition at line 20 of file CellRule.h.

#include <CellRule.h>

Inheritance diagram for MeshLib::CellRule:
[legend]

Static Public Member Functions

static bool testElementNodeOrder (Element const &e)
 

Static Public Attributes

static const unsigned dimension = 3u
 Constant: Dimension of this mesh element.
 

Static Protected Member Functions

template<typename ElementRule >
static unsigned identifyFace (Node const *const *element_nodes, Node const *nodes[ElementRule::dimension])
 Returns the ID of a face given an array of nodes.
 

Member Function Documentation

◆ identifyFace()

template<typename ElementRule >
static unsigned MeshLib::CellRule::identifyFace ( Node const *const * element_nodes,
Node const * nodes[ElementRule::dimension] )
inlinestaticprotected

Returns the ID of a face given an array of nodes.

Definition at line 39 of file CellRule.h.

41 {
42 for (unsigned i = 0; i < ElementRule::n_faces; i++)
43 {
44 unsigned flag(0);
45 constexpr std::size_t n = sizeof(ElementRule::face_nodes[0]) /
46 sizeof(ElementRule::face_nodes[0][0]);
47 for (unsigned j = 0; j < n; j++)
48 {
49 for (unsigned k = 0; k < ElementRule::dimension; k++)
50 {
51 if (ElementRule::face_nodes[i][j] != 99 &&
52 element_nodes[ElementRule::face_nodes[i][j]] ==
53 nodes[k])
54 {
55 flag++;
56 }
57 }
58 }
59 if (flag == ElementRule::dimension)
60 {
61 return i;
62 }
63 }
64 return std::numeric_limits<unsigned>::max();
65 }

Referenced by MeshLib::HexRule20::identifyFace(), MeshLib::HexRule8::identifyFace(), MeshLib::PrismRule15::identifyFace(), MeshLib::PrismRule6::identifyFace(), MeshLib::PyramidRule13::identifyFace(), MeshLib::PyramidRule5::identifyFace(), MeshLib::TetRule10::identifyFace(), and MeshLib::TetRule4::identifyFace().

◆ testElementNodeOrder()

bool MeshLib::CellRule::testElementNodeOrder ( Element const & e)
static

Checks if the node order of an element is correct by testing surface normals. For 3D elements true is returned if the normals of all faces points away from the centre of the element. Note: This method might give wrong results if something else is wrong with the element (non-planar faces, non-convex geometry, possibly zero volume) which causes the calculated center of gravity to lie outside of the actual element

Definition at line 18 of file CellRule.cpp.

19{
20 auto const cc = getCenterOfGravity(e).asEigenVector3d();
21 const unsigned nFaces(e.getNumberOfFaces());
22 for (unsigned j = 0; j < nFaces; ++j)
23 {
24 MeshLib::Element const* const face(e.getFace(j));
25 // Node 1 is checked below because that way all nodes are used for the
26 // test at some point, while for node 0 at least one node in every
27 // element type would be used for checking twice and one wouldn't be
28 // checked at all. (based on the definition of the _face_nodes variable)
29 auto const& x = face->getNode(1)->asEigenVector3d();
30 Eigen::Vector3d const cx = x - cc;
31 const double s = FaceRule::getSurfaceNormal(*face).dot(cx);
32 delete face;
33 if (s >= 0)
34 {
35 return false;
36 }
37 }
38 return true;
39}
Eigen::Vector3d const & asEigenVector3d() const
Definition Point3d.h:64
static Eigen::Vector3d getSurfaceNormal(Element const &e)
Returns the surface normal of a 2D element.
Definition FaceRule.cpp:40
MathLib::Point3d getCenterOfGravity(Element const &element)
Calculates the center of gravity for the mesh element.
Definition Element.cpp:124

References MathLib::Point3d::asEigenVector3d(), MeshLib::getCenterOfGravity(), MeshLib::Element::getFace(), MeshLib::Element::getNode(), MeshLib::Element::getNumberOfFaces(), and MeshLib::FaceRule::getSurfaceNormal().

Member Data Documentation

◆ dimension

const unsigned MeshLib::CellRule::dimension = 3u
static

Constant: Dimension of this mesh element.

Definition at line 24 of file CellRule.h.


The documentation for this class was generated from the following files: