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.

KKSPhaseChemicalPotential

Definition at line 35 of file KKSMultiPhaseConcentration.h.

## ◆ KKSMultiPhaseConcentration()

 KKSMultiPhaseConcentration::KKSMultiPhaseConcentration ( const InputParameters & parameters )

Definition at line 33 of file KKSMultiPhaseConcentration.C.

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

## ◆ computeQpJacobian()

 Real KKSMultiPhaseConcentration::computeQpJacobian ( )
protectedvirtual

Definition at line 99 of file KKSMultiPhaseConcentration.C.

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

## ◆ computeQpOffDiagJacobian()

 Real KKSMultiPhaseConcentration::computeQpOffDiagJacobian ( unsigned int jvar )
protectedvirtual

Definition at line 105 of file KKSMultiPhaseConcentration.C.

106 {
107  if (jvar == _c_var)
108  return -_test[_i][_qp] * _phi[_j][_qp];
109
110  for (unsigned int m = 0; m < _num_j; ++m)
111  if (jvar == _cjs_var[m])
112  return _test[_i][_qp] * (*_prop_hj[m])[_qp] * _phi[_j][_qp];
113
114  for (unsigned int m = 0; m < _num_j; ++m)
115  if (jvar == _eta_vars[m])
116  {
117  Real sum = 0.0;
118
119  for (unsigned int n = 0; n < _num_j; ++n)
120  sum += (*_prop_dhjdetai[n][m])[_qp] * (*_cjs[n])[_qp];
121
122  return _test[_i][_qp] * sum * _phi[_j][_qp];
123  }
124
125  return 0.0;
126 }
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

## ◆ computeQpResidual()

 Real KKSMultiPhaseConcentration::computeQpResidual ( )
protectedvirtual

Definition at line 88 of file KKSMultiPhaseConcentration.C.

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

## ◆ _c

 const VariableValue& KKSMultiPhaseConcentration::_c
private

Definition at line 52 of file KKSMultiPhaseConcentration.h.

Referenced by computeQpResidual().

## ◆ _c_var

 unsigned int KKSMultiPhaseConcentration::_c_var
private

Definition at line 53 of file KKSMultiPhaseConcentration.h.

Referenced by computeQpOffDiagJacobian().

## ◆ _cjs

 std::vector KKSMultiPhaseConcentration::_cjs
private

## ◆ _cjs_var

 std::vector KKSMultiPhaseConcentration::_cjs_var
private

## ◆ _eta_names

 std::vector KKSMultiPhaseConcentration::_eta_names
private

Order parameters for each phase $$\eta_j$$.

Definition at line 60 of file KKSMultiPhaseConcentration.h.

Referenced by KKSMultiPhaseConcentration().

## ◆ _eta_vars

 std::vector KKSMultiPhaseConcentration::_eta_vars
private

## ◆ _hj_names

 std::vector 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 computeQpJacobian(), and KKSMultiPhaseConcentration().

## ◆ _num_j

 const unsigned int KKSMultiPhaseConcentration::_num_j
private

## ◆ _prop_dhjdetai

 std::vector *> > 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 *> KKSMultiPhaseConcentration::_prop_hj
private

Definition at line 57 of file KKSMultiPhaseConcentration.h.

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