www.mooseframework.org
KKSSplitCHCRes.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 "KKSSplitCHCRes.h"
11 
12 registerMooseObject("PhaseFieldApp", KKSSplitCHCRes);
13 
16 {
18  params.addClassDescription(
19  "KKS model kernel for the split Bulk Cahn-Hilliard term. This kernel operates on the "
20  "physical concentration 'c' as the non-linear variable");
21  params.addRequiredParam<MaterialPropertyName>(
22  "fa_name",
23  "Base name of an arbitrary phase free energy function F (f_base in the corresponding "
24  "KKSBaseMaterial)");
25  params.addRequiredCoupledVar(
26  "ca", "phase concentration corresponding to the non-linear variable of this kernel");
27  params.addCoupledVar("args_a", "Vector of additional arguments to Fa");
28  params.addRequiredCoupledVar("w",
29  "Chemical potential non-linear helper variable for the split solve");
30  return params;
31 }
32 
35  _ca_var(coupled("ca")),
36  _ca_name(coupledName("ca", 0)),
37  _dFadca(getMaterialPropertyDerivative<Real>("fa_name", _ca_name)),
38  _d2Fadcadarg(_n_args),
39  _w_var(coupled("w")),
40  _w(coupledValue("w"))
41 {
42  // get the second derivative material property
43  for (unsigned int i = 0; i < _n_args; ++i)
44  _d2Fadcadarg[i] = &getMaterialPropertyDerivative<Real>("fa_name", _ca_name, i);
45 }
46 
47 void
49 {
50  validateNonlinearCoupling<Real>("fa_name");
51  validateDerivativeMaterialPropertyBase<Real>("fa_name");
52 }
53 
54 Real
56 {
58  residual += -_w[_qp] * _test[_i][_qp];
59 
60  return residual;
61 }
62 
70 Real
71 KKSSplitCHCRes::computeDFDC(PFFunctionType type)
72 {
73  switch (type)
74  {
75  case Residual:
76  return _dFadca[_qp]; // dFa/dca ( = dFb/dcb = dF/dc)
77 
78  case Jacobian:
79  return 0.0;
80  }
81 
82  mooseError("Invalid type passed in");
83 }
84 
85 Real
87 {
88  // treat w variable explicitly
89  if (jvar == _w_var)
90  return -_phi[_j][_qp] * _test[_i][_qp];
91 
92  // get the coupled variable jvar is referring to
93  const unsigned int cvar = mapJvarToCvar(jvar);
94  return _phi[_j][_qp] * _test[_i][_qp] * (*_d2Fadcadarg[cvar])[_qp];
95 }
virtual Real computeQpResidual()
Definition: SplitCHBase.C:39
SplitCHBulk child class that takes all the necessary data from a KKSBaseMaterial. ...
void mooseError(Args &&... args)
registerMooseObject("PhaseFieldApp", KKSSplitCHCRes)
static InputParameters validParams()
KKSSplitCHCRes(const InputParameters &parameters)
const VariableValue & _w
const MaterialProperty< Real > & _dFadca
chemical potential
void addRequiredParam(const std::string &name, const std::string &doc_string)
static InputParameters validParams()
Definition: SplitCHBase.C:13
virtual Real computeQpResidual()
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
void addCoupledVar(const std::string &name, const std::string &doc_string)
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
The couple, SplitCHBase and SplitCHWRes, splits the CH equation by replacing chemical potential with ...
Definition: SplitCHBase.h:17
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::vector< const MaterialProperty< Real > * > _d2Fadcadarg
Second derivatives of fa with respect to all ca and coupled variables.
void addClassDescription(const std::string &doc_string)
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()