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

Base class for a single surface (boundary) element of a closed surface mesh. More...

#include <SurfaceElement.h>

Inheritance diagram for SurfaceElement:
[legend]

Public Member Functions

 SurfaceElement (const Elem *elem, const Point &normal)
 Constructor takes a pointer to a surface element and its precomputed unit normal.
 
virtual ~SurfaceElement ()=default
 Virtual destructor to ensure proper cleanup in derived classes.
 
const Elem & elem () const
 Getter for the underlying element.
 
const Point & normal () const
 Getter for the normal vector.
 
virtual bool intersect (const LineSegment &line_segment) const =0
 Check if the given line segment intersects this surface 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.
 
virtual Ball computeBoundingBall () const =0
 Compute a bounding ball for this surface element.
 
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

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

Detailed Description

Base class for a single surface (boundary) element of a closed surface mesh.

Wraps a libMesh boundary element (an EDGE2 in 2D or a TRI3 in 3D) together with its precomputed unit normal and provides the geometric queries needed by point-containment and distance algorithms. intersect() and computeBoundingBall() are pure virtual here so that callers can issue them through a SurfaceElement reference without knowing the concrete geometry; concrete derived classes (SurfaceEdge2, SurfaceTri3) also derive from a GeometryBase primitive (LineSegment, Triangle) and forward to it.

Definition at line 26 of file SurfaceElement.h.

Constructor & Destructor Documentation

◆ SurfaceElement()

SurfaceElement::SurfaceElement ( const Elem *  elem,
const Point &  normal 
)

Constructor takes a pointer to a surface element and its precomputed unit normal.

The normal is computed eagerly by derived classes (which know their geometry) so the base can store it const and shared concurrent reads are safe.

Definition at line 14 of file SurfaceElement.C.

16{
17 mooseAssert(elem, "Element must not be null");
18
19 if (!MooseUtils::absoluteFuzzyEqual(_normal.norm(), 1))
20 mooseError("SurfaceElement: normal vector must be unit length, length = ", _normal.norm());
21}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
const Point & normal() const
Getter for the normal vector.
const Elem * _elem
Pointer to the libMesh element representing this surface face.
const Elem & elem() const
Getter for the underlying element.
const Point _normal
Unit normal vector of the surface element.

◆ ~SurfaceElement()

virtual SurfaceElement::~SurfaceElement ( )
virtualdefault

Virtual destructor to ensure proper cleanup in derived classes.

Member Function Documentation

◆ computeBoundingBall()

virtual Ball SurfaceElement::computeBoundingBall ( ) const
pure virtual

Compute a bounding ball for this surface element.

Implemented by derived classes by forwarding to their geometry primitive.

Implemented in SurfaceEdge2, and SurfaceTri3.

◆ elem()

const Elem & SurfaceElement::elem ( ) const
inline

Getter for the underlying element.

Definition at line 40 of file SurfaceElement.h.

40{ return *_elem; }

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

◆ expectedEmbeddingMeshDim()

unsigned int SurfaceElement::expectedEmbeddingMeshDim ( ) const
inline

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

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()

virtual bool SurfaceElement::intersect ( const LineSegment line_segment) const
pure virtual

Check if the given line segment intersects this surface element.

Implemented by derived classes by forwarding to their geometry primitive.

Implemented in SurfaceEdge2, SurfaceEdge2, SurfaceTri3, and SurfaceTri3.

Referenced by AdaptiveRayContainmentCheck::rayIntersectGeometry().

◆ normal()

const Point & SurfaceElement::normal ( ) const
inline

Getter for the normal vector.

Definition at line 43 of file SurfaceElement.h.

43{ return _normal; }

Member Data Documentation

◆ _elem

const Elem* SurfaceElement::_elem
private

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 elem(), expectedEmbeddingMeshDim(), and getProjectedBoundingBoxDiagonal().

◆ _normal

const Point SurfaceElement::_normal
private

Unit normal vector of the surface element.

Definition at line 82 of file SurfaceElement.h.

Referenced by normal(), and SurfaceElement().


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