28 params.addClassDescription(
"Provide an output (or its derivative) from a NEML2 model as a MOOSE "
29 "material property of type " +
30 demangle(
typeid(T).name()) +
".");
32 params.addRequiredParam<UserObjectName>(
"neml2_executor",
33 "User object managing the execution of the NEML2 model.");
34 params.addRequiredParam<MaterialPropertyName>(
36 "MOOSE material property used to store the NEML2 output variable (or its derivative)");
37 params.addRequiredParam<std::string>(
"from_neml2",
"NEML2 output variable to read from");
38 params.addParam<std::string>(
39 "neml2_input_derivative",
41 "If supplied return the derivative of the NEML2 output variable with respect to this");
42 params.addParam<std::string>(
43 "neml2_parameter_derivative",
44 "If supplied return the derivative of the NEML2 output variable with respect to this NEML2 "
48 params.addParam<MaterialPropertyName>(
"moose_material_property_init",
49 "Optional material property as the initial condition");
60 _prop(declareProperty<T>(getParam<MaterialPropertyName>(
"to_moose"))),
61 _prop0(isParamValid(
"moose_material_property_init")
62 ? &getMaterialProperty<T>(
"moose_material_property_init")
64 _value(isParamValid(
"neml2_input_derivative")
65 ? _execute_neml2_model.getOutputDerivative(
66 getParam<
std::string>(
"from_neml2"),
67 getParam<
std::string>(
"neml2_input_derivative"))
68 : (isParamValid(
"neml2_parameter_derivative")
69 ? _execute_neml2_model.getOutputParameterDerivative(
70 getParam<
std::string>(
"from_neml2"),
71 getParam<
std::string>(
"neml2_parameter_derivative"))
72 : _execute_neml2_model.getOutput(getParam<
std::string>(
"from_neml2"))))
85 if (_t_step == 0 && _prop0)
87 _prop.set() = _prop0->get();
91 if (!_execute_neml2_model.outputReady())
97 if (!_value.defined())
99 for (_qp = 0; _qp < _qrule->n_points(); ++_qp)
105 const auto i = _execute_neml2_model.getBatchIndex(_current_elem->id());
109 const bool batched = _value.dim() > base_ndim;
117 const Real * data = _value.template data_ptr<Real>();
119 for (_qp = 0; _qp < _qrule->n_points(); ++_qp)
128 if (batched &&
static_cast<int64_t
>(i + _qp) >= _value.size(0))
131 NEML2Utils::copyBlobToMOOSEData<T>(
132 batched ? data +
static_cast<std::ptrdiff_t
>(i + _qp) * base_size : data, _prop[_qp]);
136 for (_qp = 0; _qp < _qrule->n_points(); ++_qp)