www.mooseframework.org
CoupledMaterialDerivative.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
8 
9 template <>
10 InputParameters
12 {
13  InputParameters params = validParams<Kernel>();
14  params.addClassDescription(
15  "Kernel that implements (dFdv, test), where F is a property and v is a coupled variable");
16  params.addRequiredCoupledVar("v", "Variable for the parital derivatives of the free energy");
17  params.addParam<MaterialPropertyName>("f_name", "F", "The free energy material");
18  params.addCoupledVar("args", "Vector of other nonlinear variables this object depends on");
19  return params;
20 }
21 
22 CoupledMaterialDerivative::CoupledMaterialDerivative(const InputParameters & parameters)
23  : DerivativeMaterialInterface<JvarMapKernelInterface<Kernel>>(parameters),
24  _v_name(getVar("v", 0)->name()),
25  _v_var(coupled("v")),
26  _dFdv(getMaterialPropertyDerivative<Real>("f_name", _v_name)),
27  _d2Fdvdu(getMaterialPropertyDerivative<Real>("f_name", _v_name, _var.name())),
28  _d2Fdv2(getMaterialPropertyDerivative<Real>("f_name", _v_name, _v_name)),
29  _nvar(_coupled_moose_vars.size()),
30  _d2Fdvdarg(_nvar)
31 {
32  // Get free energy derivatives for other coupled variables besides v
33  for (unsigned int i = 0; i < _nvar; ++i)
34  {
35  MooseVariable * ivar = _coupled_moose_vars[i];
36  _d2Fdvdarg[i] = &getMaterialPropertyDerivative<Real>("mob_name", _v_name, ivar->name());
37  }
38 }
39 
40 void
42 {
43  validateNonlinearCoupling<Real>("f_name");
44 }
45 
46 Real
48 {
49  return _dFdv[_qp] * _test[_i][_qp];
50 }
51 
52 Real
54 {
55  return _d2Fdvdu[_qp] * _test[_i][_qp] * _phi[_j][_qp];
56 }
57 
58 Real
60 {
61  // Jacobian w.r.t. v
62  if (jvar == _v_var)
63  return _d2Fdv2[_qp] * _test[_i][_qp] * _phi[_j][_qp];
64 
65  // for all other vars get the coupled variable jvar is referring to
66  const unsigned int cvar = mapJvarToCvar(jvar);
67 
68  return (*_d2Fdvdarg[cvar])[_qp] * _test[_i][_qp] * _phi[_j][_qp];
69 }
virtual Real computeQpOffDiagJacobian(unsigned int jvar) override
const MaterialProperty< Real > & _d2Fdvdu
Free energy 2nd order derivative w.r.t. v then u.
const unsigned int _nvar
Number of coupled variables.
virtual void initialSetup() override
const MaterialProperty< Real > & _d2Fdv2
Free energy 2nd order derivative w.r.t. v.
virtual Real computeQpResidual() override
CoupledMaterialDerivative(const InputParameters &parameters)
virtual Real computeQpJacobian() override
std::vector< const MaterialProperty< Real > * > _d2Fdvdarg
Reaction rate derivatives w.r.t. other coupled variables.
InputParameters validParams< CoupledMaterialDerivative >()
const MaterialProperty< Real > & _dFdv
Free Energy derivative w.r.t. v.