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

Derived class for 2-node edge surface elements (Edge2). More...

#include <SurfaceEdge2.h>

Inheritance diagram for SurfaceEdge2:
[legend]

Public Member Functions

 SurfaceEdge2 (const Elem *elem)
 Constructor.
 
bool intersect (const LineSegment &line_segment) const override
 Check if a line segment intersects another line segment, without returning the intersection point.
 
Ball computeBoundingBall () const override
 Compute a bounding ball for this line segment.
 
bool intersect (const libMesh::Plane &pl, Point &intersect_p) const
 Check if a line segment intersects a plane, and if so, return the intersection point.
 
bool intersect (const LineSegment &l1, Point &intersect_p) const
 Check if a line segment intersects another line segment, and if so, return the intersection point.
 
bool intersect (const LineSegment &line_segment) const override
 Check if a line segment intersects another line segment, without returning the intersection point.
 
const Point & normal () const
 Getter for the normal vector.
 
Point closest_point (const Point &p) const
 Returns the closest point on the LineSegment to the passed in point.
 
bool closest_normal_point (const Point &p, Point &closest_p) const
 Finds the closest point on the Line determined by the Line Segments.
 
bool contains_point (const Point &p) const
 Determines whether a point is in a line segment or not.
 
const Point & start () const
 Beginning of the line segment.
 
const Point & end () const
 Ending of the line segment.
 
void setStart (const Point &p0)
 Sets the beginning of the line segment.
 
void setEnd (const Point &p1)
 Sets the end of the line segment.
 
void set (const Point &p0, const Point &p1)
 Sets the points on the line segment.
 
Real length () const
 Length of segment.
 
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 Member Functions

bool closest_point (const Point &p, bool clamp_to_segment, Point &closest_p) const
 

Private Attributes

Point _p0
 
Point _p1
 
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 2-node edge surface elements (Edge2).

Definition at line 16 of file SurfaceEdge2.h.

Constructor & Destructor Documentation

◆ SurfaceEdge2()

SurfaceEdge2::SurfaceEdge2 ( const Elem *  elem)
explicit

Constructor.

Definition at line 13 of file SurfaceEdge2.C.

14 : LineSegment(elem->point(0), elem->point(1)), SurfaceElement(elem, LineSegment::normal())
15{
16 mooseAssert(elem->type() == EDGE2, "Element must be of type EDGE2");
17 mooseAssert(MooseUtils::absoluteFuzzyEqual(elem->point(0)(2), elem->point(1)(2)),
18 "Currently SurfaceEdge2 must be parallel to the x-y plane, i.e., z-coordinates of "
19 "points must be equal");
20}
LineSegment()=default
Point normal() const
normal vector of the line segment
Base class for a single surface (boundary) element of a closed surface mesh.
const Elem & elem() const
Getter for the underlying element.

Member Function Documentation

◆ closest_normal_point()

bool LineSegment::closest_normal_point ( const Point p,
Point closest_p 
) const
inherited

Finds the closest point on the Line determined by the Line Segments.

Returns a boolean indicating whether that normal point is within the LineSegment or not

Definition at line 58 of file LineSegment.C.

59{
60 return closest_point(p, false, closest_p);
61}
Point closest_point(const Point &p) const
Returns the closest point on the LineSegment to the passed in point.
Definition LineSegment.C:50

◆ closest_point() [1/2]

Point LineSegment::closest_point ( const Point p) const
inherited

Returns the closest point on the LineSegment to the passed in point.

Note that the closest point may be one of the ends of the LineSegment.

Definition at line 50 of file LineSegment.C.

51{
52 Point closest_p;
53 closest_point(p, true, closest_p);
54 return closest_p;
55}

Referenced by LineSegment::closest_point(), and LineSegment::contains_point().

◆ closest_point() [2/2]

bool LineSegment::closest_point ( const Point p,
bool  clamp_to_segment,
Point closest_p 
) const
privateinherited

Definition at line 25 of file LineSegment.C.

26{
27 Point p0_p = p - _p0;
28 Point p0_p1 = _p1 - _p0;
29 Real p0_p1_2 = p0_p1.norm_sq();
30 Real perp = p0_p(0) * p0_p1(0) + p0_p(1) * p0_p1(1) + p0_p(2) * p0_p1(2);
31 Real t = perp / p0_p1_2;
32 bool on_segment = true;
33
34 if (t < 0.0 || t > 1.0)
35 on_segment = false;
36
37 if (clamp_to_segment)
38 {
39 if (t < 0.0)
40 t = 0.0;
41 else if (t > 1.0)
42 t = 1.0;
43 }
44
45 closest_p = _p0 + p0_p1 * t;
46 return on_segment;
47}
auto norm_sq() const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

◆ computeBoundingBall()

Ball SurfaceEdge2::computeBoundingBall ( ) const
inlineoverridevirtual

Compute a bounding ball for this line segment.

The ball is defined by the midpoint of the segment and a radius equal to half the segment length.

Reimplemented from LineSegment.

Definition at line 33 of file SurfaceEdge2.h.

Ball computeBoundingBall() const override
Compute a bounding ball for this line segment.

◆ contains_point()

bool LineSegment::contains_point ( const Point p) const
inherited

Determines whether a point is in a line segment or not.

Definition at line 64 of file LineSegment.C.

65{
66 Point closest_p;
67 return closest_point(p, false, closest_p) && closest_p.absolute_fuzzy_equals(p);
68}
bool absolute_fuzzy_equals(const TypeVector< Real > &rhs, Real tol=TOLERANCE) const

Referenced by Moose::sideIntersectedByLine().

◆ 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(), SurfaceElement::SurfaceElement(), and SurfaceTri3::SurfaceTri3().

◆ end()

const Point & LineSegment::end ( ) const
inlineinherited

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

◆ intersect() [1/4]

bool LineSegment::intersect ( const libMesh::Plane pl,
Point intersect_p 
) const

Check if a line segment intersects a plane, and if so, return the intersection point.

There are three cases in 3D for intersection of a line and a plane Case 1: The line is parallel to the plane - No intersection Numerator = non-zero Denominator = zero

Case 2: The line is within the plane - Inf intersection Numerator = zero Denominator = zero

Case 3: The line intersects the plane at a single point Denominator = non-zero

Definition at line 60 of file LineSegment.C.

72{
87 Point pl0 = pl.get_planar_point();
89 RealVectorValue I = (_p1 - _p0).unit();
90
91 Real numerator = (pl0 - _p0) * N;
92 Real denominator = I * N;
93
94 // The Line is parallel to the plane
95 if (std::abs(denominator) < 1.e-10)
96 {
97 // The Line is on the plane
98 if (std::abs(numerator) < 1.e-10)
99 {
100 // The solution is not unique so we'll just pick an end point for now
101 intersect_p = _p0;
102 return true;
103 }
104 return false;
105 }
106
107 Real d = numerator / denominator;
108
109 // Make sure we haven't moved off the line segment!
110 if (d + libMesh::TOLERANCE < 0 || d - libMesh::TOLERANCE > (_p1 - _p0).norm())
111 return false;
112
113 intersect_p = d * I + _p0;
114
115 return true;
116}
const Point & get_planar_point() const
virtual Point unit_normal(const Point &p) const override
VectorValue< Real > RealVectorValue
Definition SubProblem.h:34

◆ intersect() [2/4]

bool LineSegment::intersect ( const LineSegment l1,
Point &  intersect_p 
) const

Check if a line segment intersects another line segment, and if so, return the intersection point.

◆ intersect() [3/4]

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

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

Reimplemented from LineSegment.

Definition at line 72 of file LineSegment.C.

255{
256 Point p;
257 return intersect(line_segment, p);
258}
bool intersect(const LineSegment &line_segment) const override
Check if a line segment intersects another line segment, without returning the intersection point.

◆ intersect() [4/4]

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

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

Reimplemented from LineSegment.

Definition at line 29 of file SurfaceEdge2.h.

30 {
31 return LineSegment::intersect(line_segment);
32 }
bool intersect(const libMesh::Plane &pl, Point &intersect_p) const
Check if a line segment intersects a plane, and if so, return the intersection point.
Definition LineSegment.C:71

◆ length()

Real LineSegment::length ( ) const
inlineinherited

Length of segment.

Definition at line 112 of file LineSegment.h.

112{ return (_p0 - _p1).norm(); }

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

◆ set()

void LineSegment::set ( const Point p0,
const Point p1 
)
inherited

Sets the points on the line segment.

Parameters
p0The start point of the line segment
p1The end point of the line segment

Definition at line 261 of file LineSegment.C.

262{
263 setStart(p0);
264 setEnd(p1);
265}
void setStart(const Point &p0)
Sets the beginning of the line segment.
Definition LineSegment.h:95
void setEnd(const Point &p1)
Sets the end of the line segment.

Referenced by dataLoad().

◆ setEnd()

void LineSegment::setEnd ( const Point &  p1)
inlineinherited

Sets the end of the line segment.

Definition at line 100 of file LineSegment.h.

100{ _p1 = p1; }

Referenced by LineSegment::set().

◆ setStart()

void LineSegment::setStart ( const Point &  p0)
inlineinherited

Sets the beginning of the line segment.

Definition at line 95 of file LineSegment.h.

95{ _p0 = p0; }

Referenced by LineSegment::set().

◆ start()

const Point & LineSegment::start ( ) const
inlineinherited

Beginning of the line segment.

Definition at line 85 of file LineSegment.h.

85{ return _p0; }

Referenced by dataStore(), Triangle::intersect(), Ball::intersect(), and to_json().

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

Point LineSegment::_p0
privateinherited

◆ _p1

Point LineSegment::_p1
privateinherited

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