www.mooseframework.org
CoupledAllenCahn.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 "CoupledAllenCahn.h"
11 
12 registerMooseObject("PhaseFieldApp", CoupledAllenCahn);
13 
14 template <>
15 InputParameters
17 {
18  InputParameters params = ACBulk<Real>::validParams();
19  params.addClassDescription(
20  "Coupled Allen-Cahn Kernel that uses a DerivativeMaterial Free Energy");
21  params.addRequiredCoupledVar("v", "Coupled variable");
22  params.addRequiredParam<MaterialPropertyName>(
23  "f_name", "Base name of the free energy function F defined in a DerivativeParsedMaterial");
24  return params;
25 }
26 
27 CoupledAllenCahn::CoupledAllenCahn(const InputParameters & parameters)
28  : ACBulk<Real>(parameters),
29  _v_name(getVar("v", 0)->name()),
30  _nvar(_coupled_moose_vars.size()),
31  _dFdV(getMaterialPropertyDerivative<Real>("f_name", _v_name)),
32  _d2FdVdEta(getMaterialPropertyDerivative<Real>("f_name", _v_name, _var.name())),
33  _d2FdVdarg(_nvar)
34 {
35  // Iterate over all coupled variables
36  for (unsigned int i = 0; i < _nvar; ++i)
37  _d2FdVdarg[i] =
38  &getMaterialPropertyDerivative<Real>("f_name", _v_name, _coupled_moose_vars[i]->name());
39 }
40 
41 void
43 {
45  validateNonlinearCoupling<Real>("f_name");
46 }
47 
48 Real
49 CoupledAllenCahn::computeDFDOP(PFFunctionType type)
50 {
51  switch (type)
52  {
53  case Residual:
54  return _dFdV[_qp];
55 
56  case Jacobian:
57  return _d2FdVdEta[_qp] * _phi[_j][_qp];
58  }
59 
60  mooseError("Internal error");
61 }
62 
63 Real
65 {
66  // get the coupled variable jvar is referring to
67  const unsigned int cvar = mapJvarToCvar(jvar);
68 
70  _L[_qp] * (*_d2FdVdarg[cvar])[_qp] * _phi[_j][_qp] * _test[_i][_qp];
71 }
CoupledAllenCahn::computeDFDOP
virtual Real computeDFDOP(PFFunctionType type)
Definition: CoupledAllenCahn.C:49
ACBulk< Real >::Residual
Definition: ACBulk.h:40
ACBulk::computeQpOffDiagJacobian
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
Definition: ACBulk.h:116
CoupledAllenCahn::_d2FdVdEta
const MaterialProperty< Real > & _d2FdVdEta
Definition: CoupledAllenCahn.h:42
ACBulk
This is the Allen-Cahn equation base class that implements the bulk or local energy term of the equat...
Definition: ACBulk.h:24
CoupledAllenCahn.h
CoupledAllenCahn
CoupledAllenCahn uses the Free Energy function and derivatives provided by a DerivativeParsedMaterial...
Definition: CoupledAllenCahn.h:26
CoupledAllenCahn::computeQpOffDiagJacobian
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
Definition: CoupledAllenCahn.C:64
CoupledAllenCahn::_nvar
const unsigned int _nvar
Definition: CoupledAllenCahn.h:40
name
const std::string name
Definition: Setup.h:21
ACBulk::initialSetup
virtual void initialSetup()
Definition: ACBulk.h:85
ACBulk< Real >::Jacobian
Definition: ACBulk.h:39
CoupledAllenCahn::_v_name
VariableName _v_name
Definition: CoupledAllenCahn.h:38
validParams< CoupledAllenCahn >
InputParameters validParams< CoupledAllenCahn >()
Definition: CoupledAllenCahn.C:16
ACBulk::validParams
static InputParameters validParams()
Definition: ACBulk.h:74
CoupledAllenCahn::initialSetup
virtual void initialSetup()
Definition: CoupledAllenCahn.C:42
CoupledAllenCahn::_d2FdVdarg
std::vector< const MaterialProperty< Real > * > _d2FdVdarg
Definition: CoupledAllenCahn.h:44
CoupledAllenCahn::_dFdV
const MaterialProperty< Real > & _dFdV
Definition: CoupledAllenCahn.h:41
registerMooseObject
registerMooseObject("PhaseFieldApp", CoupledAllenCahn)
CoupledAllenCahn::CoupledAllenCahn
CoupledAllenCahn(const InputParameters &parameters)
Definition: CoupledAllenCahn.C:27
ACBulk< Real >::_L
const MaterialProperty< Real > & _L
Mobility.
Definition: ACBulk.h:46