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