www.mooseframework.org
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 Member Functions

 KKSMultiPhaseConcentration (const InputParameters &parameters)
 

Protected Member Functions

virtual Real computeQpResidual ()
 
virtual Real computeQpJacobian ()
 
virtual Real computeQpOffDiagJacobian (unsigned int jvar)
 

Private Attributes

const unsigned int _num_j
 
std::vector< const VariableValue * > _cjs
 
std::vector< unsigned int > _cjs_var
 
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...
 
std::vector< unsigned int > _eta_vars
 
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 32 of file KKSMultiPhaseConcentration.h.

Constructor & Destructor Documentation

KKSMultiPhaseConcentration::KKSMultiPhaseConcentration ( const InputParameters &  parameters)

Definition at line 28 of file KKSMultiPhaseConcentration.C.

29  : DerivativeMaterialInterface<Kernel>(parameters),
30  _num_j(coupledComponents("cj")),
31  _cjs(_num_j),
33  _k(-1),
34  _c(coupledValue("c")),
35  _c_var(coupled("c")),
36  _hj_names(getParam<std::vector<MaterialPropertyName>>("hj_names")),
37  _prop_hj(_hj_names.size()),
38  _eta_names(coupledComponents("etas")),
39  _eta_vars(coupledComponents("etas")),
41 {
42  // Check to make sure the the number of hj's is the same as the number of cj's
43  if (_num_j != _hj_names.size())
44  mooseError("Need to pass in as many hj_names as cjs in KKSMultiPhaseConcentration", name());
45  // Check to make sure the the number of etas is the same as the number of cj's
46  if (_num_j != _eta_names.size())
47  mooseError("Need to pass in as many etas as cjs in KKSMultiPhaseConcentration", name());
48 
49  if (_num_j == 0)
50  mooseError("Need to supply at least 1 phase concentration cj in KKSMultiPhaseConcentration",
51  name());
52 
53  // get order parameter names and variable indices
54  for (unsigned int i = 0; i < _num_j; ++i)
55  {
56  _eta_names[i] = getVar("etas", i)->name();
57  _eta_vars[i] = coupled("etas", i);
58  }
59 
60  // Load concentration variables into the arrays
61  for (unsigned int m = 0; m < _num_j; ++m)
62  {
63  _cjs[m] = &coupledValue("cj", m);
64  _cjs_var[m] = coupled("cj", m);
65  _prop_hj[m] = &getMaterialPropertyByName<Real>(_hj_names[m]);
66  _prop_dhjdetai[m].resize(_num_j);
67  // Set _k to the position of the nonlinear variable in the list of cj's
68  if (coupled("cj", m) == _var.number())
69  _k = m;
70 
71  // Get derivatives of switching functions wrt order parameters
72  for (unsigned int n = 0; n < _num_j; ++n)
73  _prop_dhjdetai[m][n] = &getMaterialPropertyDerivative<Real>(_hj_names[m], _eta_names[n]);
74  }
75 
76  // Check to make sure the nonlinear variable is set to one of the cj's
77  if (_k < 0)
78  mooseError("Need to set nonlinear variable to one of the cj's in KKSMultiPhaseConcentration",
79  name());
80 }
std::vector< unsigned int > _cjs_var
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
std::vector< const VariableValue * > _cjs
std::vector< std::vector< const MaterialProperty< Real > * > > _prop_dhjdetai
Derivative of the switching function .
std::vector< unsigned int > _eta_vars

Member Function Documentation

Real KKSMultiPhaseConcentration::computeQpJacobian ( )
protectedvirtual

Definition at line 94 of file KKSMultiPhaseConcentration.C.

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

Definition at line 100 of file KKSMultiPhaseConcentration.C.

101 {
102  if (jvar == _c_var)
103  return -_test[_i][_qp] * _phi[_j][_qp];
104 
105  for (unsigned int m = 0; m < _num_j; ++m)
106  if (jvar == _cjs_var[m])
107  return _test[_i][_qp] * (*_prop_hj[m])[_qp] * _phi[_j][_qp];
108 
109  for (unsigned int m = 0; m < _num_j; ++m)
110  if (jvar == _eta_vars[m])
111  {
112  Real sum = 0.0;
113 
114  for (unsigned int n = 0; n < _num_j; ++n)
115  sum += (*_prop_dhjdetai[n][m])[_qp] * (*_cjs[n])[_qp];
116 
117  return _test[_i][_qp] * sum * _phi[_j][_qp];
118  }
119 
120  return 0.0;
121 }
std::vector< unsigned int > _cjs_var
std::vector< const MaterialProperty< Real > * > _prop_hj
std::vector< const VariableValue * > _cjs
std::vector< std::vector< const MaterialProperty< Real > * > > _prop_dhjdetai
Derivative of the switching function .
std::vector< unsigned int > _eta_vars
Real KKSMultiPhaseConcentration::computeQpResidual ( )
protectedvirtual

Definition at line 83 of file KKSMultiPhaseConcentration.C.

84 {
85  // R = sum_i (h_i * c_i) - c
86  Real sum_ch = 0.0;
87  for (unsigned int m = 0; m < _num_j; ++m)
88  sum_ch += (*_cjs[m])[_qp] * (*_prop_hj[m])[_qp];
89 
90  return _test[_i][_qp] * (sum_ch - _c[_qp]);
91 }
std::vector< const MaterialProperty< Real > * > _prop_hj
std::vector< const VariableValue * > _cjs

Member Data Documentation

const VariableValue& KKSMultiPhaseConcentration::_c
private

Definition at line 49 of file KKSMultiPhaseConcentration.h.

Referenced by computeQpResidual().

unsigned int KKSMultiPhaseConcentration::_c_var
private

Definition at line 50 of file KKSMultiPhaseConcentration.h.

Referenced by computeQpOffDiagJacobian().

std::vector<const VariableValue *> KKSMultiPhaseConcentration::_cjs
private
std::vector<unsigned int> KKSMultiPhaseConcentration::_cjs_var
private
std::vector<VariableName> KKSMultiPhaseConcentration::_eta_names
private

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

Definition at line 57 of file KKSMultiPhaseConcentration.h.

Referenced by KKSMultiPhaseConcentration().

std::vector<unsigned int> KKSMultiPhaseConcentration::_eta_vars
private
std::vector<MaterialPropertyName> KKSMultiPhaseConcentration::_hj_names
private

Switching functions for each phase \( h_j \).

Definition at line 53 of file KKSMultiPhaseConcentration.h.

Referenced by KKSMultiPhaseConcentration().

int KKSMultiPhaseConcentration::_k
private

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

Definition at line 47 of file KKSMultiPhaseConcentration.h.

Referenced by computeQpJacobian(), and KKSMultiPhaseConcentration().

const unsigned int KKSMultiPhaseConcentration::_num_j
private
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 61 of file KKSMultiPhaseConcentration.h.

Referenced by computeQpOffDiagJacobian(), and KKSMultiPhaseConcentration().

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

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