OGS
MeshLib::CellRule Class Reference

Detailed Description

Definition at line 18 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. More...
 

Member Function Documentation

◆ 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 19 of file CellRule.cpp.

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

References MeshLib::getCenterOfGravity(), MathLib::TemplatePoint< T, DIM >::getCoords(), 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 22 of file CellRule.h.


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