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
KKSCHBulk Class Referenceabstract

CHBulk child class that takes all the necessary data from a KKSBaseMaterial. More...

#include <KKSCHBulk.h>

Inheritance diagram for KKSCHBulk:
[legend]

Public Types

typedef DerivativeMaterialPropertyNameInterface::SymbolName SymbolName
 

Public Member Functions

 KKSCHBulk (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

enum  PFFunctionType
 

Protected Member Functions

virtual RealGradient computeGradDFDCons (PFFunctionType type)
 Note that per product and chain rules: \( \frac{d}{du_j}\left(F(u)\nabla u\right) = \nabla u \frac {dF(u)}{du}\frac{du}{du_j} + F(u)\frac{d\nabla u}{du_j} \) which is: \( \nabla u \frac {dF(u)}{du} \phi_j + F(u) \nabla \phi_j \). More...
 
virtual Real computeQpOffDiagJacobian (unsigned int jvar)
 
virtual RealGradient precomputeQpResidual ()
 
virtual RealGradient precomputeQpJacobian ()
 
virtual RealGradient computeGradDFDCons (PFFunctionType type)=0
 

Protected Attributes

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

Private Attributes

std::vector< const MaterialProperty< Real > * > _second_derivatives
 Derivatives of \( dFa/dca \) with respect to all coupled variables. More...
 
std::vector< std::vector< const MaterialProperty< Real > * > > _third_derivatives
 Second derivatives of dFa/dca with respect to all coupled variables. More...
 
std::vector< const MaterialProperty< Real > * > _third_derivatives_ca
 Derivatives of \( d^2Fa/dca^2 \) with respect to all coupled variables. More...
 
std::vector< const VariableGradient * > _grad_args
 Gradients for all coupled variables. More...
 
const MaterialProperty< Real > & _prop_h
 h(eta) material property More...
 
const MaterialProperty< Real > & _second_derivative_Fa
 Second derivative \( d^2Fa/dca^2 \). More...
 
const MaterialProperty< Real > & _second_derivative_Fb
 Second derivative \( d^2Fb/dcb^2 \). More...
 
unsigned int _ca_var
 
const VariableName _ca_name
 
unsigned int _cb_var
 
const VariableName _cb_name
 

Detailed Description

CHBulk child class that takes all the necessary data from a KKSBaseMaterial.

We calculate \( \nabla\frac{\partial F_a}{\partial c_a} \). This takes advantage of the KKS identity

\( dF/dc = dF_a/dc_a (= dF_b/dc_b) \)

The non-linear variable for this Kernel is the concentration 'c'. The user picks one phase free energy \( F_a \) (f_base) and its corresponding phase concentration \( c_a \)

Definition at line 28 of file KKSCHBulk.h.

Member Enumeration Documentation

◆ PFFunctionType

enum CHBulk::PFFunctionType
protectedinherited

Definition at line 38 of file CHBulk.h.

39  {
40  Jacobian,
41  Residual
42  };

Constructor & Destructor Documentation

◆ KKSCHBulk()

KKSCHBulk::KKSCHBulk ( const InputParameters parameters)

Definition at line 39 of file KKSCHBulk.C.

40  : CHBulk<Real>(parameters),
41  _ca_var(coupled("ca")),
42  _ca_name(coupledName("ca", 0)),
43  _cb_var(coupled("cb")),
44  _cb_name(coupledName("cb", 0)),
45  _prop_h(getMaterialProperty<Real>("h_name")),
46  _second_derivative_Fa(getMaterialPropertyDerivative<Real>("fa_name", _ca_name, _ca_name)),
47  _second_derivative_Fb(getMaterialPropertyDerivative<Real>("fb_name", _cb_name, _cb_name))
48 {
49  // reserve space for derivatives
50  _second_derivatives.resize(_n_args);
51  _third_derivatives.resize(_n_args);
52  _third_derivatives_ca.resize(_n_args);
53  _grad_args.resize(_n_args);
54 
55  // Iterate over all coupled variables
56  for (unsigned int i = 0; i < _n_args; ++i)
57  {
58 
59  // get the second derivative material property (TODO:warn)
60  _second_derivatives[i] = &getMaterialPropertyDerivative<Real>("fa_name", _ca_name, i);
61 
62  // get the third derivative material properties
63  _third_derivatives[i].resize(_n_args);
64  for (unsigned int j = 0; j < _n_args; ++j)
65  _third_derivatives[i][j] = &getMaterialPropertyDerivative<Real>("fa_name", _ca_name, i, j);
66 
67  MooseVariable * cvar = _coupled_standard_moose_vars[i];
68 
69  // third derivative for the on-diagonal jacobian
71  &getMaterialPropertyDerivative<Real>("fa_name", _ca_name, _ca_name, cvar->name());
72 
73  // get the gradient
74  _grad_args[i] = &(cvar->gradSln());
75  }
76 }
std::vector< const MaterialProperty< Real > * > _third_derivatives_ca
Derivatives of with respect to all coupled variables.
Definition: KKSCHBulk.h:55
std::vector< const MaterialProperty< Real > * > _second_derivatives
Derivatives of with respect to all coupled variables.
Definition: KKSCHBulk.h:49
const VariableName _ca_name
Definition: KKSCHBulk.h:43
unsigned int _ca_var
Definition: KKSCHBulk.h:42
const FieldVariableGradient & gradSln() const override
const MaterialProperty< Real > & _prop_h
h(eta) material property
Definition: KKSCHBulk.h:61
const MaterialProperty< Real > & _second_derivative_Fa
Second derivative .
Definition: KKSCHBulk.h:64
const std::string & name() const override
unsigned int _cb_var
Definition: KKSCHBulk.h:44
std::vector< const VariableGradient * > _grad_args
Gradients for all coupled variables.
Definition: KKSCHBulk.h:58
const MaterialProperty< Real > & _second_derivative_Fb
Second derivative .
Definition: KKSCHBulk.h:67
const VariableName _cb_name
Definition: KKSCHBulk.h:45
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
std::vector< std::vector< const MaterialProperty< Real > * > > _third_derivatives
Second derivatives of dFa/dca with respect to all coupled variables.
Definition: KKSCHBulk.h:52

Member Function Documentation

◆ computeGradDFDCons() [1/2]

RealGradient KKSCHBulk::computeGradDFDCons ( PFFunctionType  type)
protectedvirtual

Note that per product and chain rules: \( \frac{d}{du_j}\left(F(u)\nabla u\right) = \nabla u \frac {dF(u)}{du}\frac{du}{du_j} + F(u)\frac{d\nabla u}{du_j} \) which is: \( \nabla u \frac {dF(u)}{du} \phi_j + F(u) \nabla \phi_j \).

Definition at line 86 of file KKSCHBulk.C.

87 {
88  RealGradient res = 0.0;
89 
90  switch (type)
91  {
92  case Residual:
93  for (unsigned int i = 0; i < _n_args; ++i)
94  res += (*_second_derivatives[i])[_qp] * (*_grad_args[i])[_qp];
95 
96  return res;
97 
98  case Jacobian:
99  // the nonlinear variable is c, but the free energy only contains the
100  // phase concentrations. Equation (23) in the KKS paper gives the chain-
101  // rule derivative dca/dc
102  /* Real dcadc = _second_derivative_Fb[_qp]
103  / ( (1.0 - _prop_h[_qp]) * _second_derivative_Fb[_qp]
104  + _prop_h[_qp] * _second_derivative_Fa[_qp]); */
105  // The (1-h)*X_b, h*X_a pairing is opposite to what the KKSPhaseConcentration kernel does!
106 
107  res = _second_derivative_Fa[_qp] * _grad_phi[_j][_qp];
108 
109  for (unsigned int i = 0; i < _n_args; ++i)
110  res += (*_third_derivatives_ca[i])[_qp] * (*_grad_args[i])[_qp] * _phi[_j][_qp];
111 
112  // convergence improves if we return 0.0 here
113  return 0.0; // res * dcadc;
114  }
115 
116  mooseError("Invalid type passed in");
117 }
std::vector< const MaterialProperty< Real > * > _third_derivatives_ca
Derivatives of with respect to all coupled variables.
Definition: KKSCHBulk.h:55
std::vector< const MaterialProperty< Real > * > _second_derivatives
Derivatives of with respect to all coupled variables.
Definition: KKSCHBulk.h:49
void mooseError(Args &&... args)
const MaterialProperty< Real > & _second_derivative_Fa
Second derivative .
Definition: KKSCHBulk.h:64
std::vector< const VariableGradient * > _grad_args
Gradients for all coupled variables.
Definition: KKSCHBulk.h:58

◆ computeGradDFDCons() [2/2]

virtual RealGradient CHBulk< Real >::computeGradDFDCons ( PFFunctionType  type)
protectedpure virtualinherited

Implemented in CahnHilliardBase< Real >.

◆ computeQpOffDiagJacobian()

Real KKSCHBulk::computeQpOffDiagJacobian ( unsigned int  jvar)
protectedvirtual

Reimplemented from CHBulk< Real >.

Definition at line 120 of file KKSCHBulk.C.

121 {
122  // get the coupled variable jvar is referring to
123  const unsigned int cvar = mapJvarToCvar(jvar);
124 
125  RealGradient res = (*_second_derivatives[cvar])[_qp] * _grad_phi[_j][_qp];
126 
127  for (unsigned int i = 0; i < _n_args; ++i)
128  res += (*_third_derivatives[i][cvar])[_qp] * (*_grad_args[i])[_qp] * _phi[_j][_qp];
129 
130  // keeping this term seems to improve the solution.
131  return res * _grad_test[_i][_qp];
132 }
std::vector< const MaterialProperty< Real > * > _second_derivatives
Derivatives of with respect to all coupled variables.
Definition: KKSCHBulk.h:49
std::vector< const VariableGradient * > _grad_args
Gradients for all coupled variables.
Definition: KKSCHBulk.h:58
std::vector< std::vector< const MaterialProperty< Real > * > > _third_derivatives
Second derivatives of dFa/dca with respect to all coupled variables.
Definition: KKSCHBulk.h:52

◆ initialSetup()

void CHBulk< Real >::initialSetup ( )
virtualinherited

Reimplemented in CahnHilliardBase< Real >.

Definition at line 87 of file CHBulk.h.

88 {
89  validateNonlinearCoupling<Real>("mob_name");
90 }

◆ precomputeQpJacobian()

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

◆ precomputeQpResidual()

RealGradient CHBulk< Real >::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< Real > & _M
Mobility.
Definition: CHBulk.h:47

◆ validParams()

InputParameters KKSCHBulk::validParams ( )
static

Definition at line 15 of file KKSCHBulk.C.

16 {
18  params.addClassDescription("KKS model kernel for the Bulk Cahn-Hilliard term. This operates on "
19  "the concentration 'c' as the non-linear variable");
20  params.addRequiredParam<MaterialPropertyName>("fa_name",
21  "Base name of the free energy function "
22  "F (f_name in the corresponding "
23  "derivative function material)");
24  params.addRequiredParam<MaterialPropertyName>("fb_name",
25  "Base name of the free energy function "
26  "F (f_name in the corresponding "
27  "derivative function material)");
28  params.addRequiredCoupledVar(
29  "ca", "phase concentration corresponding to the non-linear variable of this kernel");
30  params.addRequiredCoupledVar(
31  "cb", "phase concentration corresponding to the non-linear variable of this kernel");
32  params.addCoupledVar("args_a", "Vector of additional arguments to Fa");
33  params.addParam<MaterialPropertyName>(
34  "h_name", "h", "Base name for the switching function h(eta)"); // TODO: everywhere else this
35  // is called just "h"
36  return params;
37 }
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addCoupledVar(const std::string &name, const std::string &doc_string)
void addRequiredCoupledVar(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

◆ _ca_name

const VariableName KKSCHBulk::_ca_name
private

Definition at line 43 of file KKSCHBulk.h.

Referenced by KKSCHBulk().

◆ _ca_var

unsigned int KKSCHBulk::_ca_var
private

Phase concnetration variables

Definition at line 42 of file KKSCHBulk.h.

◆ _cb_name

const VariableName KKSCHBulk::_cb_name
private

Definition at line 45 of file KKSCHBulk.h.

◆ _cb_var

unsigned int KKSCHBulk::_cb_var
private

Definition at line 44 of file KKSCHBulk.h.

◆ _dMdarg

std::vector<const MaterialProperty<Real > *> CHBulk< Real >::_dMdarg
protectedinherited

Mobility derivative w.r.t coupled variables.

Definition at line 53 of file CHBulk.h.

◆ _dMdc

const MaterialProperty<Real >& CHBulk< Real >::_dMdc
protectedinherited

Mobility derivative w.r.t. concentration.

Definition at line 50 of file CHBulk.h.

◆ _grad_args

std::vector<const VariableGradient *> KKSCHBulk::_grad_args
private

Gradients for all coupled variables.

Definition at line 58 of file KKSCHBulk.h.

Referenced by computeGradDFDCons(), computeQpOffDiagJacobian(), and KKSCHBulk().

◆ _M

const MaterialProperty<Real >& CHBulk< Real >::_M
protectedinherited

Mobility.

Definition at line 47 of file CHBulk.h.

◆ _prop_h

const MaterialProperty<Real>& KKSCHBulk::_prop_h
private

h(eta) material property

Definition at line 61 of file KKSCHBulk.h.

◆ _second_derivative_Fa

const MaterialProperty<Real>& KKSCHBulk::_second_derivative_Fa
private

Second derivative \( d^2Fa/dca^2 \).

Definition at line 64 of file KKSCHBulk.h.

Referenced by computeGradDFDCons().

◆ _second_derivative_Fb

const MaterialProperty<Real>& KKSCHBulk::_second_derivative_Fb
private

Second derivative \( d^2Fb/dcb^2 \).

Definition at line 67 of file KKSCHBulk.h.

◆ _second_derivatives

std::vector<const MaterialProperty<Real> *> KKSCHBulk::_second_derivatives
private

Derivatives of \( dFa/dca \) with respect to all coupled variables.

Definition at line 49 of file KKSCHBulk.h.

Referenced by computeGradDFDCons(), computeQpOffDiagJacobian(), and KKSCHBulk().

◆ _third_derivatives

std::vector<std::vector<const MaterialProperty<Real> *> > KKSCHBulk::_third_derivatives
private

Second derivatives of dFa/dca with respect to all coupled variables.

Definition at line 52 of file KKSCHBulk.h.

Referenced by computeQpOffDiagJacobian(), and KKSCHBulk().

◆ _third_derivatives_ca

std::vector<const MaterialProperty<Real> *> KKSCHBulk::_third_derivatives_ca
private

Derivatives of \( d^2Fa/dca^2 \) with respect to all coupled variables.

Definition at line 55 of file KKSCHBulk.h.

Referenced by computeGradDFDCons(), and KKSCHBulk().


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