https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Member Functions | List of all members
ElemExtrema Struct Reference

Helper for defining if at an element's edge, vertex, or neither. More...

#include <ElemExtrema.h>

Inheritance diagram for ElemExtrema:
[legend]

Public Member Functions

 ElemExtrema ()
 Default constructor: sets entires to invalid (not at vertex or edge)
 
 ElemExtrema (const unsigned short v1, const unsigned short v2)
 
bool atExtrema () const
 
bool isInvalid () const
 
bool atVertex () const
 
bool atVertex (const unsigned short v) const
 
bool atEdge () const
 
bool atEdge (const unsigned short v1, const unsigned short v2) const
 
void invalidate ()
 Invalidates the current state.
 
unsigned short vertex () const
 
const std::pair< unsigned short, unsigned short > & edgeVertices () const
 
std::string print () const
 Prints the current state (at edge, at vertex, not at either)
 
void setVertex (const unsigned short vertex)
 Sets the "at vertex" state.
 
void setEdge (const unsigned short v1, const unsigned short v2)
 Sets the "at edge" state.
 
void setEdge (const std::pair< unsigned short, unsigned short > &vertices)
 Sets the "at edge" state.
 
const Point & vertexPoint (const libMesh::Elem *elem) const
 
std::unique_ptr< const libMesh::ElembuildEdge (const Elem *elem) const
 
bool isValid (const Elem *const elem, const Point &point) const
 

Detailed Description

Helper for defining if at an element's edge, vertex, or neither.

Definition at line 25 of file ElemExtrema.h.

Constructor & Destructor Documentation

◆ ElemExtrema() [1/2]

ElemExtrema::ElemExtrema ( )
inline

Default constructor: sets entires to invalid (not at vertex or edge)

Definition at line 30 of file ElemExtrema.h.

31 : std::pair<unsigned short, unsigned short>(RayTracingCommon::invalid_vertex,
33 {
34 }
static const unsigned short invalid_vertex
Identifier for an invalid vertex index.

◆ ElemExtrema() [2/2]

ElemExtrema::ElemExtrema ( const unsigned short  v1,
const unsigned short  v2 
)
inline

Definition at line 36 of file ElemExtrema.h.

37 : std::pair<unsigned short, unsigned short>(v1, v2)
38 {
39 }

Member Function Documentation

◆ atEdge() [1/2]

bool ElemExtrema::atEdge ( ) const
inline

◆ atEdge() [2/2]

bool ElemExtrema::atEdge ( const unsigned short  v1,
const unsigned short  v2 
) const
inline
Returns
true if at the edge defined by vertices v1 and v2

Definition at line 78 of file ElemExtrema.h.

79 {
80 return second != RayTracingCommon::invalid_vertex &&
81 ((first == v1 && second == v2) || (first == v2 && second == v1));
82 }

◆ atExtrema()

bool ElemExtrema::atExtrema ( ) const
inline

◆ atVertex() [1/2]

bool ElemExtrema::atVertex ( ) const
inline
Returns
true if at a vertex

Definition at line 56 of file ElemExtrema.h.

57 {
59 }

Referenced by TraceRay::exitsElem(), TraceRay::getNeighbors(), isValid(), print(), TEST(), vertex(), and TraceRayTools::withinExtremaOnSide().

◆ atVertex() [2/2]

bool ElemExtrema::atVertex ( const unsigned short  v) const
inline
Returns
true if at vertex v

Definition at line 63 of file ElemExtrema.h.

64 {
65 return first == v && second == RayTracingCommon::invalid_vertex;
66 }
const double v

◆ buildEdge()

std::unique_ptr< const libMesh::Elem > ElemExtrema::buildEdge ( const Elem *  elem) const
Returns
The edge when at an edge

Definition at line 22 of file ElemExtrema.C.

23{
24 mooseAssert(atEdge(), "Did not intersect edge");
25 mooseAssert(first < elem->n_vertices(), "Invalid first vertex for given element");
26 mooseAssert(second < elem->n_vertices(), "Invalid second vertex for given element");
27
28 for (const auto e : elem->edge_index_range())
29 if (elem->is_node_on_edge(first, e) && elem->is_node_on_edge(second, e))
30 return elem->build_edge_ptr(e);
31
32 mooseError("Element does not contain vertices in ElemExtrema");
33}
void mooseError(Args &&... args)
if(subdm)
bool atEdge() const
Definition ElemExtrema.h:71

Referenced by isValid(), RayTracingStudyTest::RayTracingStudyTest(), TEST(), and TraceRayTools::withinEdgeOnSideTempl().

◆ edgeVertices()

const std::pair< unsigned short, unsigned short > & ElemExtrema::edgeVertices ( ) const
inline
Returns
The vertices that contain the edge when at an edge

Definition at line 104 of file ElemExtrema.h.

105 {
106 mooseAssert(atEdge(), "Not at an edge");
107 return *this;
108 }

Referenced by TraceRay::getNeighbors(), and TEST().

◆ invalidate()

void ElemExtrema::invalidate ( )
inline

◆ isInvalid()

bool ElemExtrema::isInvalid ( ) const
inline

◆ isValid()

bool ElemExtrema::isValid ( const Elem *const  elem,
const Point &  point 
) const
Returns
Whether or not the current state (at vertex/edge) is valid for the given elem and point.

This ONLY checks for validity when atExtrema().

Definition at line 49 of file ElemExtrema.C.

50{
51 mooseAssert(first == RayTracingCommon::invalid_vertex || first < elem->n_vertices(),
52 "Invalid first vertex for given element");
53 mooseAssert(second == RayTracingCommon::invalid_vertex || second < elem->n_vertices(),
54 "Invalid second vertex for given element");
55
56 if (atVertex())
57 return vertexPoint(elem).absolute_fuzzy_equals(point);
58 if (elem->dim() == 3 && atEdge())
59 return buildEdge(elem)->contains_point(point);
60
61 return true;
62}
std::unique_ptr< const libMesh::Elem > buildEdge(const Elem *elem) const
Definition ElemExtrema.C:22
const Point & vertexPoint(const libMesh::Elem *elem) const
Definition ElemExtrema.C:16
bool atVertex() const
Definition ElemExtrema.h:56

Referenced by TraceRay::possiblyAddToBoundaryElems(), and TEST().

◆ print()

std::string ElemExtrema::print ( ) const

Prints the current state (at edge, at vertex, not at either)

Definition at line 36 of file ElemExtrema.C.

37{
38 std::stringstream oss;
39 if (atVertex())
40 oss << "at vertex " << vertex();
41 else if (atEdge())
42 oss << "at edge with vertices " << first << " and " << second;
43 else
44 oss << "not at extrema";
45 return oss.str();
46}
unsigned short vertex() const
Definition ElemExtrema.h:96

Referenced by operator<<().

◆ setEdge() [1/2]

void ElemExtrema::setEdge ( const std::pair< unsigned short, unsigned short > &  vertices)
inline

Sets the "at edge" state.

Definition at line 137 of file ElemExtrema.h.

138 {
139 setEdge(vertices.first, vertices.second);
140 }
void setEdge(const unsigned short v1, const unsigned short v2)
Sets the "at edge" state.

◆ setEdge() [2/2]

void ElemExtrema::setEdge ( const unsigned short  v1,
const unsigned short  v2 
)
inline

Sets the "at edge" state.

Definition at line 127 of file ElemExtrema.h.

128 {
129 mooseAssert(v1 != RayTracingCommon::invalid_vertex, "Setting invalid vertex");
130 mooseAssert(v2 != RayTracingCommon::invalid_vertex, "Setting invalid vertex");
131 first = v1;
132 second = v2;
133 }

Referenced by TraceRayTools::intersectTriangle(), setEdge(), TEST(), TraceRayTools::withinEdgeOnSideTempl(), and TraceRayTools::withinEdgeTempl().

◆ setVertex()

void ElemExtrema::setVertex ( const unsigned short  vertex)
inline

Sets the "at vertex" state.

Definition at line 118 of file ElemExtrema.h.

119 {
120 mooseAssert(vertex != RayTracingCommon::invalid_vertex, "Setting invalid vertex");
121 first = vertex;
123 }

Referenced by TraceRay::applyOnInternalBoundary(), TraceRayTools::intersectTriangle(), TraceRayTools::sideIntersectedByLine(), and TEST().

◆ vertex()

unsigned short ElemExtrema::vertex ( ) const
inline
Returns
The vertex ID when at a vertex

Definition at line 96 of file ElemExtrema.h.

97 {
98 mooseAssert(atVertex(), "Not at a vertex");
99 return first;
100 }

Referenced by TraceRay::getNeighbors(), print(), setVertex(), TEST(), and vertexPoint().

◆ vertexPoint()

const Point & ElemExtrema::vertexPoint ( const libMesh::Elem elem) const
Returns
The vertex point when at a vertex

Definition at line 16 of file ElemExtrema.C.

17{
18 return elem->point(vertex());
19}
const Point & point(const unsigned int i) const

Referenced by isValid(), TraceRayTools::sideIntersectedByLine(), and TEST().


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