www.mooseframework.org
SplitCHParsed.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 "SplitCHParsed.h"
8 
9 template <>
10 InputParameters
12 {
13  InputParameters params = validParams<SplitCHCRes>();
14  params.addClassDescription(
15  "Split formulation Cahn-Hilliard Kernel that uses a DerivativeMaterial Free Energy");
16  params.addRequiredParam<MaterialPropertyName>(
17  "f_name", "Base name of the free energy function F defined in a DerivativeParsedMaterial");
18  params.addCoupledVar("args", "Vector of additional arguments to F");
19  return params;
20 }
21 
22 SplitCHParsed::SplitCHParsed(const InputParameters & parameters)
23  : DerivativeMaterialInterface<JvarMapKernelInterface<SplitCHCRes>>(parameters),
24  _nvar(_coupled_moose_vars.size()),
25  _dFdc(getMaterialPropertyDerivative<Real>("f_name", _var.name())),
26  _d2Fdc2(getMaterialPropertyDerivative<Real>("f_name", _var.name(), _var.name()))
27 {
28  // reserve space for derivatives
29  _d2Fdcdarg.resize(_nvar);
30 
31  // Iterate over all coupled variables
32  for (unsigned int i = 0; i < _nvar; ++i)
33  _d2Fdcdarg[i] =
34  &getMaterialPropertyDerivative<Real>("f_name", _var.name(), _coupled_moose_vars[i]->name());
35 }
36 
37 void
39 {
45  validateNonlinearCoupling<Real>("f_name", _var.name());
46  validateDerivativeMaterialPropertyBase<Real>("f_name");
47 }
48 
49 Real
50 SplitCHParsed::computeDFDC(PFFunctionType type)
51 {
52  switch (type)
53  {
54  case Residual:
55  return _dFdc[_qp];
56 
57  case Jacobian:
58  return _d2Fdc2[_qp] * _phi[_j][_qp];
59  }
60 
61  mooseError("Internal error");
62 }
63 
64 Real
66 {
67  if (jvar == _w_var)
69 
70  // get the coupled variable jvar is referring to
71  const unsigned int cvar = mapJvarToCvar(jvar);
72 
73  return (*_d2Fdcdarg[cvar])[_qp] * _phi[_j][_qp] * _test[_i][_qp];
74 }
const MaterialProperty< Real > & _d2Fdc2
Definition: SplitCHParsed.h:40
virtual void initialSetup()
Definition: SplitCHParsed.C:38
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
Definition: SplitCHParsed.C:65
const MaterialProperty< Real > & _dFdc
Definition: SplitCHParsed.h:39
std::vector< const MaterialProperty< Real > * > _d2Fdcdarg
Definition: SplitCHParsed.h:42
InputParameters validParams< SplitCHCRes >()
Definition: SplitCHCRes.C:11
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
Definition: SplitCHCRes.C:68
virtual Real computeDFDC(PFFunctionType type)
Definition: SplitCHParsed.C:50
const unsigned int _nvar
Definition: SplitCHParsed.h:38
SplitCHParsed(const InputParameters &parameters)
Definition: SplitCHParsed.C:22
The couple, SplitCHCRes and SplitCHWRes, splits the CH equation by replacing chemical potential with ...
Definition: SplitCHCRes.h:19
InputParameters validParams< SplitCHParsed >()
Definition: SplitCHParsed.C:11