15 #include "libmesh/utility.h" 16 #include "libmesh/type_tensor.h" 17 #include "libmesh/compare_types.h" 18 #include "libmesh/threads.h" 25 template <
typename T,
typename Map>
44 const std::string &
name,
45 const bool extrapolated_boundary);
52 const std::set<SubdomainID> & sub_ids,
53 const std::string &
name,
54 const bool extrapolated_boundary);
58 const StateArg & state)
const override;
91 template <
typename T,
typename Map>
93 const std::string &
name,
94 const bool extrapolated_boundary)
95 :
Moose::FunctorBase<
T>(
name), _mesh(
mesh), _extrapolated_boundary(extrapolated_boundary)
99 template <
typename T,
typename Map>
101 const std::set<SubdomainID> & sub_ids,
102 const std::string &
name,
103 const bool extrapolated_boundary)
107 _extrapolated_boundary(extrapolated_boundary)
111 template <
typename T,
typename Map>
117 const bool defined_on_elem = hasBlocks(&fi.
elem());
118 const bool defined_on_neighbor = hasBlocks(fi.
neighborPtr());
119 const bool extrapolated = (defined_on_elem + defined_on_neighbor) == 1;
121 mooseAssert(defined_on_elem || defined_on_neighbor,
122 "This shouldn't be called if we aren't defined on either side.");
126 template <
typename T,
typename Map>
133 return hasBlocks(elem->subdomain_id());
136 template <
typename T,
typename Map>
140 return _sub_ids.empty() || _sub_ids.count(sub_id);
143 template <
typename T,
typename Map>
147 const Elem *
const elem = elem_arg.
elem;
149 auto it = this->
find(elem->id());
150 if (it == this->end())
152 if (!_sub_ids.empty() && !_sub_ids.count(elem->subdomain_id()))
153 mooseError(
"Attempted to evaluate CellCenteredMapFunctor '",
155 "' with an element subdomain id of '",
156 elem->subdomain_id(),
157 "' but that subdomain id is not one of the subdomain ids the functor is " 160 mooseError(
"Attempted access into CellCenteredMapFunctor '",
162 "' with a key that does not yet exist in the map. Make sure to fill your " 163 "CellCenteredMapFunctor for all elements you will attempt to access later.");
169 template <
typename T,
typename Map>
174 return (*
this)(elem_point.
makeElem(), state) +
176 this->gradient(elem_point.
makeElem(), state);
179 template <
typename T,
typename Map>
183 const auto & fi = *face.
fi;
185 "this implementation currently only supports linear interpolations");
187 const bool defined_on_elem = hasBlocks(&fi.elem());
188 const bool defined_on_neighbor = hasBlocks(fi.neighborPtr());
189 if (defined_on_elem && defined_on_neighbor)
194 const auto elem_arg = face.
makeElem();
195 const auto elem_value = (*this)(elem_arg, state);
196 if (!_extrapolated_boundary)
199 return elem_value + this->gradient(elem_arg, state) * (fi.faceCentroid() - fi.elemCentroid());
203 mooseAssert(defined_on_neighbor,
"We should be defined on one of the sides");
205 const auto neighbor_value = (*this)(neighbor_arg, state);
206 if (!_extrapolated_boundary)
207 return neighbor_value;
210 return neighbor_value +
211 this->gradient(neighbor_arg, state) * (fi.faceCentroid() - fi.neighborCentroid());
215 template <
typename T,
typename Map>
222 template <
typename T,
typename Map>
229 template <
typename T,
typename Map>
236 template <
typename T,
typename Map>
244 template <
typename T,
typename Map>
KOKKOS_INLINE_FUNCTION const T * find(const T &target, const T *const begin, const T *const end)
const std::set< SubdomainID > _sub_ids
The subdomain IDs that this functor lives on.
const MooseMesh & _mesh
The mesh that this functor lives on.
void mooseError(Args &&... args)
const Elem & elem() const
libMesh::VectorValue< T > greenGaussGradient(const ElemArg &elem_arg, const StateArg &state_arg, const FunctorBase< T > &functor, const bool two_term_boundary_expansion, const MooseMesh &mesh, const bool force_green_gauss=false)
bool isExtrapolatedBoundaryFace(const FaceInfo &fi, const Elem *elem, const StateArg &state) const override
libMesh::CompareTypes< T, T2 >::supertype linearInterpolation(const T &value1, const T2 &value2, const FaceInfo &fi, const bool one_is_elem, const InterpMethod interp_method=InterpMethod::Average)
typename FunctorReturnType< T, FunctorEvaluationKind::Gradient >::type GradientType
GradientType evaluateGradient(const ElemArg &elem_arg, const StateArg &state) const override
const Elem * neighborPtr() const
CellCenteredMapFunctor(const MooseMesh &mesh, const std::string &name, const bool extrapolated_boundary)
Use this constructor when you want the object to live everywhere on the mesh.
MapBase< T1, T2, std::map > Map
bool supportsElemSideQpArg() const override final
const libMesh::Elem * elem
const libMesh::Elem * elem
Moose::FV::LimiterType limiter_type
ElemArg makeNeighbor() const
bool hasBlocks(SubdomainID sub_id) const override
const bool _extrapolated_boundary
ValueType evaluate(const ElemArg &elem_arg, const StateArg &) const override
bool supportsFaceArg() const override final
Point vertex_average() const
A functor whose evaluation relies on querying a map where the keys are element ids and the values cor...