12 #include "metaphysicl/raw_type.h" 22 params.
addClassDescription(
"Converts functor to non-AD and AD regular material properties");
23 params.
addParam<std::vector<MooseFunctorName>>(
24 "functors_in", {},
"The names of the functors to convert to regular material properties");
25 params.
addParam<std::vector<MaterialPropertyName>>(
26 "ad_props_out", {},
"The names of the output AD properties");
27 params.
addParam<std::vector<MaterialPropertyName>>(
28 "reg_props_out", {},
"The names of the output regular properties");
35 _num_functors_to_convert(getParam<
std::vector<MooseFunctorName>>(
"functors_in").size())
37 const auto & functors_in = getParam<std::vector<MooseFunctorName>>(
"functors_in");
38 const auto & reg_props_out = getParam<std::vector<MaterialPropertyName>>(
"reg_props_out");
39 const auto & ad_props_out = getParam<std::vector<MaterialPropertyName>>(
"ad_props_out");
41 if (reg_props_out.size() && ad_props_out.size())
43 "We dont support converting functors to both regular and AD " 44 "material properties in " 45 "a single instance of '",
47 "'. Please create two instances, one for regular and one for AD.");
49 if ((reg_props_out.size() && (functors_in.size() != reg_props_out.size())) ||
50 (ad_props_out.size() && (functors_in.size() != ad_props_out.size())))
53 "The number of output properties must match the number of input functors, which is " +
54 std::to_string(functors_in.size()));
74 computeQpProperties();
89 _current_elem, _current_side, qp_used, _qrule, _q_point[_qp]};
91 (*_ad_props_out[i])[_qp] = (*_functors_in[i])(side_arg, state);
98 const Elem * elem = _neighbor ? _current_elem->neighbor_ptr(_current_side) : _current_elem;
99 mooseAssert(elem,
"We should have an element");
102 (*_ad_props_out[i])[_qp] = (*_functors_in[i])(elem_arg, state);
void initQpStatefulProperties() override
Initialize stateful properties at quadrature points.
MaterialFunctorConverterTempl(const InputParameters ¶meters)
std::vector< const Moose::Functor< Moose::GenericType< T, true > > * > _functors_in
Incoming functors to convert. We up-convert non-AD functors to AD functors to ease implementation...
std::vector< ADMaterialProperty< T > * > _ad_props_out
AD material properties to create.
void paramError(const std::string ¶m, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
virtual void computeQpProperties() override
Users must override this method.
static InputParameters validParams()
typename std::conditional< is_ad, typename ADType< T >::type, T >::type GenericType
std::vector< MaterialProperty< T > * > _reg_props_out
Regular material properties to create.
registerMooseObject("MooseApp", MaterialFunctorConverter)
static InputParameters validParams()
const std::string & type() const
Get the type of this class.
Argument for requesting functor evaluation at a quadrature point location in an element.
Materials compute MaterialProperties.
const Moose::Functor< T > & getFunctor(const std::string &name)
Retrieves a functor from the subproblem.
IntRange< T > make_range(T beg, T end)
This material converts functor to regular (AD or not) material properties.
auto index_range(const T &sizable)
Argument for requesting functor evaluation at quadrature point locations on an element side...
const std::size_t _num_functors_to_convert
Number of material properties to create.