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)
39 _prop_dF.resize(_nargs, NULL);
40 _prop_d2F.resize(_nargs);
41 _prop_d3F.resize(_nargs);
42 for (
unsigned int i = 0; i < _nargs; ++i)
44 _prop_d2F[i].resize(_nargs, NULL);
46 if (_third_derivatives)
48 _prop_d3F[i].resize(_nargs);
50 for (
unsigned int j = 0; j < _nargs; ++j)
51 _prop_d3F[i][j].resize(_nargs, NULL);
56 for (
unsigned int i = 0; i < _nargs; ++i)
59 _prop_dF[i] = &this->
template declarePropertyDerivative<Real, is_ad>(_F_name, _arg_names[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>(
66 _F_name, _arg_names[i], _arg_names[j]);
69 if (_third_derivatives)
71 for (
unsigned int k = j; k < _nargs; ++k)
76 _prop_d3F[i][j][k] = _prop_d3F[k][i][j] = _prop_d3F[j][k][i] = _prop_d3F[k][j][i] =
77 _prop_d3F[j][i][k] = _prop_d3F[i][k][j] =
78 &this->
template declarePropertyDerivative<Real, is_ad>(
79 _F_name, _arg_names[i], _arg_names[j], _arg_names[k]);
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 " +
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]);
void mooseWarning(Args &&... args)
Emit a warning message with the given stringified, concatenated args.
void ErrorVector unsigned int
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 to compute a function and its derivatives.
static InputParameters validParams()
DerivativeFunctionMaterialBaseTempl(const InputParameters ¶meters)
void initialSetup() override
Check if we got the right number of components in the 'coupled_variables' vector.
void computeProperties() override
Performs the quadrature point loop, calling computeQpProperties.
Material base class, central to all Materials that provide a Function as a material property value.
static InputParameters validParams()
std::string name(const ElemQuality q)