www.mooseframework.org
KKSSplitCHCRes.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 "KKSSplitCHCRes.h"
8 
9 template <>
10 InputParameters
12 {
13  InputParameters params = validParams<SplitCHBase>();
14  params.addClassDescription("KKS model kernel for the split Bulk Cahn-Hilliard term. This "
15  "operates on the chemical potential 'c' as the non-linear variable");
16  params.addRequiredParam<MaterialPropertyName>(
17  "fa_name",
18  "Base name of the free energy function F (f_base in the corresponding KKSBaseMaterial)");
19  params.addRequiredParam<MaterialPropertyName>(
20  "fb_name",
21  "Base name of the free energy function F (f_base in the corresponding KKSBaseMaterial)");
22  params.addRequiredCoupledVar(
23  "ca", "phase concentration corresponding to the non-linear variable of this kernel");
24  params.addRequiredCoupledVar(
25  "cb", "phase concentration corresponding to the non-linear variable of this kernel");
26  params.addCoupledVar("args_a", "Vector of additional arguments to Fa");
27  params.addParam<MaterialPropertyName>(
28  "h_name", "h", "Base name for the switching function h(eta)"); // TODO: everywhere else this
29  // is called just "h"
30  params.addRequiredCoupledVar("w",
31  "Chemical potenial non-linear helper variable for the split solve");
32 
33  return params;
34 }
35 
36 KKSSplitCHCRes::KKSSplitCHCRes(const InputParameters & parameters)
37  : DerivativeMaterialInterface<JvarMapKernelInterface<SplitCHBase>>(parameters),
38  // number of coupled variables (ca, args_a[])
39  _nvar(_coupled_moose_vars.size()),
40  _ca_var(coupled("ca")),
41  _ca_name(getVar("ca", 0)->name()),
42  _cb_var(coupled("cb")),
43  _cb_name(getVar("cb", 0)->name()),
44  _prop_h(getMaterialProperty<Real>("h_name")),
45  _first_derivative_Fa(getMaterialPropertyDerivative<Real>("fa_name", _ca_name)),
46  _second_derivative_Fa(getMaterialPropertyDerivative<Real>("fa_name", _ca_name, _ca_name)),
47  _second_derivative_Fb(getMaterialPropertyDerivative<Real>("fb_name", _cb_name, _cb_name)),
48  _w_var(coupled("w")),
49  _w(coupledValue("w"))
50 {
51  // reserve space for derivatives
52  _d2Fadcadarg.resize(_nvar);
53 
54  // Iterate over all coupled variables
55  for (unsigned int i = 0; i < _nvar; ++i)
56  {
57  MooseVariable * cvar = this->_coupled_moose_vars[i];
58 
59  // get the second derivative material property
60  _d2Fadcadarg[i] = &getMaterialPropertyDerivative<Real>("fa_name", _ca_name, cvar->name());
61  }
62 }
63 
64 void
66 {
67  validateNonlinearCoupling<Real>("fa_name");
68  validateDerivativeMaterialPropertyBase<Real>("fa_name");
69 }
70 
71 Real
73 {
74  Real residual = SplitCHBase::computeQpResidual();
75  residual += -_w[_qp] * _test[_i][_qp];
76 
77  return residual;
78 }
79 
87 Real
88 KKSSplitCHCRes::computeDFDC(PFFunctionType type)
89 {
90  switch (type)
91  {
92  case Residual:
93  return _first_derivative_Fa[_qp]; // dFa/dca ( = dFb/dcb = dF/dc)
94 
95  case Jacobian:
96  return 0.0;
97  }
98 
99  mooseError("Invalid type passed in");
100 }
101 
102 Real
104 {
105  // treat w variable explicitly
106  if (jvar == _w_var)
107  return -_phi[_j][_qp] * _test[_i][_qp];
108 
109  if (jvar == _ca_var)
110  return _phi[_j][_qp] * _test[_i][_qp] * _second_derivative_Fa[_qp];
111 
112  // get the coupled variable jvar is referring to
113  const unsigned int cvar = mapJvarToCvar(jvar);
114 
115  return _phi[_j][_qp] * _test[_i][_qp] * (*_d2Fadcadarg[cvar])[_qp];
116 }
virtual Real computeQpResidual()
Definition: SplitCHBase.C:37
unsigned int _ca_var
const MaterialProperty< Real > & _second_derivative_Fa
Second derivative .
KKSSplitCHCRes(const InputParameters &parameters)
const VariableValue & _w
const MaterialProperty< Real > & _first_derivative_Fa
Second derivative .
virtual Real computeQpResidual()
InputParameters validParams< SplitCHBase >()
Definition: SplitCHBase.C:11
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
The couple, SplitCHBase and SplitCHWRes, splits the CH equation by replacing chemical potential with ...
Definition: SplitCHBase.h:19
InputParameters validParams< KKSSplitCHCRes >()
unsigned int _nvar
Number of coupled variables.
std::vector< const MaterialProperty< Real > * > _d2Fadcadarg
Derivatives of with respect to all coupled variables.
virtual Real computeDFDC(PFFunctionType type)
Note that per product and chain rules: which is: .
VariableName _ca_name
unsigned int _w_var
Chemical potential.
virtual void initialSetup()