14 #define registerMOOSEQuantityToNEML2(T) \ 15 registerMooseObject("MooseApp", MOOSE##T##ToNEML2); \ 16 registerMooseObject("MooseApp", MOOSEOld##T##ToNEML2) 23 template <
typename T,
unsigned int state>
30 params.addClassDescription(
31 "Gather a MOOSE quantity of type " +
demangle(
typeid(T).
name()) +
32 " for insertion into the specified input or model parameter of a NEML2 model.");
33 params.template addRequiredParam<std::string>(
"from_moose",
34 "Name of the MOOSE quantity to read from");
35 MooseEnum moose_type(
"TIME SCALAR FUNCTION VARIABLE MATERIAL",
"MATERIAL");
36 params.template addParam<MooseEnum>(
37 "quantity_type", moose_type,
"Type of the MOOSE quantity to read from.");
44 params.set<
ExecFlagEnum>(
"execute_on") = execute_options;
49 template <
typename T,
unsigned int state>
58 ? &this->_fe_problem.getScalarVariable(_tid, getParam<
std::string>(
"from_moose")).sln()
62 ? &this->_fe_problem.getScalarVariable(_tid, getParam<
std::string>(
"from_moose"))
66 ? &this->_fe_problem.getFunction(getParam<
std::string>(
"from_moose"), _tid)
70 ? &this->template getMaterialPropertyByName<T>(getParam<
std::string>(
"from_moose"))
74 ? &this->template getMaterialPropertyOldByName<T>(getParam<
std::string>(
"from_moose"))
77 ? &this->_fe_problem.getStandardVariable(_tid, getParam<
std::string>(
"from_moose"))
81 ? &this->_fe_problem.getStandardVariable(_tid, getParam<
std::string>(
"from_moose"))
90 template <
typename T,
unsigned int state>
97 template <
typename T,
unsigned int state>
104 for (
unsigned int qp = 0; qp < _qrule->n_points(); qp++)
105 _buffer.emplace_back(qpData(qp));
108 template <
typename T,
unsigned int state>
116 _buffer.insert(_buffer.end(), m2n._buffer.begin(), m2n._buffer.end());
119 template <
typename T,
unsigned int state>
128 return state == 0 ? neml2::Scalar::full(_t, neml2::kFloat64)
129 : neml2::Scalar::full(_t_old, neml2::kFloat64);
131 return state == 0 ? neml2::Scalar::full((*_var_scalar)[0], neml2::kFloat64)
132 : neml2::Scalar::full((*_var_scalar_old)[0], neml2::kFloat64);
137 "Unbatched quantity cannot be of type MATERIAL or VARIABLE. This should never happen.");
139 mooseError(
"Invalid MOOSE quantity type. This should never happen.");
146 template <
typename T,
unsigned int state>
152 "elemMOOSEData should only be called for batched quantities. This should never happen.");
155 if constexpr (!std::is_same_v<T, Real>)
156 return state == 0 ? (*_mat_prop)[qp] : (*_mat_prop_old)[qp];
161 mooseError(
"Batched quantity cannot be of type TIME. This should never happen.");
163 mooseError(
"Batched quantity cannot be of type SCALAR. This should never happen.");
165 return _func->value(state == 0 ? _t : _t_old, _q_point[qp]);
167 return state == 0 ? (*_var)[qp] : (*_var_old)[qp];
169 return state == 0 ? (*_mat_prop)[qp] : (*_mat_prop_old)[qp];
171 mooseError(
"Invalid MOOSE quantity type. This should never happen.");
176 #define instantiateMOOSEQuantityToNEML2(T) \ 177 template class MOOSEQuantityToNEML2<T, 0>; \ 178 template class MOOSEQuantityToNEML2<T, 1>
std::string name(const ElemQuality q)
A MultiMooseEnum object to hold "execute_on" flags.
MOOSEQuantityToNEML2(const InputParameters ¶ms)
registerMOOSEQuantityToNEML2(Real)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
static InputParameters validParams()
Gather a MOOSE quantity for insertion into the NEML2 model.
ExecFlagEnum getDefaultExecFlagEnum()
void execute() override
Execute method.
void threadJoin(const UserObject &) override
Must override.
neml2::Tensor gatheredData() const override
Convert data gathered from MOOSE into neml2::Tensor.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
const ExecFlagType EXEC_LINEAR
instantiateMOOSEQuantityToNEML2(Real)
std::string demangle(const char *name)
T qpData(unsigned int) const
const ExecFlagType EXEC_NONLINEAR
static InputParameters validParams()
Common interface for inserting gathered MOOSE data into the NEML2 material model. ...
static InputParameters validParams()
void initialize() override
Called before execute() is ever called so that data can be cleared.
Base class for user-specific data.
neml2::Tensor fromBlob(const std::vector< T > &data)
Map from std::vector<T> to neml2::Tensor without copying the data.
const ExecFlagType EXEC_INITIAL