12 #include "libmesh/quadrature.h" 23 params.
addParam<std::vector<std::string>>(
"sum_materials",
24 "Base name of the parsed sum material property");
30 "Vector of displacement gradient variables (see " 31 "Modules/PhaseField/DisplacementGradients " 35 params.
addParam<std::vector<Real>>(
"prefactor", {},
"Prefactor to multiply the sum term with.");
36 params.
addParam<
Real>(
"constant", 0.0,
"Constant to be added to the prefactor multiplied sum.");
38 params.
addParam<
bool>(
"validate_coupling",
40 "Check if all variables the specified materials depend on are listed in " 41 "the `coupled_variables` parameter.");
50 _sum_materials(this->template getParam<
std::vector<
std::string>>(
"sum_materials")),
51 _num_materials(_sum_materials.size()),
52 _prefactor(_num_materials, 1.0),
53 _constant(this->template getParam<
Real>(
"constant")),
54 _validate_coupling(this->template getParam<bool>(
"validate_coupling"))
58 mooseError(
"Please supply at least one material to sum in DerivativeSumMaterial ",
name());
61 std::vector<Real> p = this->
template getParam<std::vector<Real>>(
"prefactor");
66 else if (p.size() != 0)
67 mooseError(
"Supply the same number of sum materials and prefactors.");
82 for (
unsigned int i = 0; i <
_nargs; ++i)
84 _summand_dF[n][i] = &this->
template getMaterialPropertyDerivative<Real, is_ad>(
91 for (
unsigned int j = 0; j <
_nargs; ++j)
93 _summand_d2F[n][i][j] = &this->
template getMaterialPropertyDerivative<Real, is_ad>(
100 for (
unsigned int k = 0; k <
_nargs; ++k)
101 _summand_d3F[n][i][j][k] = &this->
template getMaterialPropertyDerivative<Real, is_ad>(
109 template <
bool is_ad>
113 if (_validate_coupling)
114 for (
unsigned int n = 0; n < _num_materials; ++n)
115 this->
template validateCoupling<Real>(_sum_materials[n]);
118 template <
bool is_ad>
122 unsigned int i, j, k;
124 for (_qp = 0; _qp < _qrule->n_points(); _qp++)
129 (*_prop_F)[_qp] = (*_summand_F[0])[_qp] * _prefactor[0];
130 for (
unsigned int n = 1; n < _num_materials; ++n)
131 (*_prop_F)[_qp] += (*_summand_F[n])[_qp] * _prefactor[n];
134 for (i = 0; i < _nargs; ++i)
139 (*_prop_dF[i])[_qp] = (*_summand_dF[0][i])[_qp] * _prefactor[0];
140 for (
unsigned int n = 1; n < _num_materials; ++n)
141 (*_prop_dF[i])[_qp] += (*_summand_dF[n][i])[_qp] * _prefactor[n];
145 for (j = i; j < _nargs; ++j)
149 (*_prop_d2F[i][j])[_qp] = (*_summand_d2F[0][i][j])[_qp] * _prefactor[0];
150 for (
unsigned int n = 1; n < _num_materials; ++n)
151 (*_prop_d2F[i][j])[_qp] += (*_summand_d2F[n][i][j])[_qp] * _prefactor[n];
155 if (_third_derivatives)
157 for (k = j; k < _nargs; ++k)
158 if (_prop_d3F[i][j][k])
160 (*_prop_d3F[i][j][k])[_qp] = (*_summand_d3F[0][i][j][k])[_qp] * _prefactor[0];
161 for (
unsigned int n = 1; n < _num_materials; ++n)
162 (*_prop_d3F[i][j][k])[_qp] += (*_summand_d3F[n][i][j][k])[_qp] * _prefactor[n];
DerivativeSumMaterialTempl(const InputParameters ¶meters)
std::vector< std::string > _sum_materials
std::vector< std::vector< std::vector< const GenericMaterialProperty< Real, is_ad > * > > > _summand_d2F
Second derivatives of the summands.
std::vector< std::vector< std::vector< std::vector< const GenericMaterialProperty< Real, is_ad > * > > > > _summand_d3F
Third derivatives of the summands.
std::vector< Real > _prefactor
arguments to construct a sum of the form
virtual void initialSetup()
Check if we got the right number of components in the 'coupled_variables' vector. ...
std::vector< std::string > _arg_names
String vector of all argument names.
const std::string & name() const
Get the name of the class.
std::vector< std::vector< const GenericMaterialProperty< Real, is_ad > * > > _summand_dF
Derivatives of the summands with respect to arg[i].
virtual void computeProperties()
Performs the quadrature point loop, calling computeQpProperties.
registerMooseObject("MooseApp", DerivativeSumMaterial)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
bool _third_derivatives
Calculate (and allocate memory for) the third derivatives of the free energy.
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
Material base class to compute a function and its derivatives.
unsigned int _nargs
Number of coupled arguments.
std::vector< const GenericMaterialProperty< Real, is_ad > * > _summand_F
Function values of the summands.
unsigned int _num_materials
static InputParameters validParams()
static InputParameters validParams()