https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
PiecewiseByBlockLambdaFunctor< T > Class Template Reference

A material property that is evaluated on-the-fly via calls to various overloads of operator() More...

#include <PiecewiseByBlockLambdaFunctor.h>

Inheritance diagram for PiecewiseByBlockLambdaFunctor< T >:
[legend]

Public Types

using FunctorType = FunctorBase< T >
 
using ValueType = T
 
using GradientType = typename FunctorReturnType< T, FunctorEvaluationKind::Gradient >::type
 This rigmarole makes it so that a user can create functors that return containers (std::vector, std::array).
 
using DotType = ValueType
 

Public Member Functions

template<typename PolymorphicLambda >
 PiecewiseByBlockLambdaFunctor (const std::string &name, PolymorphicLambda my_lammy, const std::set< ExecFlagType > &clearance_schedule, const MooseMesh &mesh, const std::set< SubdomainID > &block_ids)
 
template<typename PolymorphicLambda >
void setFunctor (const MooseMesh &mesh, const std::set< SubdomainID > &block_ids, PolymorphicLambda my_lammy)
 Set the functor that will be used in calls to evaluate overloads.
 
virtual ~PiecewiseByBlockLambdaFunctor ()=default
 
bool isExtrapolatedBoundaryFace (const FaceInfo &fi, const Elem *elem, const Moose::StateArg &time) const override
 Returns whether this (sided) face is an extrapolated boundary face for this functor.
 
bool hasBlocks (SubdomainID id) const override
 Returns whether the functor is defined on this block.
 
bool supportsFaceArg () const override final
 Whether this functor supports evaluation with FaceArg.
 
bool supportsElemSideQpArg () const override final
 Whether this functor supports evaluation with ElemSideQpArg.
 
template<FunctorEvaluationKind FET, typename Space , typename State >
FunctorReturnType< T, FET >::type genericEvaluate (const Space &r, const State &state) const
 Perform a generic evaluation based on the supplied template argument FET and supplied spatial and temporal arguments.
 
const MooseFunctorName & functorName () const
 Return the functor name.
 
virtual void residualSetup () override
 
virtual void jacobianSetup () override
 
virtual void timestepSetup () override
 
virtual void customSetup (const ExecFlagType &exec_type) override
 
void setCacheClearanceSchedule (const std::set< ExecFlagType > &clearance_schedule)
 Set how often to clear the functor evaluation cache.
 
bool isInternalFace (const FaceInfo &) const
 Returns true if the face is an internal face.
 
virtual bool isConstant () const
 Returns true if this functor is a constant.
 
virtual bool hasFaceSide (const FaceInfo &fi, const bool fi_elem_side) const override
 
void checkFace (const Moose::FaceArg &face) const
 Examines the incoming face argument.
 
ValueType operator() (const ElemArg &elem, const StateArg &state) const
 Same as their evaluate overloads with the same arguments but allows for caching implementation.
 
ValueType operator() (const FaceArg &face, const StateArg &state) const
 
ValueType operator() (const ElemQpArg &qp, const StateArg &state) const
 
ValueType operator() (const ElemSideQpArg &qp, const StateArg &state) const
 
ValueType operator() (const ElemPointArg &elem_point, const StateArg &state) const
 
ValueType operator() (const NodeArg &node, const StateArg &state) const
 
GradientType gradient (const ElemArg &elem, const StateArg &state) const
 Same as their evaluateGradient overloads with the same arguments but allows for caching implementation.
 
GradientType gradient (const FaceArg &face, const StateArg &state) const
 
GradientType gradient (const ElemQpArg &qp, const StateArg &state) const
 
GradientType gradient (const ElemSideQpArg &qp, const StateArg &state) const
 
GradientType gradient (const ElemPointArg &elem_point, const StateArg &state) const
 
GradientType gradient (const NodeArg &node, const StateArg &state) const
 
DotType dot (const ElemArg &elem, const StateArg &state) const
 Same as their evaluateDot overloads with the same arguments but allows for caching implementation.
 
DotType dot (const FaceArg &face, const StateArg &state) const
 
DotType dot (const ElemQpArg &qp, const StateArg &state) const
 
DotType dot (const ElemSideQpArg &qp, const StateArg &state) const
 
DotType dot (const ElemPointArg &elem_point, const StateArg &state) const
 
DotType dot (const NodeArg &node, const StateArg &state) const
 
GradientType gradDot (const ElemArg &elem, const StateArg &state) const
 Same as their evaluateGradDot overloads with the same arguments but allows for caching implementation.
 
GradientType gradDot (const FaceArg &face, const StateArg &state) const
 
GradientType gradDot (const ElemQpArg &qp, const StateArg &state) const
 
GradientType gradDot (const ElemSideQpArg &qp, const StateArg &state) const
 
GradientType gradDot (const ElemPointArg &elem_point, const StateArg &state) const
 
GradientType gradDot (const NodeArg &node, const StateArg &state) const
 

Protected Types

using ElemFn = std::function< T(const Moose::ElemArg &, const Moose::StateArg &)>
 
using FaceFn = std::function< T(const Moose::FaceArg &, const Moose::StateArg &)>
 
using ElemQpFn = std::function< T(const Moose::ElemQpArg &, const Moose::StateArg &)>
 
using ElemSideQpFn = std::function< T(const Moose::ElemSideQpArg &, const Moose::StateArg &)>
 
using ElemPointFn = std::function< T(const Moose::ElemPointArg &, const Moose::StateArg &)>
 
using NodeFn = std::function< T(const Moose::NodeArg &, const Moose::StateArg &)>
 

Protected Member Functions

ValueType evaluate (const Moose::ElemArg &elem_arg, const Moose::StateArg &time) const override
 Evaluate the functor with a given element.
 
ValueType evaluate (const Moose::FaceArg &face, const Moose::StateArg &time) const override
 
ValueType evaluate (const Moose::ElemQpArg &elem_qp, const Moose::StateArg &time) const override
 
ValueType evaluate (const Moose::ElemSideQpArg &elem_side_qp, const Moose::StateArg &time) const override
 
ValueType evaluate (const Moose::ElemPointArg &elem_point, const Moose::StateArg &time) const override
 Evaluate the functor with a given element and point.
 
ValueType evaluate (const Moose::NodeArg &node_arg, const Moose::StateArg &time) const override
 
GradientType evaluateGradient (const Moose::ElemArg &elem_arg, const Moose::StateArg &) const override
 Evaluate the functor gradient with a given element.
 
GradientType evaluateGradient (const Moose::FaceArg &face_arg, const Moose::StateArg &) const override
 
Functor evaluation routines

These methods are all for evaluating functors with different kinds of spatial arguments.

Each of these methods also takes a state argument. For a description of the state argument, please see the StateArg doxygen

virtual GradientType evaluateGradient (const ElemQpArg &, const StateArg &) const
 
virtual GradientType evaluateGradient (const ElemSideQpArg &, const StateArg &) const
 
virtual GradientType evaluateGradient (const ElemPointArg &, const StateArg &) const
 Evaluate the functor gradient with a given element and point.
 
virtual GradientType evaluateGradient (const NodeArg &, const StateArg &) const
 
virtual DotType evaluateDot (const ElemArg &, const StateArg &) const
 Evaluate the functor time derivative with a given element.
 
virtual DotType evaluateDot (const FaceArg &, const StateArg &) const
 
virtual DotType evaluateDot (const ElemQpArg &, const StateArg &) const
 
virtual DotType evaluateDot (const ElemSideQpArg &, const StateArg &) const
 
virtual DotType evaluateDot (const ElemPointArg &, const StateArg &) const
 Evaluate the functor time derivative with a given element and point.
 
virtual DotType evaluateDot (const NodeArg &, const StateArg &) const
 
virtual GradientType evaluateGradDot (const ElemArg &, const StateArg &) const
 Evaluate the functor gradient-dot with a given element.
 
virtual GradientType evaluateGradDot (const FaceArg &, const StateArg &) const
 
virtual GradientType evaluateGradDot (const ElemQpArg &, const StateArg &) const
 
virtual GradientType evaluateGradDot (const ElemSideQpArg &, const StateArg &) const
 
virtual GradientType evaluateGradDot (const ElemPointArg &, const StateArg &) const
 Evaluate the functor gradient-dot with a given element and point.
 
virtual GradientType evaluateGradDot (const NodeArg &, const StateArg &) const
 

Private Member Functions

template<typename C >
void subdomainErrorMessage (SubdomainID sub_id, const std::unordered_map< SubdomainID, C > &functors) const
 Provide a useful error message about lack of functor material property on the provided subdomain sub_id.
 
std::string subdomainNameAndID (SubdomainID sub_id) const
 Format a subdomain ID with its name, when available.
 
void clearCacheData ()
 clear cache data
 
template<typename SpaceArg , typename StateArg >
ValueType queryQpCache (unsigned int qp, const libMesh::QBase &qrule, std::vector< std::pair< bool, T > > &qp_cache_data, const SpaceArg &space, const StateArg &state) const
 check a qp cache and if invalid then evaluate
 
template<typename SpaceArg >
ValueType queryFVArgCache (std::map< SpaceArg, ValueType > &cache_data, const SpaceArg &space) const
 check a finite volume spatial argument cache and if invalid then evaluate
 

Private Attributes

std::unordered_map< SubdomainID, ElemFn_elem_functor
 Functors that return element average values (or cell centroid values or whatever the implementer wants to return for a given element argument)
 
std::unordered_map< SubdomainID, FaceFn_face_functor
 Functors that return the property value on the requested side of the face (e.g.
 
std::unordered_map< SubdomainID, ElemQpFn_elem_qp_functor
 Functors that will evaluate elements at quadrature points.
 
std::unordered_map< SubdomainID, ElemSideQpFn_elem_side_qp_functor
 Functors that will evaluate elements at side quadrature points.
 
std::unordered_map< SubdomainID, ElemPointFn_elem_point_functor
 Functors that return evaluations at an arbitrary physical point in an element.
 
std::unordered_map< SubdomainID, NodeFn_node_functor
 Functors that return nodal values.
 
const MooseMesh_mesh
 The mesh that this functor operates on.
 
std::set< ExecFlagType_clearance_schedule
 How often to clear the material property cache.
 
bool _always_evaluate
 Boolean to check if we always need evaluation.
 
dof_id_type _current_qp_map_key = libMesh::DofObject::invalid_id
 Current key for qp map cache.
 
std::vector< std::pair< bool, ValueType > > * _current_qp_map_value = nullptr
 Current value for qp map cache.
 
std::unordered_map< dof_id_type, std::vector< std::pair< bool, ValueType > > > _qp_to_value
 Cached element quadrature point functor property evaluations.
 
dof_id_type _current_side_qp_map_key = libMesh::DofObject::invalid_id
 Current key for side-qp map cache.
 
std::vector< std::vector< std::pair< bool, ValueType > > > * _current_side_qp_map_value
 Current value for side-qp map cache.
 
std::unordered_map< dof_id_type, std::vector< std::vector< std::pair< bool, ValueType > > > > _side_qp_to_value
 Cached element quadrature point functor property evaluations.
 
std::map< ElemArg, ValueType_elem_arg_to_value
 Map from element arguments to their cached evaluations.
 
std::map< FaceArg, ValueType_face_arg_to_value
 Map from face arguments to their cached evaluations.
 
std::map< NodeArg, ValueType_node_arg_to_value
 Map from nodal arguments to their cached evaluations.
 
MooseFunctorName _functor_name
 name of the functor
 

Detailed Description

template<typename T>
class PiecewiseByBlockLambdaFunctor< T >

A material property that is evaluated on-the-fly via calls to various overloads of operator()

Definition at line 32 of file PiecewiseByBlockLambdaFunctor.h.

Member Typedef Documentation

◆ DotType

template<typename T >
using Moose::FunctorBase< T >::DotType = ValueType
inherited

Definition at line 150 of file MooseFunctor.h.

◆ ElemFn

template<typename T >
using PiecewiseByBlockLambdaFunctor< T >::ElemFn = std::function<T(const Moose::ElemArg &, const Moose::StateArg &)>
protected

Definition at line 70 of file PiecewiseByBlockLambdaFunctor.h.

◆ ElemPointFn

template<typename T >
using PiecewiseByBlockLambdaFunctor< T >::ElemPointFn = std::function<T(const Moose::ElemPointArg &, const Moose::StateArg &)>
protected

Definition at line 74 of file PiecewiseByBlockLambdaFunctor.h.

◆ ElemQpFn

template<typename T >
using PiecewiseByBlockLambdaFunctor< T >::ElemQpFn = std::function<T(const Moose::ElemQpArg &, const Moose::StateArg &)>
protected

Definition at line 72 of file PiecewiseByBlockLambdaFunctor.h.

◆ ElemSideQpFn

template<typename T >
using PiecewiseByBlockLambdaFunctor< T >::ElemSideQpFn = std::function<T(const Moose::ElemSideQpArg &, const Moose::StateArg &)>
protected

Definition at line 73 of file PiecewiseByBlockLambdaFunctor.h.

◆ FaceFn

template<typename T >
using PiecewiseByBlockLambdaFunctor< T >::FaceFn = std::function<T(const Moose::FaceArg &, const Moose::StateArg &)>
protected

Definition at line 71 of file PiecewiseByBlockLambdaFunctor.h.

◆ FunctorType

template<typename T >
using Moose::FunctorBase< T >::FunctorType = FunctorBase<T>
inherited

Definition at line 140 of file MooseFunctor.h.

◆ GradientType

template<typename T >
using Moose::FunctorBase< T >::GradientType = typename FunctorReturnType<T, FunctorEvaluationKind::Gradient>::type
inherited

This rigmarole makes it so that a user can create functors that return containers (std::vector, std::array).

This logic will make it such that if a user requests a functor type T that is a container of algebraic types, for example Reals, then the GradientType will be a container of the gradients of those algebraic types, in this example VectorValue<Reals>. So if T is std::vector<Real>, then GradientType will be std::vector<VectorValue<Real>>. As another example: T = std::array<VectorValue<Real>, 1> -> GradientType = std::array<TensorValue<Real>, 1>

Definition at line 149 of file MooseFunctor.h.

◆ NodeFn

template<typename T >
using PiecewiseByBlockLambdaFunctor< T >::NodeFn = std::function<T(const Moose::NodeArg &, const Moose::StateArg &)>
protected

Definition at line 75 of file PiecewiseByBlockLambdaFunctor.h.

◆ ValueType

template<typename T >
using Moose::FunctorBase< T >::ValueType = T
inherited

Definition at line 141 of file MooseFunctor.h.

Constructor & Destructor Documentation

◆ PiecewiseByBlockLambdaFunctor()

template<typename T >
template<typename PolymorphicLambda >
PiecewiseByBlockLambdaFunctor< T >::PiecewiseByBlockLambdaFunctor ( const std::string &  name,
PolymorphicLambda  my_lammy,
const std::set< ExecFlagType > &  clearance_schedule,
const MooseMesh mesh,
const std::set< SubdomainID > &  block_ids 
)

Definition at line 134 of file PiecewiseByBlockLambdaFunctor.h.

140 : Moose::FunctorBase<T>(name, clearance_schedule), _mesh(mesh)
141{
142 setFunctor(mesh, block_ids, my_lammy);
143}
Base class template for functor objects.
void setFunctor(const MooseMesh &mesh, const std::set< SubdomainID > &block_ids, PolymorphicLambda my_lammy)
Set the functor that will be used in calls to evaluate overloads.
const MooseMesh & _mesh
The mesh that this functor operates on.

◆ ~PiecewiseByBlockLambdaFunctor()

template<typename T >
virtual PiecewiseByBlockLambdaFunctor< T >::~PiecewiseByBlockLambdaFunctor ( )
virtualdefault

Member Function Documentation

◆ checkFace()

template<typename T >
void Moose::FunctorBase< T >::checkFace ( const Moose::FaceArg face) const
inherited

Examines the incoming face argument.

If the face argument producer (residual object, postprocessor, etc.) did not indicate a sidedness to the face, e.g. if the face_side member of the FaceArg is nullptr, then we may "modify" the sidedness of the argument if we are only defined on one side of the face. If the face argument producer \emph has indicated a sidedness and we are not defined on that side, then we will error

Parameters
faceThe face argument created by the face argument producer, likely a residual object
Returns
A face with possibly changed sidedness depending on whether we aren't defined on both sides of the face

Definition at line 738 of file MooseFunctor.h.

743{
744#if DEBUG
745 const Elem * const elem = face.face_side;
746 const FaceInfo * const fi = face.fi;
747 mooseAssert(fi, "face info should be non-null");
748 bool check_elem_def = false;
749 bool check_neighbor_def = false;
750 // We check if the functor is defined on both sides of the face
751 if (!elem)
752 {
753 if (!hasFaceSide(*fi, true))
754 check_neighbor_def = true;
755 else if (!hasFaceSide(*fi, false))
756 check_elem_def = true;
757 }
758 else if (elem == fi->elemPtr())
759 check_elem_def = true;
760 else
761 {
762 mooseAssert(elem == fi->neighborPtr(), "This has to match something");
763 check_neighbor_def = true;
764 }
765
766 if (check_elem_def && !hasFaceSide(*fi, true))
767 {
768 std::string additional_message = "It is not defined on the neighbor side either.";
769 if (hasFaceSide(*fi, false))
770 additional_message = "It is however defined on the neighbor side.";
771 additional_message += " Face centroid: " + Moose::stringify(fi->faceCentroid());
773 " is not defined on the element side of the face information, but a face argument "
774 "producer "
775 "(e.g. residual object, postprocessor, etc.) has requested evaluation there.\n",
776 additional_message);
777 }
778 if (check_neighbor_def && !hasFaceSide(*fi, false))
779 {
780 std::string additional_message = "It is not defined on the element side either.";
781 if (hasFaceSide(*fi, true))
782 additional_message = "It is however defined on the element side.";
783 additional_message += " Face centroid: " + Moose::stringify(fi->faceCentroid());
786 " is not defined on the neighbor side of the face information, but a face argument "
787 "producer (e.g. residual object, postprocessor, etc.) has requested evaluation there.\n",
788 additional_message);
789 }
790#endif
791}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
This data structure is used to store geometric and variable related metadata about each cell face in ...
Definition FaceInfo.h:38
const Elem * neighborPtr() const
Definition FaceInfo.h:88
const Elem * elemPtr() const
Definition FaceInfo.h:86
const Point & faceCentroid() const
Returns the coordinates of the face centroid.
Definition FaceInfo.h:75
virtual bool hasFaceSide(const FaceInfo &fi, const bool fi_elem_side) const override
MooseFunctorName _functor_name
name of the functor
std::string stringify(const T &t)
conversion to string
Definition Conversion.h:64
const libMesh::Elem * face_side
A member that can be used to indicate whether there is a sidedness to this face.
const FaceInfo * fi
a face information object which defines our location in space

◆ clearCacheData()

template<typename T >
void Moose::FunctorBase< T >::clearCacheData ( )
privateinherited

clear cache data

Definition at line 795 of file MooseFunctor.h.

796{
797 for (auto & map_pr : _qp_to_value)
798 for (auto & pr : map_pr.second)
799 pr.first = false;
800
801 for (auto & map_pr : _side_qp_to_value)
802 {
803 auto & side_vector = map_pr.second;
804 for (auto & qp_vector : side_vector)
805 for (auto & pr : qp_vector)
806 pr.first = false;
807 }
808
810 _current_qp_map_value = nullptr;
813
814 _elem_arg_to_value.clear();
815 _face_arg_to_value.clear();
816 _node_arg_to_value.clear();
817}
for(PetscInt i=0;i< nvars;++i)
dof_id_type _current_qp_map_key
Current key for qp map cache.
std::map< ElemArg, ValueType > _elem_arg_to_value
Map from element arguments to their cached evaluations.
std::unordered_map< dof_id_type, std::vector< std::pair< bool, ValueType > > > _qp_to_value
Cached element quadrature point functor property evaluations.
std::map< FaceArg, ValueType > _face_arg_to_value
Map from face arguments to their cached evaluations.
std::vector< std::vector< std::pair< bool, ValueType > > > * _current_side_qp_map_value
Current value for side-qp map cache.
std::map< NodeArg, ValueType > _node_arg_to_value
Map from nodal arguments to their cached evaluations.
std::vector< std::pair< bool, ValueType > > * _current_qp_map_value
Current value for qp map cache.
dof_id_type _current_side_qp_map_key
Current key for side-qp map cache.
std::unordered_map< dof_id_type, std::vector< std::vector< std::pair< bool, ValueType > > > > _side_qp_to_value
Cached element quadrature point functor property evaluations.
static constexpr dof_id_type invalid_id

◆ customSetup()

template<typename T >
void Moose::FunctorBase< T >::customSetup ( const ExecFlagType exec_type)
overridevirtualinherited

Implements Moose::FunctorAbstract.

Reimplemented in Function.

Definition at line 845 of file MooseFunctor.h.

846{
847 if (_clearance_schedule.count(exec_type))
849}
void clearCacheData()
clear cache data
std::set< ExecFlagType > _clearance_schedule
How often to clear the material property cache.

Referenced by Function::customSetup().

◆ dot() [1/6]

template<typename T >
FunctorBase< T >::DotType Moose::FunctorBase< T >::dot ( const ElemArg elem,
const StateArg state 
) const
inherited

Same as their evaluateDot overloads with the same arguments but allows for caching implementation.

These are the methods a user will call in their code

Definition at line 896 of file MooseFunctor.h.

897{
898 return evaluateDot(elem, state);
899}
virtual DotType evaluateDot(const ElemArg &, const StateArg &) const
Evaluate the functor time derivative with a given element.

Referenced by FVFunctorTimeKernel::computeQpResidual(), Moose::ADWrapperFunctor< T >::evaluateDot(), Moose::ADWrapperFunctor< T >::evaluateDot(), Moose::ADWrapperFunctor< T >::evaluateDot(), Moose::ADWrapperFunctor< T >::evaluateDot(), Moose::ADWrapperFunctor< T >::evaluateDot(), and Moose::ADWrapperFunctor< T >::evaluateDot().

◆ dot() [2/6]

template<typename T >
FunctorBase< T >::DotType Moose::FunctorBase< T >::dot ( const ElemPointArg elem_point,
const StateArg state 
) const
inherited

Definition at line 925 of file MooseFunctor.h.

926{
927 return evaluateDot(elem_point, state);
928}

◆ dot() [3/6]

template<typename T >
FunctorBase< T >::DotType Moose::FunctorBase< T >::dot ( const ElemQpArg qp,
const StateArg state 
) const
inherited

Definition at line 911 of file MooseFunctor.h.

912{
913 return evaluateDot(elem_qp, state);
914}

◆ dot() [4/6]

template<typename T >
FunctorBase< T >::DotType Moose::FunctorBase< T >::dot ( const ElemSideQpArg qp,
const StateArg state 
) const
inherited

Definition at line 918 of file MooseFunctor.h.

919{
920 return evaluateDot(elem_side_qp, state);
921}

◆ dot() [5/6]

template<typename T >
FunctorBase< T >::DotType Moose::FunctorBase< T >::dot ( const FaceArg face,
const StateArg state 
) const
inherited

Definition at line 903 of file MooseFunctor.h.

904{
905 checkFace(face);
906 return evaluateDot(face, state);
907}
void checkFace(const Moose::FaceArg &face) const
Examines the incoming face argument.

◆ dot() [6/6]

template<typename T >
FunctorBase< T >::DotType Moose::FunctorBase< T >::dot ( const NodeArg node,
const StateArg state 
) const
inherited

Definition at line 932 of file MooseFunctor.h.

933{
934 return evaluateDot(node, state);
935}

◆ evaluate() [1/6]

template<typename T >
PiecewiseByBlockLambdaFunctor< T >::ValueType PiecewiseByBlockLambdaFunctor< T >::evaluate ( const Moose::ElemArg elem,
const Moose::StateArg state 
) const
overrideprotectedvirtual

Evaluate the functor with a given element.

Some example implementations of this method could compute an element-average or evaluate at the element centroid

Implements Moose::FunctorBase< T >.

Definition at line 249 of file PiecewiseByBlockLambdaFunctor.h.

251{
252 const Elem * const elem = elem_arg.elem;
253 mooseAssert(elem && elem != libMesh::remote_elem,
254 "The element must be non-null and non-remote in functor material properties");
255 auto it = _elem_functor.find(elem->subdomain_id());
256 if (it == _elem_functor.end())
257 subdomainErrorMessage(elem->subdomain_id(), _elem_functor);
258
259 return it->second(elem_arg, time);
260}
void subdomainErrorMessage(SubdomainID sub_id, const std::unordered_map< SubdomainID, C > &functors) const
Provide a useful error message about lack of functor material property on the provided subdomain sub_...
std::unordered_map< SubdomainID, ElemFn > _elem_functor
Functors that return element average values (or cell centroid values or whatever the implementer want...
const RemoteElem * remote_elem
const libMesh::Elem * elem

◆ evaluate() [2/6]

template<typename T >
PiecewiseByBlockLambdaFunctor< T >::ValueType PiecewiseByBlockLambdaFunctor< T >::evaluate ( const Moose::ElemPointArg elem_point,
const Moose::StateArg state 
) const
overrideprotectedvirtual

Evaluate the functor with a given element and point.

Some example implementations of this method could perform a two-term Taylor expansion using cell-centered value and gradient

Implements Moose::FunctorBase< T >.

Definition at line 312 of file PiecewiseByBlockLambdaFunctor.h.

314{
315 const Elem * const elem = elem_point_arg.elem;
316 mooseAssert(elem && elem != libMesh::remote_elem,
317 "The element must be non-null and non-remote in functor material properties");
318 auto it = _elem_point_functor.find(elem->subdomain_id());
319 if (it == _elem_point_functor.end())
320 subdomainErrorMessage(elem->subdomain_id(), _elem_point_functor);
321
322 return it->second(elem_point_arg, time);
323}
std::unordered_map< SubdomainID, ElemPointFn > _elem_point_functor
Functors that return evaluations at an arbitrary physical point in an element.

◆ evaluate() [3/6]

template<typename T >
PiecewiseByBlockLambdaFunctor< T >::ValueType PiecewiseByBlockLambdaFunctor< T >::evaluate ( const Moose::ElemQpArg qp,
const Moose::StateArg state 
) const
overrideprotectedvirtual
Parameters
qpSee the ElemQpArg doxygen
stateSee the StateArg doxygen
Returns
The functor evaluated at the requested state and space

Implements Moose::FunctorBase< T >.

Definition at line 286 of file PiecewiseByBlockLambdaFunctor.h.

288{
289 const auto sub_id = elem_qp.elem->subdomain_id();
290 auto it = _elem_qp_functor.find(sub_id);
291 if (it == _elem_qp_functor.end())
293
294 return it->second(elem_qp, time);
295}
std::unordered_map< SubdomainID, ElemQpFn > _elem_qp_functor
Functors that will evaluate elements at quadrature points.

◆ evaluate() [4/6]

template<typename T >
PiecewiseByBlockLambdaFunctor< T >::ValueType PiecewiseByBlockLambdaFunctor< T >::evaluate ( const Moose::ElemSideQpArg side_qp,
const Moose::StateArg state 
) const
overrideprotectedvirtual
Parameters
side_qpSee the ElemSideQpArg doxygen
stateSee the StateArg doxygen
Returns
The functor evaluated at the requested state and space

Implements Moose::FunctorBase< T >.

Definition at line 299 of file PiecewiseByBlockLambdaFunctor.h.

301{
302 const auto sub_id = elem_side_qp.elem->subdomain_id();
303 auto it = _elem_side_qp_functor.find(sub_id);
304 if (it == _elem_side_qp_functor.end())
306
307 return it->second(elem_side_qp, time);
308}
std::unordered_map< SubdomainID, ElemSideQpFn > _elem_side_qp_functor
Functors that will evaluate elements at side quadrature points.

◆ evaluate() [5/6]

template<typename T >
PiecewiseByBlockLambdaFunctor< T >::ValueType PiecewiseByBlockLambdaFunctor< T >::evaluate ( const Moose::FaceArg face,
const Moose::StateArg state 
) const
overrideprotectedvirtual
Parameters
faceSee the FaceArg doxygen
stateSee the StateArg doxygen
Returns
The functor evaluated at the requested state and space

Implements Moose::FunctorBase< T >.

Definition at line 264 of file PiecewiseByBlockLambdaFunctor.h.

266{
267 using namespace Moose::FV;
268
269 if (face.face_side)
270 {
271 const auto sub_id = face.face_side->subdomain_id();
272 auto it = _face_functor.find(sub_id);
273 if (it == _face_functor.end())
275
276 return it->second(face, time);
277 }
278
279 mooseAssert(this->isInternalFace(*face.fi),
280 "If we did not have a face side, then we must be an internal face");
281 return interpolate(*this, face, time);
282}
bool isInternalFace(const FaceInfo &) const
Returns true if the face is an internal face.
std::unordered_map< SubdomainID, FaceFn > _face_functor
Functors that return the property value on the requested side of the face (e.g.
subdomain_id_type subdomain_id() const
void interpolate(InterpMethod m, T &result, const T2 &value1, const T3 &value2, const FaceInfo &fi, const bool one_is_elem)
Provides interpolation of face values for non-advection-specific purposes (although it can/will still...

◆ evaluate() [6/6]

template<typename T >
PiecewiseByBlockLambdaFunctor< T >::ValueType PiecewiseByBlockLambdaFunctor< T >::evaluate ( const Moose::NodeArg node_arg,
const Moose::StateArg time 
) const
overrideprotectedvirtual

Implements Moose::FunctorBase< T >.

Definition at line 327 of file PiecewiseByBlockLambdaFunctor.h.

329{
330 mooseAssert(node_arg.node, "The node must be non-null in functor material properties");
331 if (node_arg.subdomain_ids->size() != 1)
332 mooseError("We do not currently support multi-subdomain evaluation of nodal arguments");
333 const auto sub_id = *(node_arg.subdomain_ids->begin());
334 auto it = _node_functor.find(sub_id);
335 if (it == _node_functor.end())
337
338 return it->second(node_arg, time);
339}
std::unordered_map< SubdomainID, NodeFn > _node_functor
Functors that return nodal values.
const libMesh::Node * node
The node which defines our location in space.
const std::set< SubdomainID > * subdomain_ids
Indicates what subdomains this argument should be associated with.

◆ evaluateDot() [1/6]

template<typename T >
virtual DotType Moose::FunctorBase< T >::evaluateDot ( const ElemArg ,
const StateArg  
) const
inlineprotectedvirtualinherited

Evaluate the functor time derivative with a given element.

Some example implementations of this method could compute an element-average or evaluate at the element centroid

Reimplemented in Moose::ConstantFunctor< T >, MooseVariableFE< OutputType >, MooseVariableFE< ComputeValueType >, MooseVariableFE< Real >, MooseVariableFE< RealEigenVector >, MooseVariableFE< RealVectorValue >, MooseVariableFE< T >, Function, Postprocessor, MooseLinearVariableFV< OutputType >, MooseLinearVariableFV< ComputeValueType >, MooseLinearVariableFV< Real >, MooseLinearVariableFV< RealEigenVector >, MooseLinearVariableFV< RealVectorValue >, MooseLinearVariableFV< T >, MooseVariableFV< OutputType >, MooseVariableFV< ComputeValueType >, MooseVariableFV< Real >, MooseVariableFV< RealEigenVector >, MooseVariableFV< RealVectorValue >, MooseVariableFV< T >, Moose::FunctorEnvelope< T >, Moose::FunctorEnvelope< ADReal >, Moose::FunctorEnvelope< GenericReal< is_ad > >, Moose::FunctorEnvelope< GenericRealVectorValue< is_ad > >, Moose::FunctorEnvelope< libMesh::VectorValue >, Moose::FunctorEnvelope< Moose::GenericType< Real, is_ad > >, Moose::FunctorEnvelope< Moose::GenericType< T, is_ad > >, Moose::FunctorEnvelope< Real >, Moose::FunctorEnvelope< RealVectorValue >, Moose::FunctorEnvelope< VectorValue< GenericReal< is_ad > > >, Moose::ADWrapperFunctor< T >, Moose::RawValueFunctor< T >, and Moose::VectorCompositeFunctor< T >.

Definition at line 391 of file MooseFunctor.h.

392 {
393 mooseError("Element time derivative not implemented for functor " + functorName());
394 }
const MooseFunctorName & functorName() const
Return the functor name.

◆ evaluateDot() [2/6]

template<typename T >
virtual DotType Moose::FunctorBase< T >::evaluateDot ( const ElemPointArg ,
const StateArg  
) const
inlineprotectedvirtualinherited

◆ evaluateDot() [3/6]

template<typename T >
virtual DotType Moose::FunctorBase< T >::evaluateDot ( const ElemQpArg ,
const StateArg  
) const
inlineprotectedvirtualinherited

◆ evaluateDot() [4/6]

template<typename T >
virtual DotType Moose::FunctorBase< T >::evaluateDot ( const ElemSideQpArg ,
const StateArg  
) const
inlineprotectedvirtualinherited

◆ evaluateDot() [5/6]

template<typename T >
virtual DotType Moose::FunctorBase< T >::evaluateDot ( const FaceArg ,
const StateArg  
) const
inlineprotectedvirtualinherited

◆ evaluateDot() [6/6]

template<typename T >
virtual DotType Moose::FunctorBase< T >::evaluateDot ( const NodeArg ,
const StateArg  
) const
inlineprotectedvirtualinherited

◆ evaluateGradDot() [1/6]

template<typename T >
virtual GradientType Moose::FunctorBase< T >::evaluateGradDot ( const ElemArg ,
const StateArg  
) const
inlineprotectedvirtualinherited

◆ evaluateGradDot() [2/6]

template<typename T >
virtual GradientType Moose::FunctorBase< T >::evaluateGradDot ( const ElemPointArg ,
const StateArg  
) const
inlineprotectedvirtualinherited

◆ evaluateGradDot() [3/6]

template<typename T >
virtual GradientType Moose::FunctorBase< T >::evaluateGradDot ( const ElemQpArg ,
const StateArg  
) const
inlineprotectedvirtualinherited

◆ evaluateGradDot() [4/6]

template<typename T >
virtual GradientType Moose::FunctorBase< T >::evaluateGradDot ( const ElemSideQpArg ,
const StateArg  
) const
inlineprotectedvirtualinherited

◆ evaluateGradDot() [5/6]

template<typename T >
virtual GradientType Moose::FunctorBase< T >::evaluateGradDot ( const FaceArg ,
const StateArg  
) const
inlineprotectedvirtualinherited

◆ evaluateGradDot() [6/6]

template<typename T >
virtual GradientType Moose::FunctorBase< T >::evaluateGradDot ( const NodeArg ,
const StateArg  
) const
inlineprotectedvirtualinherited

◆ evaluateGradient() [1/6]

template<typename T >
virtual GradientType Moose::FunctorBase< T >::evaluateGradient ( const ElemPointArg ,
const StateArg  
) const
inlineprotectedvirtualinherited

◆ evaluateGradient() [2/6]

template<typename T >
virtual GradientType Moose::FunctorBase< T >::evaluateGradient ( const ElemQpArg ,
const StateArg  
) const
inlineprotectedvirtualinherited
Parameters
qpSee the ElemQpArg doxygen
stateSee the StateArg doxygen
Returns
The functor gradient evaluated at the requested state and space

Reimplemented in Moose::ConstantFunctor< T >, MooseVariableFE< OutputType >, MooseVariableFE< ComputeValueType >, MooseVariableFE< Real >, MooseVariableFE< RealEigenVector >, MooseVariableFE< RealVectorValue >, MooseVariableFE< T >, Function, Postprocessor, MooseVariableScalar, Moose::FunctorEnvelope< T >, Moose::FunctorEnvelope< ADReal >, Moose::FunctorEnvelope< GenericReal< is_ad > >, Moose::FunctorEnvelope< GenericRealVectorValue< is_ad > >, Moose::FunctorEnvelope< libMesh::VectorValue >, Moose::FunctorEnvelope< Moose::GenericType< Real, is_ad > >, Moose::FunctorEnvelope< Moose::GenericType< T, is_ad > >, Moose::FunctorEnvelope< Real >, Moose::FunctorEnvelope< RealVectorValue >, Moose::FunctorEnvelope< VectorValue< GenericReal< is_ad > > >, Moose::ADWrapperFunctor< T >, Moose::RawValueFunctor< T >, MooseLinearVariableFV< OutputType >, MooseLinearVariableFV< ComputeValueType >, MooseLinearVariableFV< Real >, MooseLinearVariableFV< RealEigenVector >, MooseLinearVariableFV< RealVectorValue >, MooseLinearVariableFV< T >, MooseVariableFV< OutputType >, MooseVariableFV< ComputeValueType >, MooseVariableFV< Real >, MooseVariableFV< RealEigenVector >, MooseVariableFV< RealVectorValue >, and MooseVariableFV< T >.

Definition at line 358 of file MooseFunctor.h.

359 {
360 mooseError("Element quadrature point gradient not implemented for functor " + functorName());
361 }

◆ evaluateGradient() [3/6]

template<typename T >
virtual GradientType Moose::FunctorBase< T >::evaluateGradient ( const ElemSideQpArg ,
const StateArg  
) const
inlineprotectedvirtualinherited

◆ evaluateGradient() [4/6]

template<typename T >
PiecewiseByBlockLambdaFunctor< T >::GradientType PiecewiseByBlockLambdaFunctor< T >::evaluateGradient ( const Moose::ElemArg ,
const Moose::StateArg  
) const
overrideprotectedvirtual

Evaluate the functor gradient with a given element.

Some example implementations of this method could compute an element-average or evaluate at the element centroid

Reimplemented from Moose::FunctorBase< T >.

Definition at line 343 of file PiecewiseByBlockLambdaFunctor.h.

345{
346 return Moose::FV::greenGaussGradient(elem_arg, time, *this, true, _mesh);
347}
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)
Compute a cell gradient using the method of Green-Gauss.

◆ evaluateGradient() [5/6]

template<typename T >
PiecewiseByBlockLambdaFunctor< T >::GradientType PiecewiseByBlockLambdaFunctor< T >::evaluateGradient ( const Moose::FaceArg ,
const Moose::StateArg  
) const
overrideprotectedvirtual
Parameters
faceSee the FaceArg doxygen
stateSee the StateArg doxygen
Returns
The functor gradient evaluated at the requested state and space

Reimplemented from Moose::FunctorBase< T >.

Definition at line 351 of file PiecewiseByBlockLambdaFunctor.h.

353{
354 return Moose::FV::greenGaussGradient(face_arg, time, *this, true, _mesh);
355}

◆ evaluateGradient() [6/6]

template<typename T >
virtual GradientType Moose::FunctorBase< T >::evaluateGradient ( const NodeArg ,
const StateArg  
) const
inlineprotectedvirtualinherited

◆ functorName()

template<typename T >
const MooseFunctorName & Moose::FunctorBase< T >::functorName ( ) const
inlineinherited

◆ genericEvaluate()

template<typename T >
template<FunctorEvaluationKind FET, typename Space , typename State >
FunctorReturnType< T, FET >::type Moose::FunctorBase< T >::genericEvaluate ( const Space &  r,
const State &  state 
) const
inherited

Perform a generic evaluation based on the supplied template argument FET and supplied spatial and temporal arguments.

Definition at line 993 of file MooseFunctor.h.

994{
995 if constexpr (FET == FunctorEvaluationKind::Value)
996 return (*this)(r, state);
997 else if constexpr (FET == FunctorEvaluationKind::Gradient)
998 return gradient(r, state);
999 else if constexpr (FET == FunctorEvaluationKind::Dot)
1000 return dot(r, state);
1001 else
1002 return gradDot(r, state);
1003}
DotType dot(const ElemArg &elem, const StateArg &state) const
Same as their evaluateDot overloads with the same arguments but allows for caching implementation.
GradientType gradient(const ElemArg &elem, const StateArg &state) const
Same as their evaluateGradient overloads with the same arguments but allows for caching implementatio...
GradientType gradDot(const ElemArg &elem, const StateArg &state) const
Same as their evaluateGradDot overloads with the same arguments but allows for caching implementation...

◆ gradDot() [1/6]

template<typename T >
FunctorBase< T >::GradientType Moose::FunctorBase< T >::gradDot ( const ElemArg elem,
const StateArg state 
) const
inherited

Same as their evaluateGradDot overloads with the same arguments but allows for caching implementation.

These are the methods a user will call in their code

Definition at line 939 of file MooseFunctor.h.

940{
941 return evaluateGradDot(elem, state);
942}
virtual GradientType evaluateGradDot(const ElemArg &, const StateArg &) const
Evaluate the functor gradient-dot with a given element.

Referenced by Moose::ADWrapperFunctor< T >::evaluateGradDot(), Moose::VectorComponentFunctor< T >::evaluateGradDot(), Moose::ADWrapperFunctor< T >::evaluateGradDot(), Moose::ADWrapperFunctor< T >::evaluateGradDot(), Moose::ADWrapperFunctor< T >::evaluateGradDot(), Moose::ADWrapperFunctor< T >::evaluateGradDot(), Moose::VectorComponentFunctor< T >::evaluateGradDot(), and Moose::ADWrapperFunctor< T >::evaluateGradDot().

◆ gradDot() [2/6]

template<typename T >
FunctorBase< T >::GradientType Moose::FunctorBase< T >::gradDot ( const ElemPointArg elem_point,
const StateArg state 
) const
inherited

Definition at line 968 of file MooseFunctor.h.

969{
970 return evaluateGradDot(elem_point, state);
971}

◆ gradDot() [3/6]

template<typename T >
FunctorBase< T >::GradientType Moose::FunctorBase< T >::gradDot ( const ElemQpArg qp,
const StateArg state 
) const
inherited

Definition at line 954 of file MooseFunctor.h.

955{
956 return evaluateGradDot(elem_qp, state);
957}

◆ gradDot() [4/6]

template<typename T >
FunctorBase< T >::GradientType Moose::FunctorBase< T >::gradDot ( const ElemSideQpArg qp,
const StateArg state 
) const
inherited

Definition at line 961 of file MooseFunctor.h.

962{
963 return evaluateGradDot(elem_side_qp, state);
964}

◆ gradDot() [5/6]

template<typename T >
FunctorBase< T >::GradientType Moose::FunctorBase< T >::gradDot ( const FaceArg face,
const StateArg state 
) const
inherited

Definition at line 946 of file MooseFunctor.h.

947{
948 checkFace(face);
949 return evaluateGradDot(face, state);
950}

◆ gradDot() [6/6]

template<typename T >
FunctorBase< T >::GradientType Moose::FunctorBase< T >::gradDot ( const NodeArg node,
const StateArg state 
) const
inherited

Definition at line 975 of file MooseFunctor.h.

976{
977 return evaluateGradDot(node, state);
978}

◆ gradient() [1/6]

template<typename T >
FunctorBase< T >::GradientType Moose::FunctorBase< T >::gradient ( const ElemArg elem,
const StateArg state 
) const
inherited

◆ gradient() [2/6]

template<typename T >
FunctorBase< T >::GradientType Moose::FunctorBase< T >::gradient ( const ElemPointArg elem_point,
const StateArg state 
) const
inherited

Definition at line 882 of file MooseFunctor.h.

883{
884 return evaluateGradient(elem_point, state);
885}

◆ gradient() [3/6]

template<typename T >
FunctorBase< T >::GradientType Moose::FunctorBase< T >::gradient ( const ElemQpArg qp,
const StateArg state 
) const
inherited

Definition at line 868 of file MooseFunctor.h.

869{
870 return evaluateGradient(elem_qp, state);
871}

◆ gradient() [4/6]

template<typename T >
FunctorBase< T >::GradientType Moose::FunctorBase< T >::gradient ( const ElemSideQpArg qp,
const StateArg state 
) const
inherited

Definition at line 875 of file MooseFunctor.h.

876{
877 return evaluateGradient(elem_side_qp, state);
878}

◆ gradient() [5/6]

template<typename T >
FunctorBase< T >::GradientType Moose::FunctorBase< T >::gradient ( const FaceArg face,
const StateArg state 
) const
inherited

Definition at line 860 of file MooseFunctor.h.

861{
862 checkFace(face);
863 return evaluateGradient(face, state);
864}

◆ gradient() [6/6]

template<typename T >
FunctorBase< T >::GradientType Moose::FunctorBase< T >::gradient ( const NodeArg node,
const StateArg state 
) const
inherited

Definition at line 889 of file MooseFunctor.h.

890{
891 return evaluateGradient(node, state);
892}

◆ hasBlocks()

template<typename T >
bool PiecewiseByBlockLambdaFunctor< T >::hasBlocks ( SubdomainID  ) const
overridevirtual

Returns whether the functor is defined on this block.

Reimplemented from Moose::FunctorBase< T >.

Definition at line 202 of file PiecewiseByBlockLambdaFunctor.h.

203{
204 // If any of the maps has a functor for that block, it has the block
205 const bool has_blocks = _elem_functor.count(id);
206 mooseAssert(has_blocks == _face_functor.count(id),
207 "All functor sets should agree on whether we have this sub id");
208 mooseAssert(has_blocks == _elem_qp_functor.count(id),
209 "All functor sets should agree on whether we have this sub id");
210 mooseAssert(has_blocks == _elem_side_qp_functor.count(id),
211 "All functor sets should agree on whether we have this sub id");
212 return has_blocks;
213}

◆ hasFaceSide()

template<typename T >
bool Moose::FunctorBase< T >::hasFaceSide ( const FaceInfo fi,
const bool  fi_elem_side 
) const
overridevirtualinherited

◆ isConstant()

template<typename T >
virtual bool Moose::FunctorBase< T >::isConstant ( ) const
inlinevirtualinherited

◆ isExtrapolatedBoundaryFace()

template<typename T >
bool PiecewiseByBlockLambdaFunctor< T >::isExtrapolatedBoundaryFace ( const FaceInfo ,
const Elem *  ,
const Moose::StateArg  
) const
overridevirtual

Returns whether this (sided) face is an extrapolated boundary face for this functor.

Reimplemented from Moose::FunctorBase< T >.

Definition at line 184 of file PiecewiseByBlockLambdaFunctor.h.

187{
188 if (!fi.neighborPtr())
189 return true;
190
191 const bool defined_on_elem = _elem_functor.count(fi.elem().subdomain_id());
192 const bool defined_on_neighbor = _elem_functor.count(fi.neighbor().subdomain_id());
193 const bool extrapolated = (defined_on_elem + defined_on_neighbor) == 1;
194
195 mooseAssert(defined_on_elem || defined_on_neighbor,
196 "This shouldn't be called if we aren't defined on either side.");
197 return extrapolated;
198}

◆ isInternalFace()

template<typename T >
bool Moose::FunctorBase< T >::isInternalFace ( const FaceInfo fi) const
inherited

Returns true if the face is an internal face.

Definition at line 575 of file MooseFunctor.h.

576{
577 if (!fi.neighborPtr())
578 return false;
579
580 return hasBlocks(fi.elem().subdomain_id()) && hasBlocks(fi.neighborPtr()->subdomain_id());
581}

Referenced by FVAnisotropicDiffusion::computeQpResidual(), and FVDiffusion::computeQpResidual().

◆ jacobianSetup()

template<typename T >
void Moose::FunctorBase< T >::jacobianSetup ( )
overridevirtualinherited

◆ operator()() [1/6]

template<typename T >
FunctorBase< T >::ValueType Moose::FunctorBase< T >::operator() ( const ElemArg elem,
const StateArg state 
) const
inherited

Same as their evaluate overloads with the same arguments but allows for caching implementation.

These are the methods a user will call in their code

Definition at line 603 of file MooseFunctor.h.

604{
606 return evaluate(elem, state);
607
608 mooseAssert(state.state == 0,
609 "Cached evaluations are only currently supported for the current state.");
610
612}
bool _always_evaluate
Boolean to check if we always need evaluation.
virtual ValueType evaluate(const ElemArg &elem, const StateArg &state) const =0
Evaluate the functor with a given element.
ValueType queryFVArgCache(std::map< SpaceArg, ValueType > &cache_data, const SpaceArg &space) const
check a finite volume spatial argument cache and if invalid then evaluate

◆ operator()() [2/6]

template<typename T >
FunctorBase< T >::ValueType Moose::FunctorBase< T >::operator() ( const ElemPointArg elem_point,
const StateArg state 
) const
inherited

Definition at line 713 of file MooseFunctor.h.

714{
715 return evaluate(elem_point, state);
716}

◆ operator()() [3/6]

template<typename T >
FunctorBase< T >::ValueType Moose::FunctorBase< T >::operator() ( const ElemQpArg qp,
const StateArg state 
) const
inherited

Definition at line 662 of file MooseFunctor.h.

663{
665 return evaluate(elem_qp, state);
666
667 const auto elem_id = elem_qp.elem->id();
668 if (elem_id != _current_qp_map_key)
669 {
670 _current_qp_map_key = elem_id;
672 }
673 auto & qp_data = *_current_qp_map_value;
674 const auto qp = elem_qp.qp;
675 const auto * const qrule = elem_qp.qrule;
676 mooseAssert(qrule, "qrule must be non-null");
677
678 return queryQpCache(qp, *qrule, qp_data, elem_qp, state);
679}
ValueType queryQpCache(unsigned int qp, const libMesh::QBase &qrule, std::vector< std::pair< bool, T > > &qp_cache_data, const SpaceArg &space, const StateArg &state) const
check a qp cache and if invalid then evaluate

◆ operator()() [4/6]

template<typename T >
FunctorBase< T >::ValueType Moose::FunctorBase< T >::operator() ( const ElemSideQpArg qp,
const StateArg state 
) const
inherited

Definition at line 683 of file MooseFunctor.h.

684{
686 return evaluate(elem_side_qp, state);
687
688 const Elem * const elem = elem_side_qp.elem;
689 mooseAssert(elem, "elem must be non-null");
690 const auto elem_id = elem->id();
691 if (elem_id != _current_side_qp_map_key)
692 {
693 _current_side_qp_map_key = elem_id;
695 }
696 auto & side_qp_data = *_current_side_qp_map_value;
697 const auto side = elem_side_qp.side;
698 const auto qp = elem_side_qp.qp;
699 const auto * const qrule = elem_side_qp.qrule;
700 mooseAssert(qrule, "qrule must be non-null");
701
702 // Check and see whether we even have sized for this side
703 if (side >= side_qp_data.size())
704 side_qp_data.resize(elem->n_sides());
705
706 // Ok we were sized enough for our side
707 auto & qp_data = side_qp_data[side];
708 return queryQpCache(qp, *qrule, qp_data, elem_side_qp, state);
709}

◆ operator()() [5/6]

template<typename T >
FunctorBase< T >::ValueType Moose::FunctorBase< T >::operator() ( const FaceArg face,
const StateArg state 
) const
inherited

Definition at line 616 of file MooseFunctor.h.

617{
618 checkFace(face_in);
619
621 return evaluate(face_in, state);
622
623 mooseAssert(state.state == 0,
624 "Cached evaluations are only currently supported for the current state.");
625
626 return queryFVArgCache(_face_arg_to_value, face_in);
627}

◆ operator()() [6/6]

template<typename T >
FunctorBase< T >::ValueType Moose::FunctorBase< T >::operator() ( const NodeArg node,
const StateArg state 
) const
inherited

Definition at line 730 of file MooseFunctor.h.

731{
732 mooseAssert(node.subdomain_ids, "Subdomain IDs must be supplied to the node argument");
733 return evaluate(node, state);
734}

◆ queryFVArgCache()

template<typename T >
template<typename SpaceArg >
FunctorBase< T >::ValueType Moose::FunctorBase< T >::queryFVArgCache ( std::map< SpaceArg, ValueType > &  cache_data,
const SpaceArg &  space 
) const
privateinherited

check a finite volume spatial argument cache and if invalid then evaluate

Definition at line 586 of file MooseFunctor.h.

588{
589 // We don't want to evaluate if the key already exists, so instead we value initialize
590 auto [it, inserted] = cache_data.try_emplace(space, ValueType());
591 auto & value = it->second;
592
593 if (inserted)
594 // value not ready to go
595 // this function is only called from functions that assert we are in the current time state
596 value = evaluate(space, currentState());
597
598 return value;
599}
StateArg currentState()
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)

◆ queryQpCache()

template<typename T >
template<typename SpaceArg , typename StateArg >
FunctorBase< T >::ValueType Moose::FunctorBase< T >::queryQpCache ( unsigned int  qp,
const libMesh::QBase qrule,
std::vector< std::pair< bool, T > > &  qp_cache_data,
const SpaceArg &  space,
const StateArg state 
) const
privateinherited

check a qp cache and if invalid then evaluate

Definition at line 632 of file MooseFunctor.h.

637{
638 // Check and see whether we even have sized for this quadrature point. If we haven't then we
639 // must evaluate
640 if (qp >= qp_cache_data.size())
641 {
642 qp_cache_data.resize(qrule.n_points(), std::make_pair(false, ValueType()));
643 auto & pr = qp_cache_data[qp];
644 pr.second = evaluate(space, state);
645 pr.first = true;
646 return pr.second;
647 }
648
649 // We've already sized for this qp, so let's see whether we have a valid cache value
650 auto & pr = qp_cache_data[qp];
651 if (pr.first)
652 return pr.second;
653
654 // No valid cache value so evaluate
655 pr.second = evaluate(space, state);
656 pr.first = true;
657 return pr.second;
658}
unsigned int n_points() const

◆ residualSetup()

template<typename T >
void Moose::FunctorBase< T >::residualSetup ( )
overridevirtualinherited

◆ setCacheClearanceSchedule()

template<typename T >
void Moose::FunctorBase< T >::setCacheClearanceSchedule ( const std::set< ExecFlagType > &  clearance_schedule)
inherited

Set how often to clear the functor evaluation cache.

Definition at line 720 of file MooseFunctor.h.

721{
722 if (clearance_schedule.count(EXEC_ALWAYS))
723 _always_evaluate = true;
724
725 _clearance_schedule = clearance_schedule;
726}
const ExecFlagType EXEC_ALWAYS
Definition Moose.C:53

◆ setFunctor()

template<typename T >
template<typename PolymorphicLambda >
void PiecewiseByBlockLambdaFunctor< T >::setFunctor ( const MooseMesh mesh,
const std::set< SubdomainID > &  block_ids,
PolymorphicLambda  my_lammy 
)

Set the functor that will be used in calls to evaluate overloads.

Parameters
meshThe mesh that the functor is defined on
block_idsThe block/subdomain IDs that the user-provided functor is valid for
my_lammyThe functor that defines how this object is evaluated

Definition at line 148 of file PiecewiseByBlockLambdaFunctor.h.

151{
152 mooseAssert(&mesh == &_mesh,
153 "We should always be setting this functor with the same mesh. We may relax this "
154 "assertion later");
155
156 auto add_lammy = [this, my_lammy](const SubdomainID block_id)
157 {
158 auto pr = _elem_functor.emplace(block_id, my_lammy);
159 if (!pr.second)
160 mooseError("No insertion for the functor material property '",
161 this->functorName(),
162 "' for block id ",
163 block_id,
164 ". Another material must already declare this property on that block.");
165 _face_functor.emplace(block_id, my_lammy);
166 _elem_qp_functor.emplace(block_id, my_lammy);
167 _elem_side_qp_functor.emplace(block_id, my_lammy);
168 _elem_point_functor.emplace(block_id, my_lammy);
169 _node_functor.emplace(block_id, my_lammy);
170 };
171
172 for (const auto block_id : block_ids)
173 add_lammy(block_id);
174
175 // Handle special case of ANY_BLOCK_ID and empty block restriction that also cover
176 // INVALID_BLOCK_ID
177 if (block_ids.count(Moose::ANY_BLOCK_ID) || block_ids.empty() ||
178 block_ids == mesh.meshSubdomains())
179 add_lammy(Moose::INVALID_BLOCK_ID);
180}
MeshBase & mesh
const SubdomainID ANY_BLOCK_ID
Definition MooseTypes.C:19
const SubdomainID INVALID_BLOCK_ID
Definition MooseTypes.C:20

Referenced by PiecewiseByBlockLambdaFunctor< T >::PiecewiseByBlockLambdaFunctor().

◆ subdomainErrorMessage()

template<typename T >
template<typename C >
void PiecewiseByBlockLambdaFunctor< T >::subdomainErrorMessage ( SubdomainID  sub_id,
const std::unordered_map< SubdomainID, C > &  functors 
) const
private

Provide a useful error message about lack of functor material property on the provided subdomain sub_id.

Parameters
sub_idsubdomain id on which the functor was missing
functorsmap of functors, used to show list of blocks with a definition

Definition at line 228 of file PiecewiseByBlockLambdaFunctor.h.

230{
231 std::vector<std::string> block_names_and_ids;
232 block_names_and_ids.reserve(functors.size());
233 for (const auto & [available_sub_id, functor] : functors)
234 {
235 libmesh_ignore(functor);
236 block_names_and_ids.push_back(subdomainNameAndID(available_sub_id));
237 }
238 mooseError("The provided subdomain ",
239 subdomainNameAndID(sub_id),
240 " doesn't exist in the map for lambda functor '",
241 this->functorName(),
242 "'! This is likely because you did not provide a functor material "
243 "definition on that subdomain.\nSubdomains in the map: ",
244 Moose::stringify(block_names_and_ids));
245}
std::string subdomainNameAndID(SubdomainID sub_id) const
Format a subdomain ID with its name, when available.
void libmesh_ignore(const Args &...)

◆ subdomainNameAndID()

template<typename T >
std::string PiecewiseByBlockLambdaFunctor< T >::subdomainNameAndID ( SubdomainID  sub_id) const
private

Format a subdomain ID with its name, when available.

Definition at line 217 of file PiecewiseByBlockLambdaFunctor.h.

218{
219 const auto & name = _mesh.getSubdomainName(sub_id);
220 if (name.empty())
221 return Moose::stringify(sub_id);
222 return "'" + name + "' (" + Moose::stringify(sub_id) + ")";
223}
const std::string & getSubdomainName(SubdomainID subdomain_id) const
Return the name of a block given an id.
Definition MooseMesh.C:1751
std::string name(const ElemQuality q)

◆ supportsElemSideQpArg()

template<typename T >
bool PiecewiseByBlockLambdaFunctor< T >::supportsElemSideQpArg ( ) const
inlinefinaloverridevirtual

Whether this functor supports evaluation with ElemSideQpArg.

Implements Moose::FunctorBase< T >.

Definition at line 62 of file PiecewiseByBlockLambdaFunctor.h.

62{ return true; }

◆ supportsFaceArg()

template<typename T >
bool PiecewiseByBlockLambdaFunctor< T >::supportsFaceArg ( ) const
inlinefinaloverridevirtual

Whether this functor supports evaluation with FaceArg.

Implements Moose::FunctorBase< T >.

Definition at line 61 of file PiecewiseByBlockLambdaFunctor.h.

61{ return true; }

◆ timestepSetup()

template<typename T >
void Moose::FunctorBase< T >::timestepSetup ( )
overridevirtualinherited

Member Data Documentation

◆ _always_evaluate

template<typename T >
bool Moose::FunctorBase< T >::_always_evaluate
privateinherited

Boolean to check if we always need evaluation.

Definition at line 523 of file MooseFunctor.h.

◆ _clearance_schedule

template<typename T >
std::set<ExecFlagType> Moose::FunctorBase< T >::_clearance_schedule
privateinherited

How often to clear the material property cache.

Definition at line 520 of file MooseFunctor.h.

◆ _current_qp_map_key

template<typename T >
dof_id_type Moose::FunctorBase< T >::_current_qp_map_key = libMesh::DofObject::invalid_id
mutableprivateinherited

Current key for qp map cache.

Definition at line 529 of file MooseFunctor.h.

◆ _current_qp_map_value

template<typename T >
std::vector<std::pair<bool, ValueType> >* Moose::FunctorBase< T >::_current_qp_map_value = nullptr
mutableprivateinherited

Current value for qp map cache.

Definition at line 532 of file MooseFunctor.h.

◆ _current_side_qp_map_key

template<typename T >
dof_id_type Moose::FunctorBase< T >::_current_side_qp_map_key = libMesh::DofObject::invalid_id
mutableprivateinherited

Current key for side-qp map cache.

Definition at line 545 of file MooseFunctor.h.

◆ _current_side_qp_map_value

template<typename T >
std::vector<std::vector<std::pair<bool, ValueType> > >* Moose::FunctorBase< T >::_current_side_qp_map_value
mutableprivateinherited
Initial value:
=
nullptr

Current value for side-qp map cache.

Definition at line 548 of file MooseFunctor.h.

◆ _elem_arg_to_value

template<typename T >
std::map<ElemArg, ValueType> Moose::FunctorBase< T >::_elem_arg_to_value
mutableprivateinherited

Map from element arguments to their cached evaluations.

Definition at line 561 of file MooseFunctor.h.

◆ _elem_functor

template<typename T >
std::unordered_map<SubdomainID, ElemFn> PiecewiseByBlockLambdaFunctor< T >::_elem_functor
private

Functors that return element average values (or cell centroid values or whatever the implementer wants to return for a given element argument)

Definition at line 110 of file PiecewiseByBlockLambdaFunctor.h.

◆ _elem_point_functor

template<typename T >
std::unordered_map<SubdomainID, ElemPointFn> PiecewiseByBlockLambdaFunctor< T >::_elem_point_functor
private

Functors that return evaluations at an arbitrary physical point in an element.

Definition at line 123 of file PiecewiseByBlockLambdaFunctor.h.

◆ _elem_qp_functor

template<typename T >
std::unordered_map<SubdomainID, ElemQpFn> PiecewiseByBlockLambdaFunctor< T >::_elem_qp_functor
private

Functors that will evaluate elements at quadrature points.

Definition at line 117 of file PiecewiseByBlockLambdaFunctor.h.

◆ _elem_side_qp_functor

template<typename T >
std::unordered_map<SubdomainID, ElemSideQpFn> PiecewiseByBlockLambdaFunctor< T >::_elem_side_qp_functor
private

Functors that will evaluate elements at side quadrature points.

Definition at line 120 of file PiecewiseByBlockLambdaFunctor.h.

◆ _face_arg_to_value

template<typename T >
std::map<FaceArg, ValueType> Moose::FunctorBase< T >::_face_arg_to_value
mutableprivateinherited

Map from face arguments to their cached evaluations.

Definition at line 564 of file MooseFunctor.h.

◆ _face_functor

template<typename T >
std::unordered_map<SubdomainID, FaceFn> PiecewiseByBlockLambdaFunctor< T >::_face_functor
private

Functors that return the property value on the requested side of the face (e.g.

the infinitesimal + or - side of the face)

Definition at line 114 of file PiecewiseByBlockLambdaFunctor.h.

◆ _functor_name

template<typename T >
MooseFunctorName Moose::FunctorBase< T >::_functor_name
privateinherited

name of the functor

Definition at line 570 of file MooseFunctor.h.

Referenced by Moose::FunctorBase< T >::functorName().

◆ _mesh

template<typename T >
const MooseMesh& PiecewiseByBlockLambdaFunctor< T >::_mesh
private

The mesh that this functor operates on.

Definition at line 129 of file PiecewiseByBlockLambdaFunctor.h.

◆ _node_arg_to_value

template<typename T >
std::map<NodeArg, ValueType> Moose::FunctorBase< T >::_node_arg_to_value
mutableprivateinherited

Map from nodal arguments to their cached evaluations.

Definition at line 567 of file MooseFunctor.h.

◆ _node_functor

template<typename T >
std::unordered_map<SubdomainID, NodeFn> PiecewiseByBlockLambdaFunctor< T >::_node_functor
private

Functors that return nodal values.

Definition at line 126 of file PiecewiseByBlockLambdaFunctor.h.

◆ _qp_to_value

template<typename T >
std::unordered_map<dof_id_type, std::vector<std::pair<bool, ValueType> > > Moose::FunctorBase< T >::_qp_to_value
mutableprivateinherited

Cached element quadrature point functor property evaluations.

The map key is the element id. The map values should have size corresponding to the number of quadrature points on the element. The vector elements are pairs. The first member of the pair indicates whether a cached value has been computed. The second member of the pair is the (cached) value. If the boolean is false, then the value cannot be trusted

Definition at line 539 of file MooseFunctor.h.

◆ _side_qp_to_value

template<typename T >
std::unordered_map<dof_id_type, std::vector<std::vector<std::pair<bool, ValueType> > > > Moose::FunctorBase< T >::_side_qp_to_value
mutableprivateinherited

Cached element quadrature point functor property evaluations.

The map key is the element id. The map values are a multi-dimensional vector (or vector of vectors) with the first index corresponding to the side and the second index corresponding to the quadrature point index. The elements returned after double indexing are pairs. The first member of the pair indicates whether a cached value has been computed. The second member of the pair is the (cached) value. If the boolean is false, then the value cannot be trusted

Definition at line 558 of file MooseFunctor.h.


The documentation for this class was generated from the following file: