OGS
HexRule.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#include "HexRule.h"
5
7#include "MeshLib/Node.h"
8#include "Quad.h"
9
10namespace MeshLib
11{
12double HexRule::computeVolume(Node const* const* element_nodes)
13{
14 return MathLib::calcTetrahedronVolume(*element_nodes[4],
15 *element_nodes[7],
16 *element_nodes[5],
17 *element_nodes[0]) +
18 MathLib::calcTetrahedronVolume(*element_nodes[5],
19 *element_nodes[3],
20 *element_nodes[1],
21 *element_nodes[0]) +
22 MathLib::calcTetrahedronVolume(*element_nodes[5],
23 *element_nodes[7],
24 *element_nodes[3],
25 *element_nodes[0]) +
26 MathLib::calcTetrahedronVolume(*element_nodes[5],
27 *element_nodes[7],
28 *element_nodes[6],
29 *element_nodes[2]) +
30 MathLib::calcTetrahedronVolume(*element_nodes[1],
31 *element_nodes[3],
32 *element_nodes[5],
33 *element_nodes[2]) +
34 MathLib::calcTetrahedronVolume(*element_nodes[3],
35 *element_nodes[7],
36 *element_nodes[5],
37 *element_nodes[2]);
38}
39
40bool HexRule::isPntInElement(Node const* const* nodes,
41 MathLib::Point3d const& pnt,
42 double eps)
43{
45 pnt, *nodes[4], *nodes[7], *nodes[5], *nodes[0], eps) ||
47 pnt, *nodes[5], *nodes[3], *nodes[1], *nodes[0], eps) ||
49 pnt, *nodes[5], *nodes[7], *nodes[3], *nodes[0], eps) ||
51 pnt, *nodes[5], *nodes[7], *nodes[6], *nodes[2], eps) ||
53 pnt, *nodes[1], *nodes[3], *nodes[5], *nodes[2], eps) ||
55 pnt, *nodes[3], *nodes[7], *nodes[5], *nodes[2], eps));
56}
57
59{
60 ElementErrorCode error_code;
62
63 for (unsigned i = 0; i < 6; ++i)
64 {
65 if (error_code.all())
66 {
67 break;
68 }
69
70 const MeshLib::Element* quad(e->getFace(i));
71 error_code |= quad->validate();
72 delete quad;
73 }
75 return error_code;
76}
77
78} // end namespace MeshLib
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:58
static bool isPntInElement(Node const *const *nodes, MathLib::Point3d const &pnt, double eps)
Definition HexRule.cpp:40
static double computeVolume(Node const *const *element_nodes)
Definition HexRule.cpp:12
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:126