OGS
FaceRule.h
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#pragma once
5
6#include "Element.h"
7
8namespace MeshLib
9{
10
12{
13public:
15 static const unsigned dimension = 2u;
16
18 static const Element* getFace(const Element* e, unsigned i) { return e->getEdge(i); }
19
21 static const unsigned n_faces = 0;
22
27 static bool testElementNodeOrder(Element const& e);
28
30 static Eigen::Vector3d getFirstSurfaceVector(Element const& e);
31
33 static Eigen::Vector3d getSecondSurfaceVector(Element const& e);
34
36 static Eigen::Vector3d getSurfaceNormal(Element const& e);
37
38protected:
40 template <typename ElementRule>
41 static unsigned identifyFace(Node const* const* element_nodes,
42 Node const* nodes[ElementRule::dimension])
43 {
44 for (unsigned i = 0; i < ElementRule::n_edges; i++)
45 {
46 unsigned flag(0);
47 constexpr std::size_t n = sizeof(ElementRule::edge_nodes[0]) /
48 sizeof(ElementRule::edge_nodes[0][0]);
49 for (unsigned j = 0; j < n; j++)
50 {
51 for (unsigned k = 0; k < ElementRule::dimension; k++)
52 {
53 if (element_nodes[ElementRule::edge_nodes[i][j]] ==
54 nodes[k])
55 {
56 flag++;
57 }
58 }
59 }
60 if (flag == ElementRule::dimension)
61 {
62 return i;
63 }
64 }
65 return std::numeric_limits<unsigned>::max();
66 }
67
68}; /* class */
69
70} // namespace MeshLib
virtual const Element * getEdge(unsigned i) const =0
Returns the i-th edge of the element.
static const unsigned dimension
Constant: Dimension of this mesh element.
Definition FaceRule.h:15
static bool testElementNodeOrder(Element const &e)
Definition FaceRule.cpp:14
static Eigen::Vector3d getSecondSurfaceVector(Element const &e)
Definition FaceRule.cpp:26
static const Element * getFace(const Element *e, unsigned i)
Returns the face i of the element.
Definition FaceRule.h:18
static const unsigned n_faces
Constant: The number of faces.
Definition FaceRule.h:21
static Eigen::Vector3d getFirstSurfaceVector(Element const &e)
Definition FaceRule.cpp:19
static unsigned identifyFace(Node const *const *element_nodes, Node const *nodes[ElementRule::dimension])
Returns the ID of an edge given an array of nodes.
Definition FaceRule.h:41
static Eigen::Vector3d getSurfaceNormal(Element const &e)
Returns the surface normal of a 2D element.
Definition FaceRule.cpp:33