16 #include <unordered_set> 22 template <
typename T,
bool is_ad,
bool is_functor = false,
typename RT = Real>
71 template <
typename T,
bool is_ad,
bool is_functor,
typename RT>
76 if constexpr (is_functor)
79 params.
addRequiredParam<MaterialPropertyName>(
"property",
"The material property name.");
82 "factor", 1,
"The factor by which to multiply your material property for visualization");
83 params.
addParam<RT>(
"offset", 0,
"The offset to add to your material property for visualization");
85 if constexpr (!is_functor)
89 "Evaluate the material property at a specified quadrature point. This only needs " 90 "to be used if you are interested in a particular quadrature point in each element. " 91 "Otherwise do not include this parameter in your input file.");
98 template <
typename T,
bool is_ad,
bool is_functor,
typename RT>
102 _prop(getPropertyHelper()),
103 _selected_qp(this->isParamValid(
"selected_qp")
104 ? this->template getParam<unsigned
int>(
"selected_qp")
106 _factor(this->template getParam<
Real>(
"factor")),
107 _offset(this->template getParam<RT>(
"offset")),
108 _current_subdomain_id(this->_assembly.currentSubdomainID())
112 template <
typename T,
bool is_ad,
bool is_functor,
typename RT>
116 if constexpr (is_functor)
117 return this->
template getFunctor<Moose::GenericType<T, is_ad>>(
"functor");
119 return this->
template getGenericMaterialProperty<T, is_ad>(
"property");
122 template <
typename T,
bool is_ad,
bool is_functor,
typename RT>
127 if constexpr (is_functor)
131 const std::set<SubdomainID> sub_id_set = {_current_subdomain_id};
133 const auto state = this->determineState();
134 _full_value = _prop(node_arg, state);
138 const auto elem_arg = this->makeElemArg(this->_current_elem);
139 const auto state = this->determineState();
140 _full_value = _prop(elem_arg, state);
148 if (_selected_qp >= this->_q_point.size())
150 Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
151 this->paramError(
"selected_qp",
152 "Trying to evaluate qp ",
154 " but there are only ",
155 this->_q_point.size(),
156 " quadrature points in the element");
158 _full_value = _prop[_selected_qp];
161 _full_value = _prop[this->_qp];
165 return _factor * getRealValue() + _offset;
168 template <
typename T = Real>
const unsigned int invalid_uint
const SubdomainID & _current_subdomain_id
ID of the subdomain currently being iterated over.
const RT _offset
Value to be added to the material property.
A base class for the various Material related AuxKernal objects.
This is a wrapper that forwards calls to the implementation, which can be switched out at any time wi...
const PropertyType & getPropertyHelper()
Helper function to retrieve the property or functor.
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
typename std::conditional< is_ad, typename ADType< T >::type, T >::type GenericType
virtual RT computeValue() override
Compute and return the value of the aux variable.
MaterialAuxBaseTempl(const InputParameters ¶meters)
Class constructor.
virtual RT getRealValue()=0
Returns material property values at quadrature points.
typename GenericMaterialPropertyStruct< T, is_ad >::type GenericMaterialProperty
const std::string & type() const
Get the type of this class.
const PropertyType & _prop
(Functor)Material property for this AuxKernel
virtual void checkFullValue()
Perform a sanity check on the retrieved value (e.g. to check dynamic sizes)
typename std::conditional< is_functor, Moose::Functor< Moose::GenericType< T, is_ad > >, GenericMaterialProperty< T, is_ad > >::type PropertyType
Functors really only work for Real and RealVectorValue for now :(.
auto conditional(const C &, const L &, const R &)
const Real _factor
Multiplier for the material property.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const unsigned int _selected_qp
Evaluate at this quadrature point only.
const InputParameters & parameters() const
Get the parameters of the object.
static InputParameters validParams()
Base class for creating new auxiliary kernels and auxiliary boundary conditions.
Moose::GenericType< T, is_ad > _full_value
T Value evaluated from either the property or the functor.
static InputParameters validParams()
void ErrorVector unsigned int