https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ElemExtrema.h
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
10#pragma once
11
12#include "RayTracingCommon.h"
13
14// MOOSE includes
15#include "MooseTypes.h"
16
17namespace libMesh
18{
19class Elem;
20}
21
25struct ElemExtrema : std::pair<unsigned short, unsigned short>
26{
31 : std::pair<unsigned short, unsigned short>(RayTracingCommon::invalid_vertex,
32 RayTracingCommon::invalid_vertex)
33 {
34 }
35
36 ElemExtrema(const unsigned short v1, const unsigned short v2)
37 : std::pair<unsigned short, unsigned short>(v1, v2)
38 {
39 }
40
44 bool atExtrema() const { return first != RayTracingCommon::invalid_vertex; }
48 bool isInvalid() const
49 {
51 }
52
56 bool atVertex() const
57 {
59 }
63 bool atVertex(const unsigned short v) const
64 {
65 return first == v && second == RayTracingCommon::invalid_vertex;
66 }
67
71 bool atEdge() const
72 {
74 }
78 bool atEdge(const unsigned short v1, const unsigned short v2) const
79 {
80 return second != RayTracingCommon::invalid_vertex &&
81 ((first == v1 && second == v2) || (first == v2 && second == v1));
82 }
83
92
96 unsigned short vertex() const
97 {
98 mooseAssert(atVertex(), "Not at a vertex");
99 return first;
100 }
104 const std::pair<unsigned short, unsigned short> & edgeVertices() const
105 {
106 mooseAssert(atEdge(), "Not at an edge");
107 return *this;
108 }
109
113 std::string print() const;
114
118 void setVertex(const unsigned short vertex)
119 {
120 mooseAssert(vertex != RayTracingCommon::invalid_vertex, "Setting invalid vertex");
121 first = vertex;
123 }
127 void setEdge(const unsigned short v1, const unsigned short v2)
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 }
137 void setEdge(const std::pair<unsigned short, unsigned short> & vertices)
138 {
139 setEdge(vertices.first, vertices.second);
140 }
141
145 const Point & vertexPoint(const libMesh::Elem * elem) const;
149 std::unique_ptr<const libMesh::Elem> buildEdge(const Elem * elem) const;
156 bool isValid(const Elem * const elem, const Point & point) const;
157};
158
159std::ostream & operator<<(std::ostream & os, const ElemExtrema & elem_extrema);
std::ostream & operator<<(std::ostream &os, const ElemExtrema &elem_extrema)
Definition ElemExtrema.C:65
const double v
static const unsigned short invalid_vertex
Identifier for an invalid vertex index.
The following methods are specializations for using the Parallel::packed_range_* routines for a vecto...
Helper for defining if at an element's edge, vertex, or neither.
Definition ElemExtrema.h:26
void setEdge(const std::pair< unsigned short, unsigned short > &vertices)
Sets the "at edge" state.
bool isInvalid() const
Definition ElemExtrema.h:48
ElemExtrema()
Default constructor: sets entires to invalid (not at vertex or edge)
Definition ElemExtrema.h:30
std::unique_ptr< const libMesh::Elem > buildEdge(const Elem *elem) const
Definition ElemExtrema.C:22
bool atEdge() const
Definition ElemExtrema.h:71
unsigned short vertex() const
Definition ElemExtrema.h:96
const Point & vertexPoint(const libMesh::Elem *elem) const
Definition ElemExtrema.C:16
bool isValid(const Elem *const elem, const Point &point) const
Definition ElemExtrema.C:49
void invalidate()
Invalidates the current state.
Definition ElemExtrema.h:87
bool atVertex() const
Definition ElemExtrema.h:56
bool atVertex(const unsigned short v) const
Definition ElemExtrema.h:63
std::string print() const
Prints the current state (at edge, at vertex, not at either)
Definition ElemExtrema.C:36
void setVertex(const unsigned short vertex)
Sets the "at vertex" state.
bool atExtrema() const
Definition ElemExtrema.h:44
ElemExtrema(const unsigned short v1, const unsigned short v2)
Definition ElemExtrema.h:36
void setEdge(const unsigned short v1, const unsigned short v2)
Sets the "at edge" state.
const std::pair< unsigned short, unsigned short > & edgeVertices() const
bool atEdge(const unsigned short v1, const unsigned short v2) const
Definition ElemExtrema.h:78