https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
SBMBndUnsupportedForTest Class Reference
Inheritance diagram for SBMBndUnsupportedForTest:
[legend]

Public Member Functions

 SBMBndElementBase (const Elem *elem, const Point &normal)
 Constructor takes a pointer to a boundary element and its precomputed unit normal.
 
const Elemelem () const
 Getter for the underlying element.
 
const Pointnormal () const
 Getter for the normal vector.
 
bool intersect (const LineSegment &line_segment) const
 Check if the given line segment intersects this boundary element.
 
unsigned int expectedEmbeddingMeshDim () const
 Getter of expected embedding solving mesh dimension Because the boundary element is a face of the embedding mesh, its dimension is one less than the dimension of the embedding mesh.
 
virtual Point distanceFrom (const Point &pt) const
 Compute the distance vector from an arbitrary point to this boundary element.
 
Ball computeBoundingBall () const
 Compute a bounding ball for this boundary 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 boundary face.
 
const Point _normal
 

Detailed Description

Definition at line 28 of file SBMBndElementTest.C.

Member Function Documentation

◆ computeBoundingBall()

Ball SBMBndElementBase::computeBoundingBall ( ) const
inherited

Compute a bounding ball for this boundary element.

Delegates to the underlying geometry via dynamic_cast.

Definition at line 134 of file SBMBndElementBase.C.

135{
136 if (const auto * geom = dynamic_cast<const GeometryBase *>(this))
137 return geom->computeBoundingBall();
138
139 mooseError("SBMBndElementBase::computeBoundingBall: unsupported geometry type");
140}
void mooseError(Args &&... args)

Referenced by TEST(), and TEST().

◆ distanceFrom()

Point SBMBndElementBase::distanceFrom ( const Point &  pt) const
virtualinherited

Compute the distance vector from an arbitrary point to this boundary element.

Default: normal-based distance vector. Override in derived class if needed. (a) First calculation of the normal-based distance and the projection point (b) If the projection point is outside the element, return the distance to the closest vertex.

Definition at line 39 of file SBMBndElementBase.C.

40{
41 // Side-type precondition is validated once in the base ctor; no per-call
42 // check needed here.
43
44 // (a) Project pt onto the normal direction
45 const auto vec_to_first = _elem->point(0) - pt;
46 const auto scale = vec_to_first * _normal;
47 const auto projection = _normal * scale;
48
49 // Check if projection point lands inside the geometry
50 if (_elem->contains_point(pt + projection))
51 return projection;
52
53 // (d) Point to closest edge or node
54 Real min_dist = std::numeric_limits<Real>::max();
55 Point closest_vec;
56
57 const unsigned int n_edges = _elem->n_sides();
58 for (unsigned int j = 0; j < n_edges; ++j)
59 {
60 std::unique_ptr<const Elem> curr_edge = _elem->build_side_ptr(j);
61
62 switch (curr_edge->type())
63 {
64 case EDGE2:
65 {
66 const Point & p1 = *curr_edge->node_ptr(0);
67 const Point & p2 = *curr_edge->node_ptr(1);
68
69 const Point edge = p2 - p1;
70 Real t = ((pt - p1) * edge) / (edge * edge);
71 t = std::clamp(t, 0.0, 1.0);
72 const Point proj = p1 + t * edge;
73 const Real dist = (pt - proj).norm();
74
75 if (dist < min_dist)
76 {
77 min_dist = dist;
78 closest_vec = proj - pt;
79 }
80 break;
81 }
82
83 case NODEELEM:
84 {
85 const Point & p = *curr_edge->node_ptr(0);
86 const Real dist = (pt - p).norm();
87 if (dist < min_dist)
88 {
89 min_dist = dist;
90 closest_vec = p - pt;
91 }
92 break;
93 }
94
95 default:
96 mooseAssert(false, "unreachable: side type validated in SBMBndElementBase ctor");
97 }
98 }
99
100 return closest_vec;
101}
const Real p
Real scale
const Elem * _elem
< Pointer to the libMesh element representing this boundary face.
auto norm(const T &a)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

Referenced by UnsignedDistanceToSurfaceMesh::distanceVectorToSurface(), TEST(), TEST(), TEST(), TEST(), and TEST().

◆ elem()

const Elem & SBMBndElementBase::elem ( ) const
inlineinherited

Getter for the underlying element.

Definition at line 32 of file SBMBndElementBase.h.

32{ return *_elem; }

Referenced by SBMBndEdge2::SBMBndEdge2(), SBMBndElementBase::SBMBndElementBase(), SBMBndElementBase(), and SBMBndTri3::SBMBndTri3().

◆ expectedEmbeddingMeshDim()

unsigned int SBMBndElementBase::expectedEmbeddingMeshDim ( ) const
inlineinherited

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

Definition at line 46 of file SBMBndElementBase.h.

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

◆ getProjectedBoundingBoxDiagonal()

Real SBMBndElementBase::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 104 of file SBMBndElementBase.C.

105{
106 BoundingBox bbox = _elem->loose_bounding_box();
107
108 const Point & min_pt = bbox.first;
109 const Point & max_pt = bbox.second;
110
111 // Step (a): Calculate box_vec
112 Point box_vec = max_pt - min_pt;
113
114 // Step (b): Project box_vec onto normal_dir
115 Real normal_scale = box_vec * normal_dir;
116 Point normal_box_vec = normal_dir * normal_scale;
117
118 // Step (c): Calculate tangent_vec and its norm
119 Point tangent_vec = box_vec - normal_box_vec;
120
121 return tangent_vec.norm();
122}

Referenced by TEST().

◆ intersect()

bool SBMBndElementBase::intersect ( const LineSegment line_segment) const
inherited

Check if the given line segment intersects this boundary element.

Delegates to the underlying geometry via dynamic_cast.

Definition at line 125 of file SBMBndElementBase.C.

126{
127 if (const auto * geom = dynamic_cast<const GeometryBase *>(this))
128 return geom->intersect(line_segment);
129
130 mooseError("SBMBndElementBase::intersect: unsupported geometry type");
131}

Referenced by TEST(), and TEST().

◆ normal()

const Point & SBMBndElementBase::normal ( ) const
inlineinherited

Getter for the normal vector.

Definition at line 35 of file SBMBndElementBase.h.

35{ return _normal; }

Referenced by UnsignedDistanceToSurfaceMesh::surfaceNormal().

◆ SBMBndElementBase()

SBMBndElementBase::SBMBndElementBase ( const Elem elem,
const Point normal 
)

Constructor takes a pointer to a boundary 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 26 of file SBMBndElementBase.C.

18{
19 mooseAssert(elem, "Element must not be null");
20 mooseAssert(MooseUtils::absoluteFuzzyEqual(_normal.norm(), 1),
21 "normal vector must be unit length, length = " << _normal.norm());
22
23 // Validate side type once, here, so distanceFrom() can trust the invariant
24 // without paying a per-call check. libMesh standard elements have uniform
25 // side types, so probing side(0) is sufficient.
26 if (elem && elem->n_sides() > 0)
27 {
28 const auto t = elem->build_side_ptr(0)->type();
29 if (t != EDGE2 && t != NODEELEM)
30 mooseError("SBMBndElementBase: unsupported side type ",
32 " (from element type ",
34 "). distanceFrom() only handles EDGE2 and NODEELEM sides.");
35 }
36}
const Point & normal() const
Getter for the normal vector.
const Elem & elem() const
Getter for the underlying element.
std::string enum_to_string(const T e)

Member Data Documentation

◆ _elem

const Elem* SBMBndElementBase::_elem
privateinherited

< Pointer to the libMesh element representing this boundary face.

Derived classes access it through elem() rather than this field directly. Unit normal vector of the boundary element, computed eagerly in the derived constructor and passed through the base constructor.

Definition at line 80 of file SBMBndElementBase.h.

Referenced by SBMBndElementBase::distanceFrom(), SBMBndElementBase::elem(), SBMBndElementBase::expectedEmbeddingMeshDim(), and SBMBndElementBase::getProjectedBoundingBoxDiagonal().

◆ _normal

const Point SBMBndElementBase::_normal
privateinherited

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