OGS
MeshLib::LineRule Class Reference

Detailed Description

A 1d Edge or Line Element.

Definition at line 22 of file LineRule.h.

#include <LineRule.h>

Inheritance diagram for MeshLib::LineRule:
[legend]
Collaboration diagram for MeshLib::LineRule:
[legend]

Static Public Member Functions

static bool isPntInElement (Node const *const *nodes, MathLib::Point3d const &pnt, double eps)
 
static ElementErrorCode validate (const Element *e)
 
static unsigned identifyFace (Node const *const *, Node const *nodes[1])
 Returns the ID of a face given an array of nodes.
 
static double computeVolume (Node const *const *element_nodes)
 Calculates the length of a line.
 
- Static Public Member Functions inherited from MeshLib::EdgeRule
static const ElementgetFace (const Element *, unsigned)
 Returns the i-th face of the element.
 
static bool testElementNodeOrder (Element const &)
 

Static Public Attributes

static const unsigned n_base_nodes = 2u
 Constant: The number of base nodes for this element.
 
static const MeshElemType mesh_elem_type = MeshElemType::LINE
 Constant: The geometric type of the element.
 
static const unsigned n_neighbors = 2
 Constant: The number of neighbors.
 
- Static Public Attributes inherited from MeshLib::EdgeRule
static const unsigned dimension = 1u
 Constant: Dimension of this mesh element.
 
static const unsigned n_faces = 0
 Constant: The number of faces.
 
static const unsigned n_edges = 1
 Constant: The number of edges.
 

Member Function Documentation

◆ computeVolume()

double MeshLib::LineRule::computeVolume ( Node const *const * element_nodes)
static

Calculates the length of a line.

Definition at line 17 of file LineRule.cpp.

18{
19 return std::sqrt(MathLib::sqrDist(*element_nodes[0], *element_nodes[1]));
20}
double sqrDist(MathLib::Point3d const &p0, MathLib::Point3d const &p1)
Definition Point3d.cpp:26

References MathLib::sqrDist().

◆ identifyFace()

unsigned MeshLib::LineRule::identifyFace ( Node const *const * element_nodes,
Node const * nodes[1] )
static

Returns the ID of a face given an array of nodes.

Definition at line 55 of file LineRule.cpp.

57{
58 if (nodes[0] == element_nodes[0])
59 {
60 return 0;
61 }
62 if (nodes[0] == element_nodes[1])
63 {
64 return 1;
65 }
66 return std::numeric_limits<unsigned>::max();
67}

◆ isPntInElement()

bool MeshLib::LineRule::isPntInElement ( Node const *const * nodes,
MathLib::Point3d const & pnt,
double eps )
static

Checks if a point is inside the element.

Parameters
pnta 3D MathLib::Point3d object
epstolerance for numerical algorithm used or computing the property
Returns
true if the point is not outside the element, false otherwise
Parameters
nodesthe nodes of the element.

Definition at line 22 of file LineRule.cpp.

24{
25 auto const& a = *nodes[0];
26 auto const& b = *nodes[1];
27
28 if (MathLib::sqrDist(a, pnt) < eps * eps)
29 {
30 return true;
31 }
32 if (MathLib::sqrDist(b, pnt) < eps * eps)
33 {
34 return true;
35 }
36
37 double lambda;
38 double distance_of_proj_pnt_to_a;
39 auto const distance_from_line = MathLib::calcProjPntToLineAndDists(
40 pnt, a, b, lambda, distance_of_proj_pnt_to_a);
41
42 if (lambda >= 0 && lambda <= 1)
43 {
44 // pnt has been projected to the interior of the line
45 return distance_from_line < eps;
46 }
47 else
48 {
49 // pnt has been projected outside the line segment
50 // corner cases have already been treated in the beginning
51 return false;
52 }
53}
double calcProjPntToLineAndDists(Point3d const &pp, Point3d const &pa, Point3d const &pb, double &lambda, double &d0)
Definition MathTools.cpp:19

References MathLib::calcProjPntToLineAndDists(), and MathLib::sqrDist().

◆ validate()

ElementErrorCode MeshLib::LineRule::validate ( const Element * e)
static

Tests if the element is geometrically valid.

Definition at line 69 of file LineRule.cpp.

70{
71 ElementErrorCode error_code;
73 return error_code;
74}
Collects error flags for mesh elements.
bool hasZeroVolume(MeshLib::Element const &element)
Returns true if the element has zero length/area/volume.
Definition Element.cpp:119

References MeshLib::hasZeroVolume(), and ZeroVolume.

Member Data Documentation

◆ mesh_elem_type

const MeshElemType MeshLib::LineRule::mesh_elem_type = MeshElemType::LINE
static

Constant: The geometric type of the element.

Definition at line 29 of file LineRule.h.

◆ n_base_nodes

const unsigned MeshLib::LineRule::n_base_nodes = 2u
static

Constant: The number of base nodes for this element.

Definition at line 26 of file LineRule.h.

◆ n_neighbors

const unsigned MeshLib::LineRule::n_neighbors = 2
static

Constant: The number of neighbors.

Definition at line 32 of file LineRule.h.


The documentation for this class was generated from the following files: