OGS
PrismRule.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 "PrismRule.h"
5
7#include "MeshLib/Node.h"
8#include "Quad.h"
9
10namespace MeshLib
11{
12double PrismRule::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[3]) +
18 MathLib::calcTetrahedronVolume(*element_nodes[1],
19 *element_nodes[4],
20 *element_nodes[2],
21 *element_nodes[3]) +
22 MathLib::calcTetrahedronVolume(*element_nodes[2],
23 *element_nodes[4],
24 *element_nodes[5],
25 *element_nodes[3]);
26}
27
28bool PrismRule::isPntInElement(Node const* const* nodes,
29 MathLib::Point3d const& pnt,
30 double eps)
31{
33 pnt, *nodes[0], *nodes[1], *nodes[2], *nodes[3], eps) ||
35 pnt, *nodes[1], *nodes[4], *nodes[2], *nodes[3], eps) ||
37 pnt, *nodes[2], *nodes[4], *nodes[5], *nodes[3], eps));
38}
39
41{
42 ElementErrorCode error_code;
44
45 for (unsigned i = 1; i < 4; ++i)
46 {
47 const auto* quad(dynamic_cast<const MeshLib::Quad*>(e->getFace(i)));
48 if (quad)
49 {
50 error_code |= quad->validate();
51 }
52 else
53 {
55 }
56 delete quad;
57 }
59 return error_code;
60}
61
62} // 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)
Definition PrismRule.cpp:40
static bool isPntInElement(Node const *const *nodes, MathLib::Point3d const &pnt, double eps)
Definition PrismRule.cpp:28
static double computeVolume(Node const *const *element_nodes)
Definition PrismRule.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
TemplateElement< MeshLib::QuadRule4 > Quad
Definition Quad.h:17