www.mooseframework.org
KKSACBulkC.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 "KKSACBulkC.h"
8 
9 template <>
10 InputParameters
12 {
13  InputParameters params = validParams<KKSACBulkBase>();
14  params.addClassDescription("KKS model kernel (part 2 of 2) for the Bulk Allen-Cahn. This "
15  "includes all terms dependent on chemical potential.");
16  params.addRequiredCoupledVar("ca", "a-phase concentration");
17  params.addRequiredCoupledVar("cb", "b-phase concentration");
18  return params;
19 }
20 
21 KKSACBulkC::KKSACBulkC(const InputParameters & parameters)
22  : KKSACBulkBase(parameters),
23  _ca_name(getVar("ca", 0)->name()),
24  _ca_var(coupled("ca")),
25  _ca(coupledValue("ca")),
26  _cb_name(getVar("cb", 0)->name()),
27  _cb_var(coupled("cb")),
28  _cb(coupledValue("cb")),
29  _prop_h(getMaterialProperty<Real>("h_name")),
30  _prop_dFadca(getMaterialPropertyDerivative<Real>("fa_name", _ca_name)),
31  _prop_d2Fadca2(getMaterialPropertyDerivative<Real>("fa_name", _ca_name, _ca_name)),
32  _prop_d2Fbdcb2(getMaterialPropertyDerivative<Real>("fb_name", _cb_name, _cb_name))
33 {
34  // Resize to number of coupled variables (_nvar from KKSACBulkBase constructor)
35  _prop_d2Fadcadarg.resize(_nvar);
36 
37  // Iterate over all coupled variables
38  for (unsigned int i = 0; i < _nvar; ++i)
39  {
40  MooseVariable * cvar = _coupled_moose_vars[i];
41 
42  // get second partial derivatives wrt ca and other coupled variable
43  _prop_d2Fadcadarg[i] = &getMaterialPropertyDerivative<Real>("fa_name", _ca_name, cvar->name());
44  }
45 }
46 
47 Real
49 {
50  Real res = 0.0;
51  Real A1 = _prop_dFadca[_qp] * (_ca[_qp] - _cb[_qp]);
52 
53  switch (type)
54  {
55  case Residual:
56  return _prop_dh[_qp] * A1;
57 
58  case Jacobian:
59  res = _prop_d2h[_qp] * A1;
60 
61  return _phi[_j][_qp] * res;
62  }
63 
64  mooseError("Invalid type passed in");
65 }
66 
67 Real
69 {
70  // first get dependence of mobility _L on other variables using parent class
71  // member function
73  // Then add dependence of KKSACBulkF on other variables
74  // Treat ca and cb specially, as they appear in the residual
75  if (jvar == _ca_var)
76  {
77  res += _L[_qp] * _prop_dh[_qp] *
78  ((_ca[_qp] - _cb[_qp]) * _prop_d2Fadca2[_qp] + _prop_dFadca[_qp]) * _phi[_j][_qp] *
79  _test[_i][_qp];
80 
81  return res;
82  }
83 
84  if (jvar == _cb_var)
85  {
86  res -= _L[_qp] * _prop_dh[_qp] * _prop_dFadca[_qp] * _phi[_j][_qp] * _test[_i][_qp];
87 
88  return res;
89  }
90 
91  // for all other vars get the coupled variable jvar is referring to
92  const unsigned int cvar = mapJvarToCvar(jvar);
93 
94  res += _L[_qp] * _prop_dh[_qp] * (*_prop_d2Fadcadarg[cvar])[_qp] * (_ca[_qp] - _cb[_qp]) *
95  _phi[_j][_qp] * _test[_i][_qp];
96 
97  return res;
98 }
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
Definition: KKSACBulkC.C:68
unsigned int _cb_var
Definition: KKSACBulkC.h:41
KKSACBulkC(const InputParameters &parameters)
Definition: KKSACBulkC.C:21
const MaterialProperty< Real > & _L
Mobility.
Definition: ACBulk.h:44
const MaterialProperty< Real > & _prop_d2Fadca2
Second derivative of the free energy function .
Definition: KKSACBulkC.h:51
virtual Real computeDFDOP(PFFunctionType type)
Definition: KKSACBulkC.C:48
unsigned int _ca_var
Definition: KKSACBulkC.h:36
InputParameters validParams< KKSACBulkC >()
Definition: KKSACBulkC.C:11
std::string _ca_name
phase a concentration
Definition: KKSACBulkC.h:35
ACBulk child class that takes all the necessary data from a KKSBaseMaterial and sets up the Allen-Cah...
Definition: KKSACBulkBase.h:24
unsigned int _nvar
Number of coupled variables.
Definition: KKSACBulkBase.h:33
std::vector< const MaterialProperty< Real > * > _prop_d2Fadcadarg
Mixed partial derivatives of the free energy function wrt ca and any other coupled variables ...
Definition: KKSACBulkC.h:58
const MaterialProperty< Real > & _prop_dFadca
Derivative of the free energy function .
Definition: KKSACBulkC.h:48
const MaterialProperty< Real > & _prop_dh
Derivative of the switching function .
Definition: KKSACBulkBase.h:57
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
Definition: ACBulk.h:114
const VariableValue & _cb
Definition: KKSACBulkC.h:42
const VariableValue & _ca
Definition: KKSACBulkC.h:37
const MaterialProperty< Real > & _prop_d2h
Second derivative of the switching function .
Definition: KKSACBulkBase.h:60
InputParameters validParams< KKSACBulkBase >()
Definition: KKSACBulkBase.C:11