OGS
MeshLib::LineRule2 Class Reference

Detailed Description

A 1d Edge or Line Element.

0--------1

Definition at line 27 of file LineRule2.h.

#include <LineRule2.h>

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

Public Types

using EdgeReturn = MeshLib::LinearEdgeReturn
 Edge rule. More...
 

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. More...
 
static double computeVolume (Node const *const *_nodes)
 Calculates the length of a line. More...
 
- Static Public Member Functions inherited from MeshLib::EdgeRule
static const ElementgetFace (const Element *, unsigned)
 Returns the i-th face of the element. More...
 
static bool testElementNodeOrder (Element const &)
 

Static Public Attributes

static const unsigned n_base_nodes = 2u
 Constant: The number of base nodes for this element. More...
 
static const unsigned n_all_nodes = 2u
 Constant: The number of all nodes for this element. More...
 
static const MeshElemType mesh_elem_type = MeshElemType::LINE
 Constant: The geometric type of the element. More...
 
static const CellType cell_type = CellType::LINE2
 Constant: The FEM type of the element. More...
 
static const unsigned n_neighbors = 2
 Constant: The number of neighbors. More...
 
static const unsigned edge_nodes [1][2]
 Constant: Local node index table for edge. More...
 
- Static Public Attributes inherited from MeshLib::EdgeRule
static const unsigned dimension = 1u
 Constant: Dimension of this mesh element. More...
 
static const unsigned n_faces = 0
 Constant: The number of faces. More...
 
static const unsigned n_edges = 1
 Constant: The number of edges. More...
 

Member Typedef Documentation

◆ EdgeReturn

Edge rule.

Definition at line 49 of file LineRule2.h.

Member Function Documentation

◆ computeVolume()

double MeshLib::LineRule2::computeVolume ( Node const *const *  _nodes)
static

Calculates the length of a line.

Definition at line 22 of file LineRule2.cpp.

23 {
24  return std::sqrt(MathLib::sqrDist(*_nodes[0], *_nodes[1]));
25 }
double sqrDist(MathLib::Point3d const &p0, MathLib::Point3d const &p1)
Definition: Point3d.cpp:26

References MathLib::sqrDist().

◆ identifyFace()

unsigned MeshLib::LineRule2::identifyFace ( Node const *const *  _nodes,
Node const *  nodes[1] 
)
static

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

Definition at line 60 of file LineRule2.cpp.

62 {
63  if (nodes[0] == _nodes[0])
64  {
65  return 0;
66  }
67  if (nodes[0] == _nodes[1])
68  {
69  return 1;
70  }
71  return std::numeric_limits<unsigned>::max();
72 }

◆ isPntInElement()

bool MeshLib::LineRule2::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 27 of file LineRule2.cpp.

29 {
30  auto const& a = *nodes[0];
31  auto const& b = *nodes[1];
32 
33  if (MathLib::sqrDist(a, pnt) < eps * eps)
34  {
35  return true;
36  }
37  if (MathLib::sqrDist(b, pnt) < eps * eps)
38  {
39  return true;
40  }
41 
42  double lambda;
43  double distance_of_proj_pnt_to_a;
44  auto const distance_from_line = MathLib::calcProjPntToLineAndDists(
45  pnt, a, b, lambda, distance_of_proj_pnt_to_a);
46 
47  if (lambda >= 0 && lambda <= 1)
48  {
49  // pnt has been projected to the interior of the line
50  return distance_from_line < eps;
51  }
52  else
53  {
54  // pnt has been projected outside the line segment
55  // corner cases have already been treated in the beginning
56  return false;
57  }
58 }
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::LineRule2::validate ( const Element e)
static

Tests if the element is geometrically valid.

Definition at line 74 of file LineRule2.cpp.

75 {
76  ElementErrorCode error_code;
78  return error_code;
79 }
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

◆ cell_type

const CellType MeshLib::LineRule2::cell_type = CellType::LINE2
static

Constant: The FEM type of the element.

Definition at line 40 of file LineRule2.h.

◆ edge_nodes

const unsigned MeshLib::LineRule2::edge_nodes
static
Initial value:
= {
{0, 1}
}

Constant: Local node index table for edge.

Definition at line 46 of file LineRule2.h.

◆ mesh_elem_type

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

Constant: The geometric type of the element.

Definition at line 37 of file LineRule2.h.

◆ n_all_nodes

const unsigned MeshLib::LineRule2::n_all_nodes = 2u
static

Constant: The number of all nodes for this element.

Definition at line 34 of file LineRule2.h.

◆ n_base_nodes

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

Constant: The number of base nodes for this element.

Definition at line 31 of file LineRule2.h.

◆ n_neighbors

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

Constant: The number of neighbors.

Definition at line 43 of file LineRule2.h.


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