OGS
HexRule.cpp
Go to the documentation of this file.
1
10#include "HexRule.h"
11
13#include "MeshLib/Node.h"
14#include "Quad.h"
15
16namespace MeshLib
17{
18double HexRule::computeVolume(Node const* const* element_nodes)
19{
20 return MathLib::calcTetrahedronVolume(*element_nodes[4],
21 *element_nodes[7],
22 *element_nodes[5],
23 *element_nodes[0]) +
24 MathLib::calcTetrahedronVolume(*element_nodes[5],
25 *element_nodes[3],
26 *element_nodes[1],
27 *element_nodes[0]) +
28 MathLib::calcTetrahedronVolume(*element_nodes[5],
29 *element_nodes[7],
30 *element_nodes[3],
31 *element_nodes[0]) +
32 MathLib::calcTetrahedronVolume(*element_nodes[5],
33 *element_nodes[7],
34 *element_nodes[6],
35 *element_nodes[2]) +
36 MathLib::calcTetrahedronVolume(*element_nodes[1],
37 *element_nodes[3],
38 *element_nodes[5],
39 *element_nodes[2]) +
40 MathLib::calcTetrahedronVolume(*element_nodes[3],
41 *element_nodes[7],
42 *element_nodes[5],
43 *element_nodes[2]);
44}
45
46bool HexRule::isPntInElement(Node const* const* nodes,
47 MathLib::Point3d const& pnt,
48 double eps)
49{
51 pnt, *nodes[4], *nodes[7], *nodes[5], *nodes[0], eps) ||
53 pnt, *nodes[5], *nodes[3], *nodes[1], *nodes[0], eps) ||
55 pnt, *nodes[5], *nodes[7], *nodes[3], *nodes[0], eps) ||
57 pnt, *nodes[5], *nodes[7], *nodes[6], *nodes[2], eps) ||
59 pnt, *nodes[1], *nodes[3], *nodes[5], *nodes[2], eps) ||
61 pnt, *nodes[3], *nodes[7], *nodes[5], *nodes[2], eps));
62}
63
65{
66 ElementErrorCode error_code;
68
69 for (unsigned i = 0; i < 6; ++i)
70 {
71 if (error_code.all())
72 {
73 break;
74 }
75
76 const MeshLib::Element* quad(e->getFace(i));
77 error_code |= quad->validate();
78 delete quad;
79 }
81 return error_code;
82}
83
84} // end namespace MeshLib
Definition of the Node class.
Definition of the Quad class.
Collects error flags for mesh elements.
virtual ElementErrorCode validate() const =0
virtual const Element * getFace(unsigned i) const =0
Returns the i-th face of the element.
virtual bool testElementNodeOrder() const =0
static ElementErrorCode validate(const Element *e)
Definition HexRule.cpp:64
static bool isPntInElement(Node const *const *nodes, MathLib::Point3d const &pnt, double eps)
Definition HexRule.cpp:46
static double computeVolume(Node const *const *element_nodes)
Definition HexRule.cpp:18
double calcTetrahedronVolume(MathLib::Point3d const &a, MathLib::Point3d const &b, MathLib::Point3d const &c, MathLib::Point3d const &d)
bool isPointInTetrahedron(MathLib::Point3d const &p, MathLib::Point3d const &a, MathLib::Point3d const &b, MathLib::Point3d const &c, MathLib::Point3d const &d, double eps)
bool hasZeroVolume(MeshLib::Element const &element)
Returns true if the element has zero length/area/volume.
Definition Element.cpp:119