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 precomputeQpResidual ()
 
virtual Real precomputeQpJacobian ()
 
virtual Real computeQpOffDiagJacobian (unsigned int jvar)
 

Private Attributes

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

Constructor & Destructor Documentation

◆ KKSMultiPhaseConcentration()

KKSMultiPhaseConcentration::KKSMultiPhaseConcentration ( const InputParameters &  parameters)

Definition at line 33 of file KKSMultiPhaseConcentration.C.

34  : DerivativeMaterialInterface<JvarMapKernelInterface<KernelValue>>(parameters),
35  _num_j(coupledComponents("cj")),
36  _cj(_num_j),
37  _cj_map(getParameterJvarMap("cj")),
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_map(getParameterJvarMap("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  _eta_names[i] = getVar("etas", i)->name();
61 
62  // Load concentration variables into the arrays
63  for (unsigned int m = 0; m < _num_j; ++m)
64  {
65  _cj[m] = &coupledValue("cj", m);
66  _prop_hj[m] = &getMaterialPropertyByName<Real>(_hj_names[m]);
67  _prop_dhjdetai[m].resize(_num_j);
68  // Set _k to the position of the nonlinear variable in the list of cj's
69  if (coupled("cj", m) == _var.number())
70  _k = m;
71 
72  // Get derivatives of switching functions wrt order parameters
73  for (unsigned int n = 0; n < _num_j; ++n)
74  _prop_dhjdetai[m][n] = &getMaterialPropertyDerivative<Real>(_hj_names[m], _eta_names[n]);
75  }
76 
77  // Check to make sure the nonlinear variable is set to one of the cj's
78  if (_k < 0)
79  mooseError("Need to set nonlinear variable to one of the cj's in KKSMultiPhaseConcentration",
80  name());
81 }

Member Function Documentation

◆ computeQpOffDiagJacobian()

Real KKSMultiPhaseConcentration::computeQpOffDiagJacobian ( unsigned int  jvar)
protectedvirtual

Definition at line 101 of file KKSMultiPhaseConcentration.C.

102 {
103  if (jvar == _c_var)
104  return -_test[_i][_qp] * _phi[_j][_qp];
105 
106  auto cjvar = mapJvarToCvar(jvar, _cj_map);
107  if (cjvar >= 0)
108  return _test[_i][_qp] * (*_prop_hj[cjvar])[_qp] * _phi[_j][_qp];
109 
110  auto etavar = mapJvarToCvar(jvar, _eta_map);
111  if (etavar >= 0)
112  {
113  Real sum = 0.0;
114 
115  for (unsigned int n = 0; n < _num_j; ++n)
116  sum += (*_prop_dhjdetai[n][etavar])[_qp] * (*_cj[n])[_qp];
117 
118  return _test[_i][_qp] * sum * _phi[_j][_qp];
119  }
120 
121  return 0.0;
122 }

◆ precomputeQpJacobian()

Real KKSMultiPhaseConcentration::precomputeQpJacobian ( )
protectedvirtual

Definition at line 95 of file KKSMultiPhaseConcentration.C.

96 {
97  return (*_prop_hj[_k])[_qp] * _phi[_j][_qp];
98 }

◆ precomputeQpResidual()

Real KKSMultiPhaseConcentration::precomputeQpResidual ( )
protectedvirtual

Definition at line 84 of file KKSMultiPhaseConcentration.C.

85 {
86  // R = sum_i (h_i * c_i) - c
87  Real sum_ch = 0.0;
88  for (unsigned int m = 0; m < _num_j; ++m)
89  sum_ch += (*_cj[m])[_qp] * (*_prop_hj[m])[_qp];
90 
91  return sum_ch - _c[_qp];
92 }

Member Data Documentation

◆ _c

const VariableValue& KKSMultiPhaseConcentration::_c
private

Definition at line 54 of file KKSMultiPhaseConcentration.h.

Referenced by precomputeQpResidual().

◆ _c_var

unsigned int KKSMultiPhaseConcentration::_c_var
private

Definition at line 55 of file KKSMultiPhaseConcentration.h.

Referenced by computeQpOffDiagJacobian().

◆ _cj

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

◆ _cj_map

const JvarMap& KKSMultiPhaseConcentration::_cj_map
private

Definition at line 49 of file KKSMultiPhaseConcentration.h.

Referenced by computeQpOffDiagJacobian().

◆ _eta_map

const JvarMap& KKSMultiPhaseConcentration::_eta_map
private

Definition at line 63 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 62 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 58 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 52 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 66 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:
KKSMultiPhaseConcentration::_prop_dhjdetai
std::vector< std::vector< const MaterialProperty< Real > * > > _prop_dhjdetai
Derivative of the switching function .
Definition: KKSMultiPhaseConcentration.h:66
KKSMultiPhaseConcentration::_c
const VariableValue & _c
Definition: KKSMultiPhaseConcentration.h:54
KKSMultiPhaseConcentration::_c_var
unsigned int _c_var
Definition: KKSMultiPhaseConcentration.h:55
KKSMultiPhaseConcentration::_k
int _k
Position of the nonlinear variable in the list of cj's.
Definition: KKSMultiPhaseConcentration.h:52
KKSMultiPhaseConcentration::_num_j
const unsigned int _num_j
Definition: KKSMultiPhaseConcentration.h:47
KKSMultiPhaseConcentration::_cj_map
const JvarMap & _cj_map
Definition: KKSMultiPhaseConcentration.h:49
KKSMultiPhaseConcentration::_prop_hj
std::vector< const MaterialProperty< Real > * > _prop_hj
Definition: KKSMultiPhaseConcentration.h:59
KKSMultiPhaseConcentration::_eta_names
std::vector< VariableName > _eta_names
Order parameters for each phase .
Definition: KKSMultiPhaseConcentration.h:62
KKSMultiPhaseConcentration::_hj_names
std::vector< MaterialPropertyName > _hj_names
Switching functions for each phase .
Definition: KKSMultiPhaseConcentration.h:58
name
const std::string name
Definition: Setup.h:21
KKSMultiPhaseConcentration::_cj
std::vector< const VariableValue * > _cj
Definition: KKSMultiPhaseConcentration.h:48
KKSMultiPhaseConcentration::_eta_map
const JvarMap & _eta_map
Definition: KKSMultiPhaseConcentration.h:63