OGS
QuadRule.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 "QuadRule.h"
5
7#include "MeshLib/Node.h"
8
9namespace MeshLib
10{
11double QuadRule::computeVolume(Node const* const* element_nodes)
12{
14 *element_nodes[0], *element_nodes[1], *element_nodes[2]) +
16 *element_nodes[2], *element_nodes[3], *element_nodes[0]);
17}
18
19bool QuadRule::isPntInElement(Node const* const* nodes,
20 MathLib::Point3d const& pnt,
21 double eps)
22{
23 return (
24 MathLib::isPointInTriangle(pnt, *nodes[0], *nodes[1], *nodes[2], eps) ||
25 MathLib::isPointInTriangle(pnt, *nodes[0], *nodes[2], *nodes[3], eps));
26}
27
29{
30 ElementErrorCode error_code;
32 Node const* const* element_nodes = e->getNodes();
34 (!MathLib::isCoplanar(*element_nodes[0],
35 *element_nodes[1],
36 *element_nodes[2],
37 *element_nodes[3]));
38 // for collapsed quads (i.e. reduced to a line) this test might result
39 // "false" as all four points are actually located on a line.
40 if (!error_code[ElementErrorFlag::ZeroVolume])
41 {
42 error_code[ElementErrorFlag::NonConvex] =
43 (!(MathLib::dividedByPlane(*element_nodes[0],
44 *element_nodes[2],
45 *element_nodes[1],
46 *element_nodes[3]) &&
47 MathLib::dividedByPlane(*element_nodes[1],
48 *element_nodes[3],
49 *element_nodes[0],
50 *element_nodes[2])));
51 }
53 return error_code;
54}
55
56} // end namespace MeshLib
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:28
static bool isPntInElement(Node const *const *nodes, MathLib::Point3d const &pnt, double eps)
Definition QuadRule.cpp:19
static double computeVolume(Node const *const *element_nodes)
Calculates the area of a quad with straight edges.
Definition QuadRule.cpp:11
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:126