OGS
CellRule.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 "CellRule.h"
5
6#include "Element.h"
7#include "FaceRule.h"
8
9namespace MeshLib
10{
12{
13 auto const cc = getCenterOfGravity(e).asEigenVector3d();
14 const unsigned nFaces(e.getNumberOfFaces());
15 for (unsigned j = 0; j < nFaces; ++j)
16 {
17 MeshLib::Element const* const face(e.getFace(j));
18 // Node 1 is checked below because that way all nodes are used for the
19 // test at some point, while for node 0 at least one node in every
20 // element type would be used for checking twice and one wouldn't be
21 // checked at all. (based on the definition of the _face_nodes variable)
22 auto const& x = face->getNode(1)->asEigenVector3d();
23 Eigen::Vector3d const cx = x - cc;
24 const double s = FaceRule::getSurfaceNormal(*face).dot(cx);
25 delete face;
26 if (s >= 0)
27 {
28 return false;
29 }
30 }
31 return true;
32}
33
34} // namespace MeshLib
Eigen::Vector3d const & asEigenVector3d() const
Definition Point3d.h:55
static bool testElementNodeOrder(Element const &e)
Definition CellRule.cpp:11
virtual unsigned getNumberOfFaces() const =0
Get the number of faces for this element.
virtual const Element * getFace(unsigned i) const =0
Returns the i-th face of the element.
virtual const Node * getNode(unsigned idx) const =0
static Eigen::Vector3d getSurfaceNormal(Element const &e)
Returns the surface normal of a 2D element.
Definition FaceRule.cpp:33
MathLib::Point3d getCenterOfGravity(Element const &element)
Calculates the center of gravity for the mesh element.
Definition Element.cpp:131