14 #include "metaphysicl/raw_type.h" 21 RankTwoTensorMaterialConverter,
25 RankFourTensorMaterialConverter,
35 "Converts regular material properties to AD properties and vice versa");
36 params.
addParam<std::vector<MaterialPropertyName>>(
39 "The names of the regular material properties to convert to AD properties");
40 params.
addParam<std::vector<MaterialPropertyName>>(
41 "ad_props_out", {},
"The names of the output AD properties");
42 params.
addParam<std::vector<MaterialPropertyName>>(
45 "The names of the AD material properties to convert to regular properties");
46 params.
addParam<std::vector<MaterialPropertyName>>(
47 "reg_props_out", {},
"The names of the output regular properties");
49 "intra_convert",
false,
"Whether to allow intra conversion, e.g. regular->regular, ad->ad");
55 :
Material(parameters), _intra_convert(getParam<bool>(
"intra_convert"))
58 auto reg_props_in = getParam<std::vector<MaterialPropertyName>>(
"reg_props_in");
59 auto ad_props_out = getParam<std::vector<MaterialPropertyName>>(
"ad_props_out");
60 auto ad_props_in = getParam<std::vector<MaterialPropertyName>>(
"ad_props_in");
61 auto reg_props_out = getParam<std::vector<MaterialPropertyName>>(
"reg_props_out");
65 if (reg_props_in.size() != reg_props_out.size())
67 "The number of output regular properties must match the number of input regular " 68 "properties, which is " +
69 std::to_string(reg_props_in.size()));
73 if (reg_props_in.size() != ad_props_out.size())
75 "The number of output AD properties must match the number of input regular " 76 "properties, which is " +
77 std::to_string(reg_props_in.size()));
84 if (ad_props_in.size() != ad_props_out.size())
86 "The number of output AD properties must match the number of input AD " 87 "properties, which is " +
88 std::to_string(ad_props_in.size()));
92 if (ad_props_in.size() != reg_props_out.size())
94 "The number of output regular properties must match the number of input AD " 95 "properties, which is " +
96 std::to_string(ad_props_in.size()));
109 for (MooseIndex(ad_props_out) i = 0; i < ad_props_out.size(); ++i)
113 _ad_props_in[i] = &getADMaterialProperty<T>(ad_props_in[i]);
115 for (MooseIndex(reg_props_out) i = 0; i < reg_props_out.size(); ++i)
119 template <
typename T>
123 computeQpProperties();
126 template <
typename T>
131 for (MooseIndex(_num_reg_props_to_convert) i = 0; i < _num_reg_props_to_convert; ++i)
132 (*_reg_props_out[i])[_qp] = (*_reg_props_in[i])[_qp];
134 for (MooseIndex(_num_reg_props_to_convert) i = 0; i < _num_reg_props_to_convert; ++i)
135 (*_ad_props_out[i])[_qp] = (*_reg_props_in[i])[_qp];
138 for (MooseIndex(_num_ad_props_to_convert) i = 0; i < _num_ad_props_to_convert; ++i)
139 (*_ad_props_out[i])[_qp] = (*_ad_props_in[i])[_qp];
141 for (MooseIndex(_num_ad_props_to_convert) i = 0; i < _num_ad_props_to_convert; ++i)
This material converts regular material properties to AD properties and AD properties to regular prop...
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 ...
registerMooseObject("MooseApp", MaterialADConverter)
std::size_t _num_reg_props_to_convert
virtual void computeQpProperties() override
Users must override this method.
std::size_t _num_ad_props_to_convert
static InputParameters validParams()
std::vector< const MaterialProperty< T > * > _reg_props_in
const bool _intra_convert
static InputParameters validParams()
registerMooseObjectRenamed("MooseApp", MaterialConverter, "06/30/2022 24:00", MaterialADConverter)
Materials compute MaterialProperties.
std::vector< MaterialProperty< T > * > _reg_props_out
std::vector< ADMaterialProperty< T > * > _ad_props_out
MaterialADConverterTempl(const InputParameters ¶meters)
std::vector< const ADMaterialProperty< T > * > _ad_props_in
void initQpStatefulProperties() override
Initialize stateful properties at quadrature points.