www.mooseframework.org
Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
CahnHilliardBase< T > Class Template Reference

CahnHilliardBase implements the residual of the Cahn-Hilliard equation in a general way that can be templated to a scalar or tensor mobility. More...

#include <CahnHilliardBase.h>

Inheritance diagram for CahnHilliardBase< T >:
[legend]

Public Member Functions

 CahnHilliardBase (const InputParameters &parameters)
 
virtual void initialSetup ()
 

Static Public Member Functions

static InputParameters validParams ()
 

Protected Types

typedef CHBulk< T >::PFFunctionType PFFunctionType
 

Protected Member Functions

virtual RealGradient computeGradDFDCons (PFFunctionType type)
 
virtual Real computeQpOffDiagJacobian (unsigned int jvar)
 
virtual RealGradient precomputeQpResidual ()
 
virtual RealGradient precomputeQpJacobian ()
 

Protected Attributes

const MaterialProperty< T > & _M
 Mobility. More...
 
const MaterialProperty< T > & _dMdc
 Mobility derivative w.r.t. concentration. More...
 
std::vector< const MaterialProperty< T > * > _dMdarg
 Mobility derivative w.r.t coupled variables. More...
 

Private Attributes

const unsigned int _nvar
 
std::vector< const MaterialProperty< Real > * > _second_derivatives
 
std::vector< const MaterialProperty< Real > * > _third_derivatives
 
std::vector< std::vector< const MaterialProperty< Real > * > > _third_cross_derivatives
 
std::vector< const VariableGradient * > _grad_vars
 

Detailed Description

template<typename T>
class CahnHilliardBase< T >

CahnHilliardBase implements the residual of the Cahn-Hilliard equation in a general way that can be templated to a scalar or tensor mobility.

Definition at line 21 of file CahnHilliardBase.h.

Member Typedef Documentation

◆ PFFunctionType

template<typename T>
typedef CHBulk<T>::PFFunctionType CahnHilliardBase< T >::PFFunctionType
protected

Definition at line 30 of file CahnHilliardBase.h.

Constructor & Destructor Documentation

◆ CahnHilliardBase()

template<typename T >
CahnHilliardBase< T >::CahnHilliardBase ( const InputParameters &  parameters)

Definition at line 73 of file CahnHilliardBase.h.

74  : CHBulk<T>(parameters),
75  _nvar(_coupled_moose_vars.size()),
79  _grad_vars(_nvar + 1)
80 {
81  // derivatives w.r.t. and gradients of the kernel variable
83  &this->template getMaterialPropertyDerivative<Real>("f_name", _var.name(), _var.name());
84  _third_derivatives[0] = &this->template getMaterialPropertyDerivative<Real>(
85  "f_name", _var.name(), _var.name(), _var.name());
86  _grad_vars[0] = &(_grad_u);
87 
88  // Iterate over all coupled variables
89  for (unsigned int i = 0; i < _nvar; ++i)
90  {
91  const VariableName iname = _coupled_moose_vars[i]->name();
92  if (iname == _var.name())
93  this->paramError(
94  "args", "The kernel variable should not be specified in the coupled `args` parameter.");
95 
96  _second_derivatives[i + 1] =
97  &this->template getMaterialPropertyDerivative<Real>("f_name", _var.name(), iname);
98  _third_derivatives[i + 1] = &this->template getMaterialPropertyDerivative<Real>(
99  "f_name", _var.name(), _var.name(), iname);
100 
101  _third_cross_derivatives[i].resize(_nvar);
102  for (unsigned int j = 0; j < _nvar; ++j)
103  {
104  VariableName jname = _coupled_moose_vars[j]->name();
106  &this->template getMaterialPropertyDerivative<Real>("f_name", _var.name(), iname, jname);
107  }
108 
109  _grad_vars[i + 1] = &_subproblem.getStandardVariable(_tid, iname).gradSln();
110  }
111 }
This is the Cahn-Hilliard equation base class that implements the bulk or local energy term of the eq...
Definition: CHBulk.h:26
const unsigned int _nvar
std::vector< const MaterialProperty< Real > * > _second_derivatives
std::vector< const VariableGradient * > _grad_vars
std::vector< const MaterialProperty< Real > * > _third_derivatives
std::vector< std::vector< const MaterialProperty< Real > * > > _third_cross_derivatives

Member Function Documentation

◆ computeGradDFDCons()

template<typename T >
RealGradient CahnHilliardBase< T >::computeGradDFDCons ( PFFunctionType  type)
protectedvirtual

Implements CHBulk< T >.

Definition at line 128 of file CahnHilliardBase.h.

129 {
130  RealGradient res = 0.0;
131 
132  switch (type)
133  {
134  case CHBulk<T>::Residual:
135  for (unsigned int i = 0; i <= _nvar; ++i)
136  res += (*_grad_vars[i])[_qp] * (*_second_derivatives[i])[_qp];
137  return res;
138 
139  case CHBulk<T>::Jacobian:
140  res = _grad_phi[_j][_qp] * (*_second_derivatives[0])[_qp];
141  for (unsigned int i = 0; i <= _nvar; ++i)
142  res += _phi[_j][_qp] * (*_grad_vars[i])[_qp] * (*_third_derivatives[i])[_qp];
143  return res;
144  }
145 
146  mooseError("Internal error");
147 }
This is the Cahn-Hilliard equation base class that implements the bulk or local energy term of the eq...
Definition: CHBulk.h:26
const unsigned int _nvar
std::vector< const MaterialProperty< Real > * > _second_derivatives
std::vector< const VariableGradient * > _grad_vars
std::vector< const MaterialProperty< Real > * > _third_derivatives

◆ computeQpOffDiagJacobian()

template<typename T >
Real CahnHilliardBase< T >::computeQpOffDiagJacobian ( unsigned int  jvar)
protectedvirtual

Reimplemented from CHBulk< T >.

Definition at line 151 of file CahnHilliardBase.h.

152 {
153  // get the coupled variable jvar is referring to
154  const unsigned int cvar = this->mapJvarToCvar(jvar);
155 
156  RealGradient J = _grad_u[_qp] * _phi[_j][_qp] * (*_third_derivatives[cvar + 1])[_qp] +
157  _grad_phi[_j][_qp] * (*_second_derivatives[cvar + 1])[_qp];
158 
159  for (unsigned int i = 0; i < _nvar; ++i)
160  J += _phi[_j][_qp] * (*_grad_vars[i + 1])[_qp] * (*_third_cross_derivatives[i][cvar])[_qp];
161 
162  return CHBulk<T>::computeQpOffDiagJacobian(jvar) + _M[_qp] * _grad_test[_i][_qp] * J;
163 }
const MaterialProperty< T > & _M
Mobility.
Definition: CHBulk.h:48
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
Definition: CHBulk.h:111
const unsigned int _nvar
std::vector< const MaterialProperty< Real > * > _second_derivatives
std::vector< const VariableGradient * > _grad_vars
std::vector< const MaterialProperty< Real > * > _third_derivatives
std::vector< std::vector< const MaterialProperty< Real > * > > _third_cross_derivatives

◆ initialSetup()

template<typename T >
void CahnHilliardBase< T >::initialSetup ( )
virtual

Check if both the non-linear as well as the auxiliary variables variables are coupled. Derivatives with respect to both types of variables contribute the residual.

Reimplemented from CHBulk< T >.

Definition at line 115 of file CahnHilliardBase.h.

116 {
122  this->template validateCoupling<Real>("f_name", _var.name());
123  this->template validateDerivativeMaterialPropertyBase<Real>("f_name");
124 }

◆ precomputeQpJacobian()

template<typename T >
RealGradient CHBulk< T >::precomputeQpJacobian ( )
protectedvirtualinherited

Definition at line 101 of file CHBulk.h.

102 {
103  RealGradient grad_value = _M[_qp] * computeGradDFDCons(Jacobian) +
104  _dMdc[_qp] * _phi[_j][_qp] * computeGradDFDCons(Residual);
105 
106  return grad_value;
107 }
virtual RealGradient computeGradDFDCons(PFFunctionType type)=0
const MaterialProperty< T > & _M
Mobility.
Definition: CHBulk.h:48
const MaterialProperty< T > & _dMdc
Mobility derivative w.r.t. concentration.
Definition: CHBulk.h:51

◆ precomputeQpResidual()

template<typename T >
RealGradient CHBulk< T >::precomputeQpResidual ( )
protectedvirtualinherited

Definition at line 94 of file CHBulk.h.

95 {
96  return _M[_qp] * computeGradDFDCons(Residual);
97 }
virtual RealGradient computeGradDFDCons(PFFunctionType type)=0
const MaterialProperty< T > & _M
Mobility.
Definition: CHBulk.h:48

◆ validParams()

template<typename T >
InputParameters CahnHilliardBase< T >::validParams ( )
static

Definition at line 59 of file CahnHilliardBase.h.

Referenced by validParams< CahnHilliard >(), and validParams< CahnHilliardAniso >().

60 {
61  InputParameters params = CHBulk<Real>::validParams();
62  params.addClassDescription("Cahn-Hilliard Kernel that uses a DerivativeMaterial Free Energy");
63  params.addRequiredParam<MaterialPropertyName>(
64  "f_name", "Base name of the free energy function F defined in a DerivativeParsedMaterial");
65  params.addCoupledVar("displacement_gradients",
66  "Vector of displacement gradient variables (see "
67  "Modules/PhaseField/DisplacementGradients "
68  "action)");
69  return params;
70 }
static InputParameters validParams()
Definition: CHBulk.h:76

Member Data Documentation

◆ _dMdarg

template<typename T>
std::vector<const MaterialProperty<T> *> CHBulk< T >::_dMdarg
protectedinherited

Mobility derivative w.r.t coupled variables.

Definition at line 54 of file CHBulk.h.

Referenced by CHBulk< Real >::CHBulk().

◆ _dMdc

template<typename T>
const MaterialProperty<T>& CHBulk< T >::_dMdc
protectedinherited

Mobility derivative w.r.t. concentration.

Definition at line 51 of file CHBulk.h.

◆ _grad_vars

template<typename T>
std::vector<const VariableGradient *> CahnHilliardBase< T >::_grad_vars
private

Definition at line 54 of file CahnHilliardBase.h.

Referenced by CahnHilliardBase< Real >::CahnHilliardBase().

◆ _M

template<typename T>
const MaterialProperty<T>& CHBulk< T >::_M
protectedinherited

Mobility.

Definition at line 48 of file CHBulk.h.

◆ _nvar

template<typename T>
const unsigned int CahnHilliardBase< T >::_nvar
private

Definition at line 50 of file CahnHilliardBase.h.

Referenced by CahnHilliardBase< Real >::CahnHilliardBase().

◆ _second_derivatives

template<typename T>
std::vector<const MaterialProperty<Real> *> CahnHilliardBase< T >::_second_derivatives
private

Definition at line 51 of file CahnHilliardBase.h.

Referenced by CahnHilliardBase< Real >::CahnHilliardBase().

◆ _third_cross_derivatives

template<typename T>
std::vector<std::vector<const MaterialProperty<Real> *> > CahnHilliardBase< T >::_third_cross_derivatives
private

Definition at line 53 of file CahnHilliardBase.h.

Referenced by CahnHilliardBase< Real >::CahnHilliardBase().

◆ _third_derivatives

template<typename T>
std::vector<const MaterialProperty<Real> *> CahnHilliardBase< T >::_third_derivatives
private

Definition at line 52 of file CahnHilliardBase.h.

Referenced by CahnHilliardBase< Real >::CahnHilliardBase().


The documentation for this class was generated from the following file: