https://mooseframework.inl.gov
Public Member Functions | List of all members
SBMBndTri3 Class Reference

Derived class for 3-node triangular elements (Tri3) Triangle is listed first so it is initialized before SBMBndElementBase; the base class constructor then receives the unit normal from Triangle::normal() (see the .C file). More...

#include <SBMBndTri3.h>

Inheritance diagram for SBMBndTri3:
[legend]

Public Member Functions

 SBMBndTri3 (const Elem *elem)
 Constructor. More...
 
const Point & normal () const
 Getter for the normal vector. More...
 
Ball computeBoundingBall () const override
 
bool intersect (const LineSegment &l, libMesh::Point &intersect_p) const
 
bool intersect (const LineSegment &line_segment) const override
 
libMesh::Point normal () const
 
bool intersect (const LineSegment &l, libMesh::Point &intersect_p) const
 
bool intersect (const LineSegment &line_segment) const override
 
Ball computeBoundingBall () const override
 
const Elem & elem () const
 Getter for the underlying element. More...
 
const Point & normal () const
 Getter for the normal vector. More...
 
bool intersect (const LineSegment &line_segment) const
 Check if the given line segment intersects this boundary element. More...
 
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. More...
 
virtual Point distanceFrom (const Point &pt) const
 Compute the distance vector from an arbitrary point to this boundary element. More...
 
Ball computeBoundingBall () const
 Compute a bounding ball for this boundary element. More...
 
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. More...
 

Detailed Description

Derived class for 3-node triangular elements (Tri3) Triangle is listed first so it is initialized before SBMBndElementBase; the base class constructor then receives the unit normal from Triangle::normal() (see the .C file).

Definition at line 19 of file SBMBndTri3.h.

Constructor & Destructor Documentation

◆ SBMBndTri3()

SBMBndTri3::SBMBndTri3 ( const Elem *  elem)
explicit

Constructor.

Definition at line 13 of file SBMBndTri3.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 }
const Elem & elem() const
Getter for the underlying element.
Triangle()=default
TRI3
SBMBndElementBase(const Elem *elem, const Point &normal)
Constructor takes a pointer to a boundary element and its precomputed unit normal.
libMesh::Point normal() const

Member Function Documentation

◆ computeBoundingBall() [1/2]

Ball Triangle::computeBoundingBall

◆ computeBoundingBall() [2/2]

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)

◆ 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.

Referenced by UnsignedDistanceToSurfaceMesh::distanceVectorToSurface().

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 }
void scale(MeshBase &mesh, const Real xs, const Real ys=0., const Real zs=0.)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
EDGE2
const Elem * _elem
< Pointer to the libMesh element representing this boundary face.
auto norm(const T &a)
const Real p
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
NODEELEM

◆ elem()

const Elem& SBMBndElementBase::elem ( ) const
inlineinherited

Getter for the underlying element.

Definition at line 32 of file SBMBndElementBase.h.

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

32 { return *_elem; }
const Elem * _elem
< Pointer to the libMesh element representing this boundary face.

◆ 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; }
const Elem * _elem
< Pointer to the libMesh element representing this boundary face.

◆ 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 }
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const Elem * _elem
< Pointer to the libMesh element representing this boundary face.

◆ intersect() [1/3]

bool Triangle::intersect

◆ intersect() [2/3]

bool Triangle::intersect

◆ intersect() [3/3]

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 }
void mooseError(Args &&... args)

◆ normal() [1/2]

const Point& SBMBndElementBase::normal
inline

Getter for the normal vector.

Definition at line 35 of file SBMBndElementBase.h.

35 { return _normal; }

◆ normal() [2/2]

const Point& SBMBndElementBase::normal ( ) const
inlineinherited

Getter for the normal vector.

Definition at line 35 of file SBMBndElementBase.h.

Referenced by UnsignedDistanceToSurfaceMesh::surfaceNormal().

35 { return _normal; }

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