www.mooseframework.org
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes | List of all members
KKSMultiPhaseConcentration Class Reference

Enforce sum of phase concentrations to be the real concentration. More...

#include <KKSMultiPhaseConcentration.h>

Inheritance diagram for KKSMultiPhaseConcentration:
[legend]

Public Types

typedef DerivativeMaterialPropertyNameInterface::SymbolName SymbolName
 

Public Member Functions

 KKSMultiPhaseConcentration (const InputParameters &parameters)
 
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 Member Functions

virtual Real precomputeQpResidual ()
 
virtual Real precomputeQpJacobian ()
 
virtual Real computeQpOffDiagJacobian (unsigned int jvar)
 

Private Attributes

const unsigned int _num_j
 
const std::vector< const VariableValue * > _cj
 
const JvarMap & _cj_map
 
int _k
 Position of the nonlinear variable in the list of cj's. More...
 
const VariableValue_c
 
unsigned int _c_var
 
std::vector< MaterialPropertyName > _hj_names
 Switching functions for each phase \( h_j \). More...
 
std::vector< const MaterialProperty< Real > * > _prop_hj
 
std::vector< VariableName > _eta_names
 Order parameters for each phase \( \eta_j \). More...
 
const JvarMap & _eta_map
 
std::vector< std::vector< const MaterialProperty< Real > * > > _prop_dhjdetai
 Derivative of the switching function \( \frac d{d\eta} h(\eta) \). More...
 

Detailed Description

Enforce sum of phase concentrations to be the real concentration.

\( c = h_1(\eta_1,\eta_2,\eta_3,...) c_1 + h_2(\eta_1,\eta_2,\eta_3,...) c_2 + h_3(\eta_1,\eta_2,\eta_3,..) c_3 + ... \)

The non-linear variable for this Kernel is one of the concentrations \( c_i \), while \( c_j \neq c_i \) and \( c \) are supplied as coupled variables. The other phase concentrations are set as non-linear variables using multiple KKSPhaseChemicalPotential kernels.

See also
KKSPhaseChemicalPotential

Definition at line 31 of file KKSMultiPhaseConcentration.h.

Constructor & Destructor Documentation

◆ KKSMultiPhaseConcentration()

KKSMultiPhaseConcentration::KKSMultiPhaseConcentration ( const InputParameters parameters)

Definition at line 32 of file KKSMultiPhaseConcentration.C.

34  _num_j(coupledComponents("cj")),
35  _cj(coupledValues("cj")),
36  _cj_map(getParameterJvarMap("cj")),
37  _k(-1),
38  _c(coupledValue("c")),
39  _c_var(coupled("c")),
40  _hj_names(getParam<std::vector<MaterialPropertyName>>("hj_names")),
41  _prop_hj(_hj_names.size()),
42  _eta_names(coupledComponents("etas")),
43  _eta_map(getParameterJvarMap("etas")),
45 {
46  // Check to make sure the the number of hj's is the same as the number of cj's
47  if (_num_j != _hj_names.size())
48  paramError("hj_names", "Need to pass in as many hj_names as cjs");
49  // Check to make sure the the number of etas is the same as the number of cj's
50  if (_num_j != _eta_names.size())
51  paramError("etas", "Need to pass in as many etas as cjs");
52 
53  if (_num_j == 0)
54  mooseError("Need to supply at least 1 phase concentration cj in KKSMultiPhaseConcentration",
55  name());
56 
57  // get order parameter names and variable indices
58  for (unsigned int i = 0; i < _num_j; ++i)
59  _eta_names[i] = coupledName("etas", i);
60 
61  // Load concentration variables into the arrays
62  for (unsigned int m = 0; m < _num_j; ++m)
63  {
64  _prop_hj[m] = &getMaterialPropertyByName<Real>(_hj_names[m]);
65  _prop_dhjdetai[m].resize(_num_j);
66  // Set _k to the position of the nonlinear variable in the list of cj's
67  if (coupled("cj", m) == _var.number())
68  _k = m;
69 
70  // Get derivatives of switching functions wrt order parameters
71  for (unsigned int n = 0; n < _num_j; ++n)
72  _prop_dhjdetai[m][n] = &getMaterialPropertyDerivative<Real>(_hj_names[m], _eta_names[n]);
73  }
74 
75  // Check to make sure the nonlinear variable is set to one of the cj's
76  if (_k < 0)
77  mooseError("Need to set nonlinear variable to one of the cj's in KKSMultiPhaseConcentration",
78  name());
79 }
void mooseError(Args &&... args)
int _k
Position of the nonlinear variable in the list of cj&#39;s.
std::vector< VariableName > _eta_names
Order parameters for each phase .
std::vector< MaterialPropertyName > _hj_names
Switching functions for each phase .
std::vector< const MaterialProperty< Real > * > _prop_hj
const std::string name
Definition: Setup.h:20
std::vector< std::vector< const MaterialProperty< Real > * > > _prop_dhjdetai
Derivative of the switching function .
const std::vector< const VariableValue * > _cj

Member Function Documentation

◆ computeQpOffDiagJacobian()

Real KKSMultiPhaseConcentration::computeQpOffDiagJacobian ( unsigned int  jvar)
protectedvirtual

Definition at line 99 of file KKSMultiPhaseConcentration.C.

100 {
101  if (jvar == _c_var)
102  return -_test[_i][_qp] * _phi[_j][_qp];
103 
104  auto cjvar = mapJvarToCvar(jvar, _cj_map);
105  if (cjvar >= 0)
106  return _test[_i][_qp] * (*_prop_hj[cjvar])[_qp] * _phi[_j][_qp];
107 
108  auto etavar = mapJvarToCvar(jvar, _eta_map);
109  if (etavar >= 0)
110  {
111  Real sum = 0.0;
112 
113  for (unsigned int n = 0; n < _num_j; ++n)
114  sum += (*_prop_dhjdetai[n][etavar])[_qp] * (*_cj[n])[_qp];
115 
116  return _test[_i][_qp] * sum * _phi[_j][_qp];
117  }
118 
119  return 0.0;
120 }
std::vector< const MaterialProperty< Real > * > _prop_hj
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::vector< std::vector< const MaterialProperty< Real > * > > _prop_dhjdetai
Derivative of the switching function .
const std::vector< const VariableValue * > _cj

◆ precomputeQpJacobian()

Real KKSMultiPhaseConcentration::precomputeQpJacobian ( )
protectedvirtual

Definition at line 93 of file KKSMultiPhaseConcentration.C.

94 {
95  return (*_prop_hj[_k])[_qp] * _phi[_j][_qp];
96 }
int _k
Position of the nonlinear variable in the list of cj&#39;s.
std::vector< const MaterialProperty< Real > * > _prop_hj

◆ precomputeQpResidual()

Real KKSMultiPhaseConcentration::precomputeQpResidual ( )
protectedvirtual

Definition at line 82 of file KKSMultiPhaseConcentration.C.

83 {
84  // R = sum_i (h_i * c_i) - c
85  Real sum_ch = 0.0;
86  for (unsigned int m = 0; m < _num_j; ++m)
87  sum_ch += (*_cj[m])[_qp] * (*_prop_hj[m])[_qp];
88 
89  return sum_ch - _c[_qp];
90 }
std::vector< const MaterialProperty< Real > * > _prop_hj
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const std::vector< const VariableValue * > _cj

◆ validParams()

InputParameters KKSMultiPhaseConcentration::validParams ( )
static

Definition at line 15 of file KKSMultiPhaseConcentration.C.

16 {
18  params.addClassDescription(
19  "KKS multi-phase model kernel to enforce $c = h_1c_1 + h_2c_2 + h_3c_3 + \\dots$"
20  ". The non-linear variable of this kernel is $c_n$, the final phase "
21  "concentration in the list.");
22  params.addRequiredCoupledVar(
23  "cj", "Array of phase concentrations cj. Place in same order as hj_names!");
24  params.addRequiredCoupledVar("c", "Physical concentration");
25  params.addCoupledVar("etas", "Order parameters for all phases");
26  params.addRequiredParam<std::vector<MaterialPropertyName>>(
27  "hj_names", "Switching Function Materials that provide $h(\\eta_1, \\eta_2,\\dots)$");
28  return params;
29 }
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()

Member Data Documentation

◆ _c

const VariableValue& KKSMultiPhaseConcentration::_c
private

Definition at line 52 of file KKSMultiPhaseConcentration.h.

Referenced by precomputeQpResidual().

◆ _c_var

unsigned int KKSMultiPhaseConcentration::_c_var
private

Definition at line 53 of file KKSMultiPhaseConcentration.h.

Referenced by computeQpOffDiagJacobian().

◆ _cj

const std::vector<const VariableValue *> KKSMultiPhaseConcentration::_cj
private

Definition at line 46 of file KKSMultiPhaseConcentration.h.

Referenced by computeQpOffDiagJacobian(), and precomputeQpResidual().

◆ _cj_map

const JvarMap& KKSMultiPhaseConcentration::_cj_map
private

Definition at line 47 of file KKSMultiPhaseConcentration.h.

Referenced by computeQpOffDiagJacobian().

◆ _eta_map

const JvarMap& KKSMultiPhaseConcentration::_eta_map
private

Definition at line 61 of file KKSMultiPhaseConcentration.h.

Referenced by computeQpOffDiagJacobian().

◆ _eta_names

std::vector<VariableName> KKSMultiPhaseConcentration::_eta_names
private

Order parameters for each phase \( \eta_j \).

Definition at line 60 of file KKSMultiPhaseConcentration.h.

Referenced by KKSMultiPhaseConcentration().

◆ _hj_names

std::vector<MaterialPropertyName> KKSMultiPhaseConcentration::_hj_names
private

Switching functions for each phase \( h_j \).

Definition at line 56 of file KKSMultiPhaseConcentration.h.

Referenced by KKSMultiPhaseConcentration().

◆ _k

int KKSMultiPhaseConcentration::_k
private

Position of the nonlinear variable in the list of cj's.

Definition at line 50 of file KKSMultiPhaseConcentration.h.

Referenced by KKSMultiPhaseConcentration(), and precomputeQpJacobian().

◆ _num_j

const unsigned int KKSMultiPhaseConcentration::_num_j
private

◆ _prop_dhjdetai

std::vector<std::vector<const MaterialProperty<Real> *> > KKSMultiPhaseConcentration::_prop_dhjdetai
private

Derivative of the switching function \( \frac d{d\eta} h(\eta) \).

Definition at line 64 of file KKSMultiPhaseConcentration.h.

Referenced by computeQpOffDiagJacobian(), and KKSMultiPhaseConcentration().

◆ _prop_hj

std::vector<const MaterialProperty<Real> *> KKSMultiPhaseConcentration::_prop_hj
private

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