OGS
FaceRule.cpp
Go to the documentation of this file.
1 
11 #include "FaceRule.h"
12 
13 #include "Element.h"
14 #include "MathLib/MathTools.h"
15 #include "MeshLib/Node.h"
16 
17 namespace MeshLib
18 {
20 {
21  return getSurfaceNormal(e)[2] < 0;
22 }
23 
24 Eigen::Vector3d FaceRule::getFirstSurfaceVector(Element const& e)
25 {
26  auto const a = Eigen::Map<Eigen::Vector3d const>(e.getNode(0)->getCoords());
27  auto const b = Eigen::Map<Eigen::Vector3d const>(e.getNode(1)->getCoords());
28  Eigen::Vector3d const v = a - b;
29  return v;
30 }
31 
32 Eigen::Vector3d FaceRule::getSecondSurfaceVector(Element const& e)
33 {
34  auto const a = Eigen::Map<Eigen::Vector3d const>(e.getNode(1)->getCoords());
35  auto const b = Eigen::Map<Eigen::Vector3d const>(e.getNode(2)->getCoords());
36  Eigen::Vector3d const v = b - a;
37  return v;
38 }
39 
40 Eigen::Vector3d FaceRule::getSurfaceNormal(Element const& e)
41 {
42  Eigen::Vector3d const u = getFirstSurfaceVector(e);
43  Eigen::Vector3d const v = getSecondSurfaceVector(e);
44  return u.cross(v);
45 }
46 
47 } // namespace MeshLib
Definition of the Element class.
Definition of the Node class.
const T * getCoords() const
Definition: TemplatePoint.h:75
virtual const Node * getNode(unsigned idx) const =0
static bool testElementNodeOrder(Element const &e)
Definition: FaceRule.cpp:19
static Eigen::Vector3d getSecondSurfaceVector(Element const &e)
Definition: FaceRule.cpp:32
static Eigen::Vector3d getFirstSurfaceVector(Element const &e)
Definition: FaceRule.cpp:24
static Eigen::Vector3d getSurfaceNormal(Element const &e)
Returns the surface normal of a 2D element.
Definition: FaceRule.cpp:40