https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
SurfaceTri3 Class Reference

Derived class for 3-node triangular surface elements (Tri3). More...

#include <SurfaceTri3.h>

Inheritance diagram for SurfaceTri3:
[legend]

Public Member Functions

 SurfaceTri3 (const Elem *elem)
 Constructor.
 
bool intersect (const LineSegment &line_segment) const override
 Check if a line segment intersects this geometry.
 
Ball computeBoundingBall () const override
 Compute a bounding ball for this geometry.
 
const Point & normal () const
 Getter for the normal vector.
 
bool intersect (const LineSegment &l, libMesh::Point &intersect_p) const
 Check if a line segment intersects this triangle.
 
bool intersect (const LineSegment &line_segment) const override
 Check if a line segment intersects this triangle, without returning the intersection point.
 
const Elem & elem () const
 Getter for the underlying element.
 
unsigned int expectedEmbeddingMeshDim () const
 Getter of expected embedding solving mesh dimension Because the surface element is a face of the embedding mesh, its dimension is one less than the dimension of the embedding mesh.
 
Real getProjectedBoundingBoxDiagonal (const Point &normal_dir) const
 Compute the length of the element bounding-box diagonal projected onto a plane orthogonal to a given direction.
 

Private Attributes

libMesh::Point _p0
 
libMesh::Point _p1
 
libMesh::Point _p2
 
const Elem * _elem
 Pointer to the libMesh element representing this surface face.
 
const Point _normal
 Unit normal vector of the surface element.
 

Detailed Description

Derived class for 3-node triangular surface elements (Tri3).

Definition at line 16 of file SurfaceTri3.h.

Constructor & Destructor Documentation

◆ SurfaceTri3()

SurfaceTri3::SurfaceTri3 ( const Elem *  elem)
explicit

Constructor.

Definition at line 13 of file SurfaceTri3.C.

14 : Triangle(elem->point(0), elem->point(1), elem->point(2)),
16{
17 mooseAssert(elem->type() == TRI3, "Element must be of type TRI3");
18}
Base class for a single surface (boundary) element of a closed surface mesh.
const Elem & elem() const
Getter for the underlying element.
libMesh::Point normal() const
Normal vector of the triangle.
Definition Triangle.C:24
Triangle()=default

Member Function Documentation

◆ computeBoundingBall()

Ball SurfaceTri3::computeBoundingBall ( ) const
inlineoverridevirtual

Compute a bounding ball for this geometry.

Sphere in 3D, circle in 2D. The ball should fully contain the geometry.

Implements GeometryBase.

Definition at line 33 of file SurfaceTri3.h.

Ball computeBoundingBall() const override
Compute a bounding ball for this triangle.
Definition Triangle.C:91

◆ elem()

const Elem & SurfaceElement::elem ( ) const
inlineinherited

Getter for the underlying element.

Definition at line 40 of file SurfaceElement.h.

40{ return *_elem; }
const Elem * _elem
Pointer to the libMesh element representing this surface face.

Referenced by SurfaceEdge2::SurfaceEdge2(), SurfaceElement::SurfaceElement(), and SurfaceTri3().

◆ expectedEmbeddingMeshDim()

unsigned int SurfaceElement::expectedEmbeddingMeshDim ( ) const
inlineinherited

Getter of expected embedding solving mesh dimension Because the surface element is a face of the embedding mesh, its dimension is one less than the dimension of the embedding mesh.

Definition at line 54 of file SurfaceElement.h.

54{ return _elem->dim() + 1; }

◆ getProjectedBoundingBoxDiagonal()

Real SurfaceElement::getProjectedBoundingBoxDiagonal ( const Point &  normal_dir) const
inherited

Compute the length of the element bounding-box diagonal projected onto a plane orthogonal to a given direction.

The projection plane is defined only by its normal direction; the specific location (offset) of the plane is irrelevant for this operation. Equivalently, this function removes the component of the bounding-box diagonal along the given normal direction and returns the norm of the remaining tangential component.

Parameters
normal_dirA direction vector defining the plane normal.
Returns
The length of the longest diagonal of the projected rectangle.

Definition at line 24 of file SurfaceElement.C.

25{
26 const BoundingBox bbox = _elem->loose_bounding_box();
27 const Point d = bbox.second - bbox.first; // (dx, dy, dz), each >= 0
28
29 // The longest diagonal of the projected AABB (its shadow on the plane orthogonal to
30 // normal_dir) is the search radius that must cover this element's projected footprint.
31 // Projecting only the main diagonal (dx, dy, dz) underestimates it whenever that diagonal
32 // is nearly parallel to normal_dir. The projected footprint diameter is the max projected
33 // length over all four space diagonals (dx, +/-dy, +/-dz); their negatives have identical
34 // projected length, so these four combinations are exhaustive.
35 Real max_projected = 0.0;
36 for (const Real sy : {1.0, -1.0})
37 for (const Real sz : {1.0, -1.0})
38 {
39 const Point diag(d(0), sy * d(1), sz * d(2));
40 const Point tangent_vec = diag - normal_dir * (diag * normal_dir);
41 max_projected = std::max(max_projected, tangent_vec.norm());
42 }
43
44 return max_projected;
45}
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

◆ intersect() [1/3]

bool Triangle::intersect ( const LineSegment l,
libMesh::Point intersect_p 
) const

Check if a line segment intersects this triangle.

Definition at line 37 of file Triangle.C.

39{
40 const auto & a = line_segment.start();
41 const auto & b = line_segment.end();
42
43 // (a) Build basic vectors and choose a robust tolerance
44 const Point dir = b - a;
45
46 const Point edge1 = _p1 - _p0;
47 const Point edge2 = _p2 - _p0;
48 constexpr Real eps = libMesh::TOLERANCE;
49
50 // (b) Test for parallel or degenerate configuration
51 const Point pvec = dir.cross(edge2);
52 const Real det = edge1 * pvec;
53 if (std::abs(det) < eps)
54 return false; // ray nearly parallel to triangle
55
56 const Real inv_det = 1.0 / det;
57
58 // (c) Compute barycentric coordinate u and check 0 <= u <= 1
59 const Point tvec = a - _p0;
60 const Real u = (tvec * pvec) * inv_det;
61 if (!MooseUtils::absoluteFuzzyGreaterEqual(u, 0.0, eps) ||
62 !MooseUtils::absoluteFuzzyLessEqual(u, 1.0, eps))
63 return false;
64
65 // (d) Compute barycentric coordinate v and check 0 <= v and u + v <= 1
66 const Point qvec = tvec.cross(edge1);
67 const Real v = (dir * qvec) * inv_det;
68 if (!MooseUtils::absoluteFuzzyGreaterEqual(v, 0.0, eps) ||
69 !MooseUtils::absoluteFuzzyLessEqual(u + v, 1.0, eps))
70 return false;
71
72 // (e) Locate intersection along line segment (0 <= t <= 1 constrains to a--b)
73 const Real t = (edge2 * qvec) * inv_det;
74 if (!MooseUtils::absoluteFuzzyGreaterEqual(t, 0.0, eps) ||
75 !MooseUtils::absoluteFuzzyLessEqual(t, 1.0, eps))
76 return false;
77
78 // (f) Intersection lies inside both the triangle and the segment
79 intersect_p = a + dir * t;
80 return true;
81}
libMesh::Point _p2
Definition Triangle.h:50
libMesh::Point _p0
Definition Triangle.h:50
libMesh::Point _p1
Definition Triangle.h:50
TypeVector< typename CompareTypes< Real, T2 >::supertype > cross(const TypeVector< T2 > &v) const
int eps(unsigned int i, unsigned int j)
2D version
static constexpr Real TOLERANCE

◆ intersect() [2/3]

bool Triangle::intersect ( const LineSegment line_segment) const
overridevirtual

Check if a line segment intersects this triangle, without returning the intersection point.

Implements GeometryBase.

Definition at line 42 of file Triangle.C.

85{
87 return intersect(line_segment, p);
88}
bool intersect(const LineSegment &line_segment) const override
Check if a line segment intersects this geometry.
Definition SurfaceTri3.h:29

◆ intersect() [3/3]

bool SurfaceTri3::intersect ( const LineSegment line_segment) const
inlineoverridevirtual

Check if a line segment intersects this geometry.

Implements GeometryBase.

Definition at line 29 of file SurfaceTri3.h.

30 {
31 return Triangle::intersect(line_segment);
32 }
bool intersect(const LineSegment &l, libMesh::Point &intersect_p) const
Check if a line segment intersects this triangle.
Definition Triangle.C:38

◆ normal()

const Point & SurfaceElement::normal ( ) const
inline

Getter for the normal vector.

Definition at line 43 of file SurfaceElement.h.

43{ return _normal; }
const Point _normal
Unit normal vector of the surface element.

Member Data Documentation

◆ _elem

const Elem* SurfaceElement::_elem
privateinherited

Pointer to the libMesh element representing this surface face.

Derived classes access it through elem() rather than this field directly.

Definition at line 80 of file SurfaceElement.h.

Referenced by SurfaceElement::elem(), SurfaceElement::expectedEmbeddingMeshDim(), and SurfaceElement::getProjectedBoundingBoxDiagonal().

◆ _normal

const Point SurfaceElement::_normal
privateinherited

Unit normal vector of the surface element.

Definition at line 82 of file SurfaceElement.h.

Referenced by SurfaceElement::normal(), and SurfaceElement::SurfaceElement().

◆ _p0

libMesh::Point Triangle::_p0
privateinherited

Definition at line 50 of file Triangle.h.

Referenced by Triangle::computeBoundingBall(), and Triangle::normal().

◆ _p1

libMesh::Point Triangle::_p1
privateinherited

Definition at line 50 of file Triangle.h.

Referenced by Triangle::computeBoundingBall(), and Triangle::normal().

◆ _p2

libMesh::Point Triangle::_p2
privateinherited

Definition at line 50 of file Triangle.h.

Referenced by Triangle::computeBoundingBall(), and Triangle::normal().


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