https://mooseframework.inl.gov
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 
17 namespace libMesh
18 {
19 class Elem;
20 }
21 
25 struct ElemExtrema : std::pair<unsigned short, unsigned short>
26 {
31  : std::pair<unsigned short, unsigned short>(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 
87  void invalidate()
88  {
91  }
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 
159 std::ostream & operator<<(std::ostream & os, const ElemExtrema & elem_extrema);
unsigned short vertex() const
Definition: ElemExtrema.h:96
static const unsigned short invalid_vertex
Identifier for an invalid vertex index.
void setEdge(const unsigned short v1, const unsigned short v2)
Sets the "at edge" state.
Definition: ElemExtrema.h:127
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
Helper for defining if at an element&#39;s edge, vertex, or neither.
Definition: ElemExtrema.h:25
std::unique_ptr< const libMesh::Elem > buildEdge(const Elem *elem) const
Definition: ElemExtrema.C:22
bool atEdge(const unsigned short v1, const unsigned short v2) const
Definition: ElemExtrema.h:78
bool isInvalid() const
Definition: ElemExtrema.h:48
The following methods are specializations for using the Parallel::packed_range_* routines for a vecto...
bool isValid(const Elem *const elem, const Point &point) const
Definition: ElemExtrema.C:49
const std::pair< unsigned short, unsigned short > & edgeVertices() const
Definition: ElemExtrema.h:104
std::ostream & operator<<(std::ostream &os, const ElemExtrema &elem_extrema)
Definition: ElemExtrema.C:65
ElemExtrema(const unsigned short v1, const unsigned short v2)
Definition: ElemExtrema.h:36
bool atExtrema() const
Definition: ElemExtrema.h:44
void setEdge(const std::pair< unsigned short, unsigned short > &vertices)
Sets the "at edge" state.
Definition: ElemExtrema.h:137
void setVertex(const unsigned short vertex)
Sets the "at vertex" state.
Definition: ElemExtrema.h:118
static const std::string v
Definition: NS.h:84
void invalidate()
Invalidates the current state.
Definition: ElemExtrema.h:87
ElemExtrema()
Default constructor: sets entires to invalid (not at vertex or edge)
Definition: ElemExtrema.h:30
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