https://mooseframework.inl.gov
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) More...
 
 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. More...
 
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) More...
 
void setVertex (const unsigned short vertex)
 Sets the "at vertex" state. More...
 
void setEdge (const unsigned short v1, const unsigned short v2)
 Sets the "at edge" state. More...
 
void setEdge (const std::pair< unsigned short, unsigned short > &vertices)
 Sets the "at edge" state. More...
 
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
Returns
true if at an edge

Definition at line 71 of file ElemExtrema.h.

Referenced by buildEdge(), edgeVertices(), TraceRay::findExternalBoundarySide(), TraceRayTools::intersectQuad(), isValid(), print(), TEST(), and TraceRay::trace().

72  {
74  }
static const unsigned short invalid_vertex
Identifier for an invalid vertex index.

◆ 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  }
static const unsigned short invalid_vertex
Identifier for an invalid vertex index.

◆ atExtrema()

bool ElemExtrema::atExtrema ( ) const
inline
Returns
true if at the extrema (edge or vertex)

Definition at line 44 of file ElemExtrema.h.

Referenced by TraceRay::applyOnExternalBoundary(), TraceRay::applyOnInternalBoundary(), TraceRay::findExternalBoundarySide(), TraceRay::getNeighbors(), TraceRay::onTrajectoryChanged(), TEST(), and TraceRay::trace().

44 { return first != RayTracingCommon::invalid_vertex; }
static const unsigned short invalid_vertex
Identifier for an invalid vertex index.

◆ atVertex() [1/2]

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

Definition at line 56 of file ElemExtrema.h.

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

57  {
59  }
static const unsigned short invalid_vertex
Identifier for an invalid vertex index.

◆ 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  }
static const unsigned short invalid_vertex
Identifier for an invalid vertex index.
static const std::string v
Definition: NS.h:84

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

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

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)
bool atEdge() const
Definition: ElemExtrema.h:71

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

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

105  {
106  mooseAssert(atEdge(), "Not at an edge");
107  return *this;
108  }
bool atEdge() const
Definition: ElemExtrema.h:71

◆ invalidate()

void ElemExtrema::invalidate ( )
inline

Invalidates the current state.

Definition at line 87 of file ElemExtrema.h.

Referenced by TraceRay::applyOnInternalBoundary(), TraceRay::exitsElem(), BoundingBoxIntersectionHelper::intersection(), TraceRayTools::intersectQuad(), TraceRay::moveThroughNeighbor(), TEST(), and TraceRay::trace().

88  {
91  }
static const unsigned short invalid_vertex
Identifier for an invalid vertex index.

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

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

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 }
static const unsigned short invalid_vertex
Identifier for an invalid vertex index.
std::unique_ptr< const libMesh::Elem > buildEdge(const Elem *elem) const
Definition: ElemExtrema.C:22
bool atVertex() const
Definition: ElemExtrema.h:56
bool atEdge() const
Definition: ElemExtrema.h:71
const Point & vertexPoint(const libMesh::Elem *elem) const
Definition: ElemExtrema.C:16

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

Referenced by operator<<().

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
bool atVertex() const
Definition: ElemExtrema.h:56
bool atEdge() const
Definition: ElemExtrema.h:71

◆ setEdge() [1/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.

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

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  }
static const unsigned short invalid_vertex
Identifier for an invalid vertex index.

◆ setEdge() [2/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.
Definition: ElemExtrema.h:127

◆ setVertex()

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

Sets the "at vertex" state.

Definition at line 118 of file ElemExtrema.h.

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

119  {
120  mooseAssert(vertex != RayTracingCommon::invalid_vertex, "Setting invalid vertex");
121  first = vertex;
123  }
unsigned short vertex() const
Definition: ElemExtrema.h:96
static const unsigned short invalid_vertex
Identifier for an invalid vertex index.

◆ vertex()

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

Definition at line 96 of file ElemExtrema.h.

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

97  {
98  mooseAssert(atVertex(), "Not at a vertex");
99  return first;
100  }
bool atVertex() const
Definition: ElemExtrema.h:56

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

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

17 {
18  return elem->point(vertex());
19 }
unsigned short vertex() const
Definition: ElemExtrema.h:96
const Point & point(const unsigned int i) const

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