OGS
CellRule.cpp
Go to the documentation of this file.
1
11#include "CellRule.h"
12
13#include "Element.h"
14#include "FaceRule.h"
15#include "MeshLib/Node.h"
16
17namespace MeshLib
18{
20{
21 auto const cc = getCenterOfGravity(e).asEigenVector3d();
22 const unsigned nFaces(e.getNumberOfFaces());
23 for (unsigned j = 0; j < nFaces; ++j)
24 {
25 MeshLib::Element const* const face(e.getFace(j));
26 // Node 1 is checked below because that way all nodes are used for the
27 // test at some point, while for node 0 at least one node in every
28 // element type would be used for checking twice and one wouldn't be
29 // checked at all. (based on the definition of the _face_nodes variable)
30 auto const& x = face->getNode(1)->asEigenVector3d();
31 Eigen::Vector3d const cx = x - cc;
32 const double s = FaceRule::getSurfaceNormal(*face).dot(cx);
33 delete face;
34 if (s >= 0)
35 {
36 return false;
37 }
38 }
39 return true;
40}
41
42} // namespace MeshLib
Definition of the Element class.
Definition of the Node class.
Eigen::Vector3d const & asEigenVector3d() const
Definition: Point3d.h:67
static bool testElementNodeOrder(Element const &e)
Definition: CellRule.cpp:19
virtual unsigned getNumberOfFaces() const =0
Get the number of faces for this element.
virtual const Element * getFace(unsigned i) const =0
Returns the i-th face of the element.
virtual const Node * getNode(unsigned idx) const =0
static Eigen::Vector3d getSurfaceNormal(Element const &e)
Returns the surface normal of a 2D element.
Definition: FaceRule.cpp:38
static const double s
MathLib::Point3d getCenterOfGravity(Element const &element)
Calculates the center of gravity for the mesh element.
Definition: Element.cpp:124