14 #include "libmesh/string_to_enum.h" 17 : _elem(elem), _normal(normal)
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());
28 const auto t =
elem->build_side_ptr(0)->type();
30 mooseError(
"SBMBndElementBase: unsupported side type ",
32 " (from element type ",
34 "). distanceFrom() only handles EDGE2 and NODEELEM sides.");
45 const auto vec_to_first =
_elem->point(0) - pt;
50 if (
_elem->contains_point(pt + projection))
54 Real min_dist = std::numeric_limits<Real>::max();
57 const unsigned int n_edges =
_elem->n_sides();
58 for (
unsigned int j = 0;
j < n_edges; ++
j)
60 std::unique_ptr<const Elem> curr_edge =
_elem->build_side_ptr(
j);
62 switch (curr_edge->type())
66 const Point & p1 = *curr_edge->node_ptr(0);
67 const Point & p2 = *curr_edge->node_ptr(1);
69 const Point
edge = p2 - p1;
71 t = std::clamp(t, 0.0, 1.0);
72 const Point proj = p1 + t *
edge;
73 const Real dist = (pt - proj).
norm();
78 closest_vec = proj - pt;
85 const Point &
p = *curr_edge->node_ptr(0);
96 mooseAssert(
false,
"unreachable: side type validated in SBMBndElementBase ctor");
106 BoundingBox bbox =
_elem->loose_bounding_box();
108 const Point & min_pt = bbox.first;
109 const Point & max_pt = bbox.second;
112 Point box_vec = max_pt - min_pt;
115 Real normal_scale = box_vec * normal_dir;
116 Point normal_box_vec = normal_dir * normal_scale;
119 Point tangent_vec = box_vec - normal_box_vec;
121 return tangent_vec.norm();
127 if (
const auto * geom = dynamic_cast<const GeometryBase *>(
this))
128 return geom->intersect(line_segment);
130 mooseError(
"SBMBndElementBase::intersect: unsupported geometry type");
136 if (
const auto * geom = dynamic_cast<const GeometryBase *>(
this))
139 mooseError(
"SBMBndElementBase::computeBoundingBall: unsupported geometry type");
const Elem & elem() const
Getter for the underlying element.
void mooseError(Args &&... args)
Ball computeBoundingBall() const
Compute a bounding ball for this boundary element.
bool intersect(const LineSegment &line_segment) const
Check if the given line segment intersects this boundary element.
std::string enum_to_string(const T e)
Real getProjectedBoundingBoxDiagonal(const Point &normal_dir) const
Compute the length of the element bounding-box diagonal projected onto a plane orthogonal to a given ...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const Elem * _elem
< Pointer to the libMesh element representing this boundary face.
virtual Point distanceFrom(const Point &pt) const
Compute the distance vector from an arbitrary point to this boundary element.
SBMBndElementBase(const Elem *elem, const Point &normal)
Constructor takes a pointer to a boundary element and its precomputed unit normal.
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
Ball computeBoundingBall() const override