OGS
QuadRule.cpp
Go to the documentation of this file.
1
10#include "QuadRule.h"
11
13#include "MeshLib/Node.h"
14
15namespace MeshLib
16{
17double QuadRule::computeVolume(Node const* const* element_nodes)
18{
20 *element_nodes[0], *element_nodes[1], *element_nodes[2]) +
22 *element_nodes[2], *element_nodes[3], *element_nodes[0]);
23}
24
25bool QuadRule::isPntInElement(Node const* const* nodes,
26 MathLib::Point3d const& pnt,
27 double eps)
28{
29 return (
30 MathLib::isPointInTriangle(pnt, *nodes[0], *nodes[1], *nodes[2], eps) ||
31 MathLib::isPointInTriangle(pnt, *nodes[0], *nodes[2], *nodes[3], eps));
32}
33
35{
36 ElementErrorCode error_code;
38 Node const* const* element_nodes = e->getNodes();
40 (!MathLib::isCoplanar(*element_nodes[0],
41 *element_nodes[1],
42 *element_nodes[2],
43 *element_nodes[3]));
44 // for collapsed quads (i.e. reduced to a line) this test might result
45 // "false" as all four points are actually located on a line.
46 if (!error_code[ElementErrorFlag::ZeroVolume])
47 {
48 error_code[ElementErrorFlag::NonConvex] =
49 (!(MathLib::dividedByPlane(*element_nodes[0],
50 *element_nodes[2],
51 *element_nodes[1],
52 *element_nodes[3]) &&
53 MathLib::dividedByPlane(*element_nodes[1],
54 *element_nodes[3],
55 *element_nodes[0],
56 *element_nodes[2])));
57 }
59 return error_code;
60}
61
62} // end namespace MeshLib
Definition of the Node class.
Collects error flags for mesh elements.
virtual bool testElementNodeOrder() const =0
virtual Node *const * getNodes() const =0
Get array of element nodes.
static ElementErrorCode validate(const Element *e)
Definition QuadRule.cpp:34
static bool isPntInElement(Node const *const *nodes, MathLib::Point3d const &pnt, double eps)
Definition QuadRule.cpp:25
static double computeVolume(Node const *const *element_nodes)
Calculates the area of a quad with straight edges.
Definition QuadRule.cpp:17
double calcTriangleArea(MathLib::Point3d const &a, MathLib::Point3d const &b, MathLib::Point3d const &c)
bool isCoplanar(const MathLib::Point3d &a, const MathLib::Point3d &b, const MathLib::Point3d &c, const MathLib::Point3d &d)
Checks if the four given points are located on a plane.
bool dividedByPlane(const MathLib::Point3d &a, const MathLib::Point3d &b, const MathLib::Point3d &c, const MathLib::Point3d &d)
bool isPointInTriangle(MathLib::Point3d const &p, MathLib::Point3d const &a, MathLib::Point3d const &b, MathLib::Point3d const &c, double eps_pnt_out_of_plane, double eps_pnt_out_of_tri, MathLib::TriangleTest algorithm)
bool hasZeroVolume(MeshLib::Element const &element)
Returns true if the element has zero length/area/volume.
Definition Element.cpp:119