OGS
PyramidRule.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 "PyramidRule.h"
5
7#include "MeshLib/Node.h"
8#include "Quad.h"
9
10namespace MeshLib
11{
12double PyramidRule::computeVolume(Node const* const* element_nodes)
13{
14 return MathLib::calcTetrahedronVolume(*element_nodes[0],
15 *element_nodes[1],
16 *element_nodes[2],
17 *element_nodes[4]) +
18 MathLib::calcTetrahedronVolume(*element_nodes[2],
19 *element_nodes[3],
20 *element_nodes[0],
21 *element_nodes[4]);
22}
23
24bool PyramidRule::isPntInElement(Node const* const* nodes,
25 MathLib::Point3d const& pnt,
26 double eps)
27{
29 pnt, *nodes[0], *nodes[1], *nodes[2], *nodes[4], eps) ||
31 pnt, *nodes[0], *nodes[2], *nodes[3], *nodes[4], eps));
32}
33
35{
36 ElementErrorCode error_code;
38
39 std::unique_ptr<MeshLib::Quad const> const base{
40 dynamic_cast<MeshLib::Quad const*>(e->getFace(4))};
41 if (base)
42 {
43 error_code |= base->validate();
45 }
46 else
47 {
49 }
50
51 return error_code;
52}
53
54} // end namespace MeshLib
Collects error flags for mesh elements.
void set(ElementErrorFlag e)
Set a specific flag.
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)
static double computeVolume(Node const *const *element_nodes)
static bool isPntInElement(Node const *const *nodes, MathLib::Point3d const &pnt, double eps)
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
TemplateElement< MeshLib::QuadRule4 > Quad
Definition Quad.h:17