12 #include "libmesh/quadrature.h" 20 params.
addClassDescription(
"Material to provide a function (such as a free energy) and its " 21 "derivatives w.r.t. the coupled variables");
23 "Flag to indicate if third derivatives are needed",
24 "Use derivative_order instead.");
27 "derivative_order>=2 & derivative_order<=3",
28 "Maximum order of derivatives taken (2 or 3)");
36 _third_derivatives(this->template getParam<unsigned
int>(
"derivative_order") == 3)
42 for (
unsigned int i = 0; i <
_nargs; ++i)
50 for (
unsigned int j = 0; j <
_nargs; ++j)
56 for (
unsigned int i = 0; i <
_nargs; ++i)
62 for (
unsigned int j = i; j <
_nargs; ++j)
65 _prop_d2F[i][j] =
_prop_d2F[j][i] = &this->
template declarePropertyDerivative<Real, is_ad>(
71 for (
unsigned int k = j; k <
_nargs; ++k)
78 &this->
template declarePropertyDerivative<Real, is_ad>(
91 bool needs_third_derivatives =
false;
93 if (!this->_fe_problem.isMatPropRequested(_F_name))
96 for (
unsigned int i = 0; i < _nargs; ++i)
98 if (!this->_fe_problem.isMatPropRequested(
99 this->derivativePropertyNameFirst(_F_name, _arg_names[i])))
103 for (
unsigned int j = i; j < _nargs; ++j)
105 if (!this->_fe_problem.isMatPropRequested(
106 this->derivativePropertyNameSecond(_F_name, _arg_names[i], _arg_names[j])))
107 _prop_d2F[i][j] = _prop_d2F[j][i] = NULL;
110 if (_third_derivatives)
112 for (
unsigned int k = j; k < _nargs; ++k)
114 if (!this->_fe_problem.isMatPropRequested(this->derivativePropertyNameThird(
115 _F_name, _arg_names[i], _arg_names[j], _arg_names[k])))
116 _prop_d3F[i][j][k] = _prop_d3F[k][i][j] = _prop_d3F[j][k][i] = _prop_d3F[k][j][i] =
117 _prop_d3F[j][i][k] = _prop_d3F[i][k][j] = NULL;
119 needs_third_derivatives =
true;
122 if (!needs_third_derivatives)
123 mooseWarning(
"This simulation does not actually need the third derivatives of " 124 "DerivativeFunctionMaterialBaseTempl " +
131 template <
bool is_ad>
135 for (_qp = 0; _qp < _qrule->n_points(); _qp++)
139 (*_prop_F)[_qp] = computeF();
141 for (
unsigned int i = 0; i < _nargs; ++i)
145 (*_prop_dF[i])[_qp] = computeDF(_arg_numbers[i]);
148 for (
unsigned int j = i; j < _nargs; ++j)
151 (*_prop_d2F[i][j])[_qp] = computeD2F(_arg_numbers[i], _arg_numbers[j]);
154 if (_third_derivatives)
156 for (
unsigned int k = j; k < _nargs; ++k)
157 if (_prop_d3F[i][j][k])
158 (*_prop_d3F[i][j][k])[_qp] =
159 computeD3F(_arg_numbers[i], _arg_numbers[j], _arg_numbers[k]);
std::string name(const ElemQuality q)
virtual bool isCoupledConstant(const std::string &var_name) const
Returns true if a variable passed as a coupled value is really a constant.
Material base class, central to all Materials that provide a Function as a material property value...
void mooseWarning(Args &&... args)
Emit a warning message with the given stringified, concatenated args.
std::string _F_name
Name of the function value material property and used as a base name to concatenate the material prop...
std::vector< std::string > _arg_names
String vector of all argument names.
DerivativeFunctionMaterialBaseTempl(const InputParameters ¶meters)
std::vector< std::vector< GenericMaterialProperty< Real, is_ad > * > > _prop_d2F
Material properties to store the second derivatives.
static InputParameters validParams()
void initialSetup() override
Check if we got the right number of components in the 'coupled_variables' vector. ...
bool _third_derivatives
Calculate (and allocate memory for) the third derivatives of the free energy.
Material base class to compute a function and its derivatives.
std::vector< std::vector< std::vector< GenericMaterialProperty< Real, is_ad > * > > > _prop_d3F
Material properties to store the third derivatives.
void computeProperties() override
Performs the quadrature point loop, calling computeQpProperties.
unsigned int _nargs
Number of coupled arguments.
void ErrorVector unsigned int
std::vector< GenericMaterialProperty< Real, is_ad > * > _prop_dF
Material properties to store the derivatives of f with respect to arg[i].
static InputParameters validParams()