21 "Kernel for Allen-Cahn equation that adds derivatives of switching functions and energies");
23 "Fj_names",
"List of free energies for each phase. Place in same order as hj_names!");
25 "hj_names",
"Switching Function Materials that provide h. Place in same order as Fj_names!");
30 ACSwitchingTempl<is_ad>::ACSwitchingTempl(
const InputParameters & parameters)
31 : ACSwitchingBase<is_ad>(parameters),
32 _etai_name(_var.
name()),
33 _Fj_names(this->template getParam<
std::vector<MaterialPropertyName>>(
"Fj_names")),
34 _num_j(_Fj_names.size()),
36 _hj_names(this->template getParam<
std::vector<MaterialPropertyName>>(
"hj_names")),
37 _prop_dhjdetai(_num_j)
40 if (_num_j != _hj_names.size())
41 this->paramError(
"hj_names",
"Need to pass in as many hj_names as Fj_names");
44 for (
unsigned int n = 0; n < _num_j; ++n)
47 _prop_Fj[n] = &this->
template getGenericMaterialProperty<Real, is_ad>(_Fj_names[n]);
51 &this->
template getMaterialPropertyDerivative<Real, is_ad>(_hj_names[n], _etai_name);
56 : ACSwitchingTempl<false>(parameters),
57 _prop_dFjdarg(_num_j),
58 _prop_d2hjdetai2(_num_j),
59 _prop_d2hjdetaidarg(_num_j)
62 for (
unsigned int n = 0; n < _num_j; ++n)
65 _prop_dFjdarg[n].resize(_n_args);
67 &getMaterialPropertyDerivative<Real>(_hj_names[n], _etai_name, _etai_name);
68 _prop_d2hjdetaidarg[n].resize(_n_args);
70 for (
unsigned int i = 0; i < _n_args; ++i)
73 _prop_dFjdarg[n][i] = &getMaterialPropertyDerivative<Real>(_Fj_names[n], i);
76 _prop_d2hjdetaidarg[n][i] = &getMaterialPropertyDerivative<Real>(_hj_names[n], _etai_name, i);
83 ACSwitchingTempl<is_ad>::initialSetup()
85 ACSwitchingBase<is_ad>::initialSetup();
86 for (
unsigned int n = 0; n < _num_j; ++n)
91 ACSwitching::initialSetup()
93 ACSwitchingTempl<false>::initialSetup();
94 for (
unsigned int n = 0; n < _num_j; ++n)
95 validateNonlinearCoupling<Real>(_Fj_names[n]);
99 ACSwitching::computeDFDOP(PFFunctionType type)
106 for (
unsigned int n = 0; n < _num_j; ++n)
107 sum += (*_prop_dhjdetai[n])[_qp] * (*_prop_Fj[n])[_qp];
112 for (
unsigned int n = 0; n < _num_j; ++n)
113 sum += (*_prop_d2hjdetai2[n])[_qp] * (*_prop_Fj[n])[_qp];
115 return _phi[_j][_qp] * sum;
118 mooseError(
"Invalid type passed in to ACSwitching::computeDFDOP");
122 ADACSwitching::computeDFDOP()
125 for (
unsigned int n = 0; n < _num_j; ++n)
126 sum += (*_prop_dhjdetai[n])[_qp] * (*_prop_Fj[n])[_qp];
131 ACSwitching::computeQpOffDiagJacobian(
unsigned int jvar)
134 const unsigned int cvar = mapJvarToCvar(jvar);
142 for (
unsigned int n = 0; n < _num_j; ++n)
143 sum += (*_prop_d2hjdetaidarg[n][cvar])[_qp] * (*_prop_Fj[n])[_qp] +
144 (*_prop_dhjdetai[n])[_qp] * (*_prop_dFjdarg[n][cvar])[_qp];
146 res += _L[_qp] * sum * _phi[_j][_qp] * _test[_i][_qp];
151 template class ACSwitchingTempl<false>;
152 template class ACSwitchingTempl<true>;
Moose::GenericType< Real, is_ad > GenericReal
void mooseError(Args &&... args)
DualNumber< Real, DNDerivativeType, true > ADReal
registerMooseObject("PhaseFieldApp", ACSwitching)
InputParameters validParams()
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual Real computeQpOffDiagJacobian(unsigned int jvar)