16 #include "libmesh/elem.h" 40 template <
typename ActionFunctor>
48 mooseAssert(elem.active(),
"We should never call this method with an inactive element");
50 for (
const auto side : elem.side_index_range())
52 const Elem *
const candidate_neighbor = elem.neighbor_ptr(side);
56 std::set<const Elem *> neighbors;
58 const bool inactive_neighbor_detected =
59 candidate_neighbor ? !candidate_neighbor->active() :
false;
62 if (inactive_neighbor_detected)
65 mooseAssert(candidate_neighbor->has_children(),
"We should have children");
67 const auto candidate_neighbor_side = candidate_neighbor->which_neighbor_am_i(&elem);
69 for (
const auto child_num :
make_range(candidate_neighbor->n_children()))
70 if (candidate_neighbor->is_child_on_side(child_num, candidate_neighbor_side))
72 const Elem *
const child = candidate_neighbor->child_ptr(child_num);
73 mooseAssert(child->level() - elem.level() == 1,
"The math doesn't work out here.");
74 mooseAssert(child->has_neighbor(&elem),
"Elem should be a neighbor of this child.");
75 mooseAssert(child->active(),
76 "We shouldn't have greater than a face mismatch level of one");
77 neighbors.insert(child);
81 neighbors.insert(candidate_neighbor);
83 for (
const Elem *
const neighbor : neighbors)
86 elem_has_info ?
mesh.faceInfo(&elem, side)
87 :
mesh.faceInfo(neighbor, neighbor->which_neighbor_am_i(&elem));
89 mooseAssert(fi,
"We should have found a FaceInfo");
90 mooseAssert(elem_has_info ? &elem == &fi->
elem() : &elem == fi->
neighborPtr(),
91 "Doesn't seem like we understand how this FaceInfo thing is working");
95 "Remote element detected. This indicates that you have insufficient geometric " 96 "ghosting. Please contact your application developers.");
97 mooseAssert(elem_has_info ? neighbor == fi->
neighborPtr() : neighbor == &fi->
elem(),
98 "Doesn't seem like we understand how this FaceInfo thing is working");
101 const Point elem_normal = elem_has_info ? fi->
normal() : Point(-fi->
normal());
106 const Point surface_vector = elem_normal * fi->
faceArea() * coord;
108 act(elem, neighbor, fi, surface_vector, coord, elem_has_info);
128 template <
typename FVVar>
129 std::tuple<const Elem *, const Elem *, bool>
132 auto ft = fi.
faceType(std::make_pair(var.number(), var.sys().number()));
137 "Finite volume variable " << var.name()
138 <<
" does not exist on both sides of the face despite " 139 "what the FaceInfo is telling us.");
141 ? var.hasBlocks(fi.
elem().subdomain_id()) &&
144 "Finite volume variable " << var.name()
145 <<
" does not exist on or only on the elem side of the " 146 "face despite what the FaceInfo is telling us.");
149 !var.hasBlocks(fi.
elem().subdomain_id())
151 "Finite volume variable " << var.name()
152 <<
" does not exist on or only on the neighbor side of the " 153 "face despite what the FaceInfo is telling us.");
155 const bool one_is_elem =
157 const Elem *
const elem_one = one_is_elem ? &fi.
elem() : fi.
neighborPtr();
158 mooseAssert(elem_one,
"This elem should be non-null!");
159 const Elem *
const elem_two = one_is_elem ? fi.
neighborPtr() : &fi.
elem();
161 return std::make_tuple(elem_one, elem_two, one_is_elem);
void loopOverElemFaceInfo(const Elem &elem, const MooseMesh &mesh, ActionFunctor &act, const Moose::CoordinateSystemType coord_type, const unsigned int rz_radial_coord=libMesh::invalid_uint)
bool elemHasFaceInfo(const Elem &elem, const Elem *const neighbor)
This function infers based on elements if the faceinfo between them belongs to the element or not...
const unsigned int invalid_uint
void coordTransformFactor(const P &point, C &factor, const Moose::CoordinateSystemType coord_type, const unsigned int rz_radial_coord=libMesh::invalid_uint)
compute a coordinate transformation factor
std::tuple< const Elem *, const Elem *, bool > determineElemOneAndTwo(const FaceInfo &fi, const FVVar &var)
This utility determines element one and element two given a FaceInfo fi and variable var...
const Elem & elem() const
const Point & faceCentroid() const
Returns the coordinates of the face centroid.
Real faceArea() const
Returns the face area of face id.
This data structure is used to store geometric and variable related metadata about each cell face in ...
const Elem * neighborPtr() const
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
const Point & normal() const
Returns the unit normal vector for the face oriented outward from the face's elem element...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
IntRange< T > make_range(T beg, T end)
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
This class provides variable solution values for other classes/objects to bind to when looping over f...
This class provides variable solution interface for linear finite volume problems.
VarFaceNeighbors faceType(const std::pair< unsigned int, unsigned int > &var_sys) const
Returns which side(s) the given variable-system number pair is defined on for this face...
const RemoteElem * remote_elem