www.mooseframework.org
Public Types | 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 Types

typedef DerivativeMaterialPropertyNameInterface::SymbolName SymbolName
 

Public Member Functions

 CahnHilliardBase (const InputParameters &parameters)
 
virtual void initialSetup ()
 
const GenericMaterialProperty< U, is_ad > & getDefaultMaterialProperty (const std::string &name)
 
const GenericMaterialProperty< U, is_ad > & getDefaultMaterialPropertyByName (const std::string &name)
 
void validateDerivativeMaterialPropertyBase (const std::string &base)
 
const MaterialPropertyName derivativePropertyName (const MaterialPropertyName &base, const std::vector< SymbolName > &c) const
 
const MaterialPropertyName derivativePropertyNameFirst (const MaterialPropertyName &base, const SymbolName &c1) const
 
const MaterialPropertyName derivativePropertyNameSecond (const MaterialPropertyName &base, const SymbolName &c1, const SymbolName &c2) const
 
const MaterialPropertyName derivativePropertyNameThird (const MaterialPropertyName &base, const SymbolName &c1, const SymbolName &c2, const SymbolName &c3) const
 
GenericMaterialProperty< U, is_ad > & declarePropertyDerivative (const std::string &base, const std::vector< VariableName > &c)
 
GenericMaterialProperty< U, is_ad > & declarePropertyDerivative (const std::string &base, const std::vector< SymbolName > &c)
 
GenericMaterialProperty< U, is_ad > & declarePropertyDerivative (const std::string &base, const SymbolName &c1, const SymbolName &c2="", const SymbolName &c3="")
 
GenericMaterialProperty< U, is_ad > & declarePropertyDerivative (const std::string &base, const std::vector< VariableName > &c)
 
GenericMaterialProperty< U, is_ad > & declarePropertyDerivative (const std::string &base, const std::vector< SymbolName > &c)
 
GenericMaterialProperty< U, is_ad > & declarePropertyDerivative (const std::string &base, const SymbolName &c1, const SymbolName &c2="", const SymbolName &c3="")
 
const GenericMaterialProperty< U, is_ad > & getMaterialPropertyDerivative (const std::string &base, const std::vector< VariableName > &c)
 
const GenericMaterialProperty< U, is_ad > & getMaterialPropertyDerivative (const std::string &base, const std::vector< SymbolName > &c)
 
const GenericMaterialProperty< U, is_ad > & getMaterialPropertyDerivative (const std::string &base, const SymbolName &c1, const SymbolName &c2="", const SymbolName &c3="")
 
const GenericMaterialProperty< U, is_ad > & getMaterialPropertyDerivative (const std::string &base, const SymbolName &c1, unsigned int v2, unsigned int v3=libMesh::invalid_uint)
 
const GenericMaterialProperty< U, is_ad > & getMaterialPropertyDerivative (const std::string &base, unsigned int v1, unsigned int v2=libMesh::invalid_uint, unsigned int v3=libMesh::invalid_uint)
 
const GenericMaterialProperty< U, is_ad > & getMaterialPropertyDerivative (const std::string &base, const std::vector< VariableName > &c)
 
const GenericMaterialProperty< U, is_ad > & getMaterialPropertyDerivative (const std::string &base, const std::vector< SymbolName > &c)
 
const GenericMaterialProperty< U, is_ad > & getMaterialPropertyDerivative (const std::string &base, const SymbolName &c1, const SymbolName &c2="", const SymbolName &c3="")
 
const GenericMaterialProperty< U, is_ad > & getMaterialPropertyDerivative (const std::string &base, const SymbolName &c1, unsigned int v2, unsigned int v3=libMesh::invalid_uint)
 
const GenericMaterialProperty< U, is_ad > & getMaterialPropertyDerivative (const std::string &base, unsigned int v1, unsigned int v2=libMesh::invalid_uint, unsigned int v3=libMesh::invalid_uint)
 
const GenericMaterialProperty< U, is_ad > & getMaterialPropertyDerivativeByName (const MaterialPropertyName &base, const std::vector< VariableName > &c)
 
const GenericMaterialProperty< U, is_ad > & getMaterialPropertyDerivativeByName (const MaterialPropertyName &base, const std::vector< SymbolName > &c)
 
const GenericMaterialProperty< U, is_ad > & getMaterialPropertyDerivativeByName (const MaterialPropertyName &base, const SymbolName &c1, const SymbolName &c2="", const SymbolName &c3="")
 
const GenericMaterialProperty< U, is_ad > & getMaterialPropertyDerivativeByName (const MaterialPropertyName &base, const std::vector< VariableName > &c)
 
const GenericMaterialProperty< U, is_ad > & getMaterialPropertyDerivativeByName (const MaterialPropertyName &base, const std::vector< SymbolName > &c)
 
const GenericMaterialProperty< U, is_ad > & getMaterialPropertyDerivativeByName (const MaterialPropertyName &base, const SymbolName &c1, const SymbolName &c2="", const SymbolName &c3="")
 
void validateCoupling (const MaterialPropertyName &base, const std::vector< VariableName > &c, bool validate_aux=true)
 
void validateCoupling (const MaterialPropertyName &base, const VariableName &c1="", const VariableName &c2="", const VariableName &c3="")
 
void validateCoupling (const MaterialPropertyName &base, const std::vector< VariableName > &c, bool validate_aux=true)
 
void validateCoupling (const MaterialPropertyName &base, const VariableName &c1="", const VariableName &c2="", const VariableName &c3="")
 
void validateNonlinearCoupling (const MaterialPropertyName &base, const VariableName &c1="", const VariableName &c2="", const VariableName &c3="")
 
void validateNonlinearCoupling (const MaterialPropertyName &base, const VariableName &c1="", const VariableName &c2="", const VariableName &c3="")
 
const MaterialPropertyName propertyName (const MaterialPropertyName &base, const std::vector< SymbolName > &c) const
 
const MaterialPropertyName propertyName (const MaterialPropertyName &base, const std::vector< SymbolName > &c) const
 
const MaterialPropertyName propertyNameFirst (const MaterialPropertyName &base, const SymbolName &c1) const
 
const MaterialPropertyName propertyNameFirst (const MaterialPropertyName &base, const SymbolName &c1) const
 
const MaterialPropertyName propertyNameSecond (const MaterialPropertyName &base, const SymbolName &c1, const SymbolName &c2) const
 
const MaterialPropertyName propertyNameSecond (const MaterialPropertyName &base, const SymbolName &c1, const SymbolName &c2) const
 
const MaterialPropertyName propertyNameThird (const MaterialPropertyName &base, const SymbolName &c1, const SymbolName &c2, const SymbolName &c3) const
 
const MaterialPropertyName propertyNameThird (const MaterialPropertyName &base, const SymbolName &c1, const SymbolName &c2, const SymbolName &c3) const
 

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

Member Typedef Documentation

◆ PFFunctionType

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

Definition at line 29 of file CahnHilliardBase.h.

Constructor & Destructor Documentation

◆ CahnHilliardBase()

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

Definition at line 72 of file CahnHilliardBase.h.

73  : CHBulk<T>(parameters),
74  _nvar(_coupled_moose_vars.size()),
78  _grad_vars(_nvar + 1)
79 {
80  // derivatives w.r.t. and gradients of the kernel variable
82  &this->template getMaterialPropertyDerivative<Real>("f_name", _var.name(), _var.name());
83  _third_derivatives[0] = &this->template getMaterialPropertyDerivative<Real>(
84  "f_name", _var.name(), _var.name(), _var.name());
85  _grad_vars[0] = &(_grad_u);
86 
87  // Iterate over all coupled variables
88  for (unsigned int i = 0; i < _nvar; ++i)
89  {
90  const VariableName iname = _coupled_moose_vars[i]->name();
91  if (iname == _var.name())
92  {
93  if (this->isCoupled("args"))
94  this->paramError(
95  "args", "The kernel variable should not be specified in the coupled `args` parameter.");
96  else
97  this->paramError("coupled_variables",
98  "The kernel variable should not be specified in the coupled "
99  "`coupled_variables` parameter.");
100  }
101  _second_derivatives[i + 1] =
102  &this->template getMaterialPropertyDerivative<Real>("f_name", _var.name(), iname);
103  _third_derivatives[i + 1] = &this->template getMaterialPropertyDerivative<Real>(
104  "f_name", _var.name(), _var.name(), iname);
105 
106  _third_cross_derivatives[i].resize(_nvar);
107  for (unsigned int j = 0; j < _nvar; ++j)
108  {
109  VariableName jname = _coupled_moose_vars[j]->name();
111  &this->template getMaterialPropertyDerivative<Real>("f_name", _var.name(), iname, jname);
112  }
113 
114  _grad_vars[i + 1] = &_subproblem.getStandardVariable(_tid, iname).gradSln();
115  }
116 }
This is the Cahn-Hilliard equation base class that implements the bulk or local energy term of the eq...
Definition: CHBulk.h:25
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
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")

Member Function Documentation

◆ computeGradDFDCons()

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

Implements CHBulk< T >.

Definition at line 133 of file CahnHilliardBase.h.

134 {
135  RealGradient res = 0.0;
136 
137  switch (type)
138  {
139  case CHBulk<T>::Residual:
140  for (unsigned int i = 0; i <= _nvar; ++i)
141  res += (*_grad_vars[i])[_qp] * (*_second_derivatives[i])[_qp];
142  return res;
143 
144  case CHBulk<T>::Jacobian:
145  res = _grad_phi[_j][_qp] * (*_second_derivatives[0])[_qp];
146  for (unsigned int i = 0; i <= _nvar; ++i)
147  res += _phi[_j][_qp] * (*_grad_vars[i])[_qp] * (*_third_derivatives[i])[_qp];
148  return res;
149  }
150 
151  mooseError("Internal error");
152 }
void mooseError(Args &&... args)
This is the Cahn-Hilliard equation base class that implements the bulk or local energy term of the eq...
Definition: CHBulk.h:25
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 156 of file CahnHilliardBase.h.

157 {
158  // get the coupled variable jvar is referring to
159  const unsigned int cvar = this->mapJvarToCvar(jvar);
160 
161  RealGradient J = _grad_u[_qp] * _phi[_j][_qp] * (*_third_derivatives[cvar + 1])[_qp] +
162  _grad_phi[_j][_qp] * (*_second_derivatives[cvar + 1])[_qp];
163 
164  for (unsigned int i = 0; i < _nvar; ++i)
165  J += _phi[_j][_qp] * (*_grad_vars[i + 1])[_qp] * (*_third_cross_derivatives[i][cvar])[_qp];
166 
167  return CHBulk<T>::computeQpOffDiagJacobian(jvar) + _M[_qp] * _grad_test[_i][_qp] * J;
168 }
const MaterialProperty< T > & _M
Mobility.
Definition: CHBulk.h:47
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 120 of file CahnHilliardBase.h.

121 {
127  this->template validateCoupling<Real>("f_name", _var.name());
128  this->template validateDerivativeMaterialPropertyBase<Real>("f_name");
129 }

◆ 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:47
const MaterialProperty< T > & _dMdc
Mobility derivative w.r.t. concentration.
Definition: CHBulk.h:50

◆ 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:47

◆ validParams()

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

Definition at line 58 of file CahnHilliardBase.h.

Referenced by CahnHilliard::validParams(), and CahnHilliardAniso::validParams().

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

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 53 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 50 of file CHBulk.h.

◆ _grad_vars

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

Definition at line 53 of file CahnHilliardBase.h.

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

◆ _M

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

Mobility.

Definition at line 47 of file CHBulk.h.

◆ _nvar

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

Definition at line 49 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 50 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 52 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 51 of file CahnHilliardBase.h.

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


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