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 18 of file CahnHilliardBase.h.

Member Typedef Documentation

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

Definition at line 27 of file CahnHilliardBase.h.

Constructor & Destructor Documentation

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

Definition at line 68 of file CahnHilliardBase.h.

69  : CHBulk<T>(parameters),
70  _nvar(_coupled_moose_vars.size()),
74  _grad_vars(_nvar + 1)
75 {
76  // derivatives w.r.t. and gradients of the kernel variable
78  &this->template getMaterialPropertyDerivative<Real>("f_name", _var.name(), _var.name());
79  _third_derivatives[0] = &this->template getMaterialPropertyDerivative<Real>(
80  "f_name", _var.name(), _var.name(), _var.name());
81  _grad_vars[0] = &(_grad_u);
82 
83  // Iterate over all coupled variables
84  for (unsigned int i = 0; i < _nvar; ++i)
85  {
86  const VariableName iname = _coupled_moose_vars[i]->name();
87  if (iname == _var.name())
88  mooseError("The kernel variable should not be specified in the coupled `args` parameter.");
89 
90  _second_derivatives[i + 1] =
91  &this->template getMaterialPropertyDerivative<Real>("f_name", _var.name(), iname);
92  _third_derivatives[i + 1] = &this->template getMaterialPropertyDerivative<Real>(
93  "f_name", _var.name(), _var.name(), iname);
94 
95  _third_cross_derivatives[i].resize(_nvar);
96  for (unsigned int j = 0; j < _nvar; ++j)
97  {
98  VariableName jname = _coupled_moose_vars[j]->name();
100  &this->template getMaterialPropertyDerivative<Real>("f_name", _var.name(), iname, jname);
101  }
102 
103  _grad_vars[i + 1] = &(_coupled_moose_vars[i]->gradSln());
104  }
105 }
This is the Cahn-Hilliard equation base class that implements the bulk or local energy term of the eq...
Definition: CHBulk.h:23
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

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

Implements CHBulk< T >.

Definition at line 122 of file CahnHilliardBase.h.

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

Reimplemented from CHBulk< T >.

Definition at line 145 of file CahnHilliardBase.h.

146 {
147  // get the coupled variable jvar is referring to
148  const unsigned int cvar = this->mapJvarToCvar(jvar);
149 
150  RealGradient J = _grad_u[_qp] * _phi[_j][_qp] * (*_third_derivatives[cvar + 1])[_qp] +
151  _grad_phi[_j][_qp] * (*_second_derivatives[cvar + 1])[_qp];
152 
153  for (unsigned int i = 0; i < _nvar; ++i)
154  J += _phi[_j][_qp] * (*_grad_vars[i + 1])[_qp] * (*_third_cross_derivatives[i][cvar])[_qp];
155 
156  return CHBulk<T>::computeQpOffDiagJacobian(jvar) + _M[_qp] * _grad_test[_i][_qp] * J;
157 }
const MaterialProperty< T > & _M
Mobility.
Definition: CHBulk.h:45
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
Definition: CHBulk.h:108
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
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 109 of file CahnHilliardBase.h.

110 {
116  this->template validateCoupling<Real>("f_name", _var.name());
117  this->template validateDerivativeMaterialPropertyBase<Real>("f_name");
118 }
template<typename T >
RealGradient CHBulk< T >::precomputeQpJacobian ( )
protectedvirtualinherited

Definition at line 98 of file CHBulk.h.

99 {
100  RealGradient grad_value = _M[_qp] * computeGradDFDCons(Jacobian) +
101  _dMdc[_qp] * _phi[_j][_qp] * computeGradDFDCons(Residual);
102 
103  return grad_value;
104 }
virtual RealGradient computeGradDFDCons(PFFunctionType type)=0
const MaterialProperty< T > & _M
Mobility.
Definition: CHBulk.h:45
const MaterialProperty< T > & _dMdc
Mobility derivative w.r.t. concentration.
Definition: CHBulk.h:48
template<typename T >
RealGradient CHBulk< T >::precomputeQpResidual ( )
protectedvirtualinherited

Definition at line 91 of file CHBulk.h.

92 {
93  return _M[_qp] * computeGradDFDCons(Residual);
94 }
virtual RealGradient computeGradDFDCons(PFFunctionType type)=0
const MaterialProperty< T > & _M
Mobility.
Definition: CHBulk.h:45
template<typename T >
InputParameters CahnHilliardBase< T >::validParams ( )
static

Definition at line 54 of file CahnHilliardBase.h.

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

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

Member Data Documentation

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

Mobility derivative w.r.t coupled variables.

Definition at line 51 of file CHBulk.h.

Referenced by CHBulk< T >::CHBulk(), and CHBulk< T >::computeQpOffDiagJacobian().

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

Mobility derivative w.r.t. concentration.

Definition at line 48 of file CHBulk.h.

Referenced by CHBulk< T >::precomputeQpJacobian().

template<typename T>
std::vector<const VariableGradient *> CahnHilliardBase< T >::_grad_vars
private
template<typename T>
const MaterialProperty<T>& CHBulk< T >::_M
protectedinherited
template<typename T>
const unsigned int CahnHilliardBase< T >::_nvar
private
template<typename T>
std::vector<const MaterialProperty<Real> *> CahnHilliardBase< T >::_second_derivatives
private
template<typename T>
std::vector<std::vector<const MaterialProperty<Real> *> > CahnHilliardBase< T >::_third_cross_derivatives
private
template<typename T>
std::vector<const MaterialProperty<Real> *> CahnHilliardBase< T >::_third_derivatives
private

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