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
16namespace MeshLib
17{
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}
40
41} // namespace MeshLib
Definition of the Element class.
Eigen::Vector3d const & asEigenVector3d() const
Definition Point3d.h:64
static bool testElementNodeOrder(Element const &e)
Definition CellRule.cpp:18
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:40
MathLib::Point3d getCenterOfGravity(Element const &element)
Calculates the center of gravity for the mesh element.
Definition Element.cpp:124