www.mooseframework.org
ACInterface.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 /****************************************************************/
7 #include "ACInterface.h"
8 
9 template <>
10 InputParameters
12 {
13  InputParameters params = validParams<Kernel>();
14  params.addClassDescription("Gradient energy Allen-Cahn Kernel");
15  params.addParam<MaterialPropertyName>("mob_name", "L", "The mobility used with the kernel");
16  params.addParam<MaterialPropertyName>("kappa_name", "kappa_op", "The kappa used with the kernel");
17  params.addCoupledVar("args", "Vector of nonlinear variable arguments this object depends on");
18  params.addParam<bool>("variable_L",
19  true,
20  "The mobility is a function of any MOOSE variable (if "
21  "this is set to false L must be constant over the "
22  "entire domain!)");
23  return params;
24 }
25 
26 ACInterface::ACInterface(const InputParameters & parameters)
27  : DerivativeMaterialInterface<JvarMapKernelInterface<Kernel>>(parameters),
28  _L(getMaterialProperty<Real>("mob_name")),
29  _kappa(getMaterialProperty<Real>("kappa_name")),
30  _variable_L(getParam<bool>("variable_L")),
31  _dLdop(getMaterialPropertyDerivative<Real>("mob_name", _var.name())),
32  _d2Ldop2(getMaterialPropertyDerivative<Real>("mob_name", _var.name(), _var.name())),
33  _dkappadop(getMaterialPropertyDerivative<Real>("kappa_name", _var.name())),
34  _nvar(_coupled_moose_vars.size()),
35  _dLdarg(_nvar),
36  _d2Ldargdop(_nvar),
37  _d2Ldarg2(_nvar),
38  _dkappadarg(_nvar),
39  _gradarg(_nvar)
40 {
41  // Get mobility and kappa derivatives and coupled variable gradients
42  for (unsigned int i = 0; i < _nvar; ++i)
43  {
44  MooseVariable * ivar = _coupled_moose_vars[i];
45  const VariableName iname = ivar->name();
46  if (iname == _var.name())
47  mooseError("The kernel variable should not be specified in the coupled `args` parameter.");
48 
49  _dLdarg[i] = &getMaterialPropertyDerivative<Real>("mob_name", iname);
50  _dkappadarg[i] = &getMaterialPropertyDerivative<Real>("kappa_name", iname);
51 
52  _d2Ldargdop[i] = &getMaterialPropertyDerivative<Real>("mob_name", iname, _var.name());
53 
54  _gradarg[i] = &(ivar->gradSln());
55 
56  _d2Ldarg2[i].resize(_nvar);
57  for (unsigned int j = 0; j < _nvar; ++j)
58  _d2Ldarg2[i][j] =
59  &getMaterialPropertyDerivative<Real>("mob_name", iname, _coupled_moose_vars[j]->name());
60  }
61 }
62 
63 void
65 {
66  validateCoupling<Real>("mob_name");
67  validateCoupling<Real>("kappa_name");
68 }
69 
70 RealGradient
72 {
73  RealGradient g = _grad_u[_qp] * _dLdop[_qp];
74  for (unsigned int i = 0; i < _nvar; ++i)
75  g += (*_gradarg[i])[_qp] * (*_dLdarg[i])[_qp];
76  return g;
77 }
78 
79 RealGradient
81 {
82  // sum is the product rule gradient \f$ \nabla (L\psi) \f$
83  RealGradient sum = _L[_qp] * _grad_test[_i][_qp];
84 
85  if (_variable_L)
86  sum += gradL() * _test[_i][_qp];
87 
88  return _kappa[_qp] * sum;
89 }
90 
91 Real
93 {
94  return _grad_u[_qp] * kappaNablaLPsi();
95 }
96 
97 Real
99 {
100  // dsum is the derivative \f$ \frac\partial{\partial \eta} \left( \nabla (L\psi) \right) \f$
101  RealGradient dsum =
102  (_dkappadop[_qp] * _L[_qp] + _kappa[_qp] * _dLdop[_qp]) * _phi[_j][_qp] * _grad_test[_i][_qp];
103 
104  // compute the derivative of the gradient of the mobility
105  if (_variable_L)
106  {
107  RealGradient dgradL =
108  _grad_phi[_j][_qp] * _dLdop[_qp] + _grad_u[_qp] * _phi[_j][_qp] * _d2Ldop2[_qp];
109 
110  for (unsigned int i = 0; i < _nvar; ++i)
111  dgradL += (*_gradarg[i])[_qp] * _phi[_j][_qp] * (*_d2Ldargdop[i])[_qp];
112 
113  dsum += (_kappa[_qp] * dgradL + _dkappadop[_qp] * _phi[_j][_qp] * gradL()) * _test[_i][_qp];
114  }
115 
116  return _grad_phi[_j][_qp] * kappaNablaLPsi() + _grad_u[_qp] * dsum;
117 }
118 
119 Real
121 {
122  // get the coupled variable jvar is referring to
123  const unsigned int cvar = mapJvarToCvar(jvar);
124 
125  // dsum is the derivative \f$ \frac\partial{\partial \eta} \left( \nabla (L\psi) \right) \f$
126  RealGradient dsum = ((*_dkappadarg[cvar])[_qp] * _L[_qp] + _kappa[_qp] * (*_dLdarg[cvar])[_qp]) *
127  _phi[_j][_qp] * _grad_test[_i][_qp];
128 
129  // compute the derivative of the gradient of the mobility
130  if (_variable_L)
131  {
132  RealGradient dgradL = _grad_phi[_j][_qp] * (*_dLdarg[cvar])[_qp] +
133  _grad_u[_qp] * _phi[_j][_qp] * (*_d2Ldargdop[cvar])[_qp];
134 
135  for (unsigned int i = 0; i < _nvar; ++i)
136  dgradL += (*_gradarg[i])[_qp] * _phi[_j][_qp] * (*_d2Ldarg2[cvar][i])[_qp];
137 
138  dsum += (_kappa[_qp] * dgradL + _dkappadop[_qp] * _phi[_j][_qp] * gradL()) * _test[_i][_qp];
139  }
140 
141  return _grad_u[_qp] * dsum;
142 }
std::vector< const VariableGradient * > _gradarg
Gradients for all coupled variables.
Definition: ACInterface.h:69
virtual Real computeQpJacobian()
Definition: ACInterface.C:98
const MaterialProperty< Real > & _L
Mobility.
Definition: ACInterface.h:41
const bool _variable_L
flag set if L is a function of non-linear variables in args
Definition: ACInterface.h:46
RealGradient kappaNablaLPsi()
the term
Definition: ACInterface.C:80
ACInterface(const InputParameters &parameters)
Definition: ACInterface.C:26
InputParameters validParams< ACInterface >()
Definition: ACInterface.C:11
const MaterialProperty< Real > & _dLdop
Mobility derivatives w.r.t. order parameter.
Definition: ACInterface.h:49
std::vector< const MaterialProperty< Real > * > _d2Ldargdop
Definition: ACInterface.h:61
std::vector< const MaterialProperty< Real > * > _dkappadarg
kappa derivative w.r.t. other coupled variables
Definition: ACInterface.h:66
const unsigned int _nvar
number of coupled variables
Definition: ACInterface.h:57
virtual void initialSetup()
Definition: ACInterface.C:64
std::vector< const MaterialProperty< Real > * > _dLdarg
Mobility derivative w.r.t. other coupled variables.
Definition: ACInterface.h:60
std::vector< std::vector< const MaterialProperty< Real > * > > _d2Ldarg2
Definition: ACInterface.h:62
const MaterialProperty< Real > & _dkappadop
kappa derivative w.r.t. order parameter
Definition: ACInterface.h:54
const MaterialProperty< Real > & _kappa
Interfacial parameter.
Definition: ACInterface.h:43
const MaterialProperty< Real > & _d2Ldop2
Definition: ACInterface.h:50
virtual Real computeQpResidual()
Definition: ACInterface.C:92
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
Definition: ACInterface.C:120
RealGradient gradL()
Definition: ACInterface.C:71