34 if (e ==
this || e ==
nullptr || e->
getDimension() != dim)
36 return std::optional<unsigned>();
41 return std::optional<unsigned>();
44 Node const* face_nodes[3];
49 for (
unsigned i(0); i < nNodes; i++)
51 for (
unsigned j(0); j < eNodes; j++)
60 auto const this_face_id = this->
identifyFace(face_nodes);
61 if (this_face_id == std::numeric_limits<unsigned>::max())
64 "Could not find face of {} for the face nodes [{}, "
66 *
this, *face_nodes[0], *face_nodes[1],
70 auto const neighbors_face_id = e->
identifyFace(face_nodes);
71 if (neighbors_face_id ==
72 std::numeric_limits<unsigned>::max())
75 "Could not find face of the neighbour {} for the "
76 "face nodes [{}, {}, {}].\n"
77 "For the {} the face id {} was identified.",
78 *e, *face_nodes[0], *face_nodes[1], *face_nodes[2],
81 return neighbors_face_id;
87 return std::optional<unsigned>();
94 {
return e ==
nullptr; });
99 os <<
"element #" << e.
_id <<
" @ " << &e <<
" with "
105 <<
" with " << nnodes <<
" nodes: {\n";
106 for (
unsigned n = 0; n < nnodes; ++n)
108 os <<
" " << *
nodes[n] <<
" @ " <<
nodes[n] <<
'\n';
116 for (
unsigned i = 0; i < nNeighbors; i++)
128 return element.
getContent() < std::numeric_limits<double>::epsilon();
135 for (
unsigned i = 0; i < nNodes; ++i)
146 double min = std::numeric_limits<double>::max();
150 for (
unsigned i = 0; i < nnodes; i++)
152 for (
unsigned j = i + 1; j < nnodes; j++)
156 min = std::min(dist, min);
157 max = std::max(dist, max);
165 double min = std::numeric_limits<double>::max();
168 for (
unsigned i = 0; i < nEdges; i++)
172 min = std::min(dist, min);
173 max = std::max(dist, max);
183 std::numeric_limits<double>::epsilon())
208 WARN(
"isPointInElementXY: element type '{:s}' is not supported.",
216 for (
unsigned i(0); i < nNodes; i++)
218 if (node == element.
getNode(i))
223 return std::numeric_limits<unsigned>::max();
231 ERR(
"Error in MeshLib::getNodeIndex() - Index does not "
233 return std::numeric_limits<std::size_t>::max();
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
void WARN(fmt::format_string< Args... > fmt, Args &&... args)
std::size_t getID() const
Eigen::Vector3d const & asEigenVector3d() const
virtual MeshElemType getGeomType() const =0
void setNeighbor(Element *neighbor, unsigned const face_id)
virtual ~Element()
Destructor.
virtual unsigned getNumberOfNodes() const =0
virtual double getContent() const =0
Returns the length, area or volume of a 1D, 2D or 3D element.
virtual unsigned getNumberOfBaseNodes() const =0
virtual bool isBoundaryElement() const
virtual const Node * getNode(unsigned idx) const =0
virtual unsigned getNumberOfNeighbors() const =0
Get the number of neighbors for this element.
virtual unsigned getNumberOfEdges() const =0
Get the number of edges for this element.
virtual constexpr unsigned getDimension() const =0
Get dimension of the mesh element.
std::optional< unsigned > addNeighbor(Element *e)
Tries to add an element e as neighbour to this element. If the elements really are neighbours,...
constexpr std::span< Node *const > nodes() const
Span of element's nodes, their pointers actually.
virtual Node *const * getNodes() const =0
Get array of element nodes.
virtual const Element * getNeighbor(unsigned i) const =0
Get the specified neighbor.
virtual Node * getEdgeNode(unsigned edge_id, unsigned node_id) const =0
Return a specific edge node.
virtual unsigned identifyFace(Node const *nodes[3]) const =0
Returns the ID of a face given an array of nodes.
double sqrDist2d(MathLib::Point3d const &p0, MathLib::Point3d const &p1)
double sqrDist(MathLib::Point3d const &p0, MathLib::Point3d const &p1)
bool isPointInTriangleXY(MathLib::Point3d const &p, MathLib::Point3d const &a, MathLib::Point3d const &b, MathLib::Point3d const &c)
std::pair< double, double > computeSqrNodeDistanceRange(MeshLib::Element const &element, bool const check_allnodes)
Compute the minimum and maximum node distances for this element.
bool isPointInElementXY(MathLib::Point3d const &p, Element const &e)
bool hasZeroVolume(MeshLib::Element const &element)
Returns true if the element has zero length/area/volume.
std::string MeshElemType2String(const MeshElemType t)
Given a MeshElemType this returns the appropriate string.
std::pair< double, double > computeSqrEdgeLengthRange(Element const &element)
Compute the minimum and maximum squared edge length for this element.
std::size_t getNodeIndex(Element const &element, unsigned const idx)
unsigned getNodeIDinElement(Element const &element, const MeshLib::Node *node)
Returns the position of the given node in the node array of this element.
MathLib::Point3d getCenterOfGravity(Element const &element)
Calculates the center of gravity for the mesh element.
std::ostream & operator<<(std::ostream &os, Element const &e)
bool areNeighbors(Element const *const element, Element const *const other)
Returns true if elem is a neighbour of this element and false otherwise.