www.mooseframework.org
KKSMultiACBulkF.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 "KKSMultiACBulkF.h"
8 
9 template <>
10 InputParameters
12 {
13  InputParameters params = validParams<KKSMultiACBulkBase>();
14  params.addClassDescription("KKS model kernel (part 1 of 2) for the Bulk Allen-Cahn. This "
15  "includes all terms NOT dependent on chemical potential.");
16  params.addRequiredParam<Real>("wi", "Double well height parameter");
17  params.addRequiredParam<MaterialPropertyName>(
18  "gi_name", "Base name for the double well function g_i(eta_i)");
19  return params;
20 }
21 
22 KKSMultiACBulkF::KKSMultiACBulkF(const InputParameters & parameters)
23  : KKSMultiACBulkBase(parameters),
24  _wi(getParam<Real>("wi")),
25  _prop_dgi(getMaterialPropertyDerivative<Real>("gi_name", _etai_name)),
26  _prop_d2gi(getMaterialPropertyDerivative<Real>("gi_name", _etai_name, _etai_name))
27 {
28 }
29 
30 Real
32 {
33  Real sum = 0.0;
34 
35  switch (type)
36  {
37  case Residual:
38  for (unsigned int n = 0; n < _num_j; ++n)
39  sum += (*_prop_dhjdetai[n])[_qp] * (*_prop_Fj[n])[_qp];
40 
41  return sum + _wi * _prop_dgi[_qp];
42 
43  case Jacobian:
44  // For when this kernel is used in the Lagrange multiplier equation
45  // In that case the Lagrange multiplier is the nonlinear variable
46  if (_etai_var != _var.number())
47  return 0.0;
48 
49  // For when eta_i is the nonlinear variable
50  for (unsigned int n = 0; n < _num_j; ++n)
51  sum += (*_prop_d2hjdetai2[n])[_qp] * (*_prop_Fj[n])[_qp];
52 
53  return _phi[_j][_qp] * (sum + _wi * _prop_d2gi[_qp]);
54  }
55 
56  mooseError("Invalid type passed in");
57 }
58 
59 Real
61 {
62  // get the coupled variable jvar is referring to
63  const unsigned int cvar = mapJvarToCvar(jvar);
64 
65  // first get dependence of mobility _L on other variables using parent class
66  // member function
68 
69  // Then add dependence of KKSMultiACBulkF on other variables
70  Real sum = 0.0;
71  for (unsigned int n = 0; n < _num_j; ++n)
72  sum += (*_prop_d2hjdetaidarg[n][cvar])[_qp] * (*_prop_Fj[n])[_qp] +
73  (*_prop_dhjdetai[n])[_qp] * (*_prop_dFjdarg[n][cvar])[_qp];
74 
75  // Handle the case when this kernel is used in the Lagrange multiplier equation
76  // In this case the second derivative of the barrier function contributes
77  // to the off-diagonal Jacobian
78  if (jvar == _etai_var)
79  sum += _wi * _prop_d2gi[_qp];
80 
81  res += _L[_qp] * sum * _phi[_j][_qp] * _test[_i][_qp];
82 
83  return res;
84 }
const MaterialProperty< Real > & _prop_dgi
Derivative of the double well function .
const MaterialProperty< Real > & _prop_d2gi
Second derivative of the double well function .
const MaterialProperty< Real > & _L
Mobility.
Definition: ACBulk.h:44
ACBulk child class that sets up necessary variables and materials for calculation of residual contrib...
Real _wi
double well height parameter
KKSMultiACBulkF(const InputParameters &parameters)
std::vector< std::vector< const MaterialProperty< Real > * > > _prop_d2hjdetaidarg
Second derivatives of the switching functions (needed for off-diagonal Jacobians) ...
std::vector< const MaterialProperty< Real > * > _prop_dhjdetai
Derivatives of the switching functions wrt the order parameter for this kernel.
virtual Real computeDFDOP(PFFunctionType type)
InputParameters validParams< KKSMultiACBulkBase >()
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
std::vector< const MaterialProperty< Real > * > _prop_Fj
Values of the free energy functions for each phase .
InputParameters validParams< KKSMultiACBulkF >()
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
Definition: ACBulk.h:114
std::vector< const MaterialProperty< Real > * > _prop_d2hjdetai2
Second derivatives of the switching functions wrt the order parameter for this kernel.
unsigned int _etai_var
index of order parameter that derivatives are taken wrt
std::vector< std::vector< const MaterialProperty< Real > * > > _prop_dFjdarg
Derivatives of the free energy functions (needed for off-diagonal Jacobians)