https://mooseframework.inl.gov
SLKKSMultiPhaseConcentration.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
11 
13 
16 {
17  auto params = SLKKSMultiPhaseBase::validParams();
18  params.addClassDescription(
19  "SLKKS multi-phase model kernel to enforce $c_i = \\sum_j h_j\\sum_k a_{jk} c_{ijk}$. "
20  "The non-linear variable of this kernel is a phase's sublattice concentration");
21  params.addRequiredCoupledVar("c", "Physical concentration");
22  return params;
23 }
24 
25 // Phase interpolation func
27  : SLKKSMultiPhaseBase(parameters), _l(-1), _prop_h(_nh), _prop_dhdeta(_nh)
28 {
29  // Fetch switching functions and their derivatives
30  for (std::size_t i = 0; i < _nh; ++i)
31  {
32  _prop_h[i] = &getMaterialPropertyByName<Real>(_h_names[i]);
33  _prop_dhdeta[i].resize(_neta);
34 
35  // Get derivatives of switching functions w.r.t. order parameters
36  for (std::size_t j = 0; j < _neta; ++j)
37  _prop_dhdeta[i][j] = &getMaterialPropertyDerivativeByName<Real>(_h_names[i], _eta_names[j]);
38  }
39 
40  // Determine position of the nonlinear variable
41  for (std::size_t i = 0; i < _ncs; ++i)
42  if (coupled("cs", i) == _var.number())
43  _l = i;
44 
45  // Check to make sure the nonlinear variable is in the cs list
46  if (_l < 0)
47  paramError("cs", "One of the listed variables must be the kernel variable");
48 }
49 
50 Real
52 {
53  // sum over phases
54  std::size_t k = 0;
55  Real sum = 0.0;
56  for (std::size_t i = 0; i < _nh; ++i)
57  {
58  // sum sublattice concentrations
59  Real csum = 0.0;
60  for (unsigned int j = 0; j < _ns[i]; ++j)
61  {
62  csum += (*_cs[k])[_qp] * _a_cs[k];
63  k++;
64  }
65  sum += (*_prop_h[i])[_qp] * csum;
66  }
67  return sum - _c[_qp];
68 }
69 
70 Real
72 {
73  return (*_prop_h[_phase[_l]])[_qp] * _phi[_j][_qp] * _a_cs[_l];
74 }
75 
76 Real
78 {
79  if (jvar == _c_var)
80  return -_test[_i][_qp] * _phi[_j][_qp];
81 
82  auto csvar = mapJvarToCvar(jvar, _cs_map);
83  if (csvar >= 0)
84  return _test[_i][_qp] * (*_prop_h[_phase[csvar]])[_qp] * _phi[_j][_qp] * _a_cs[csvar];
85 
86  auto etavar = mapJvarToCvar(jvar, _eta_map);
87  if (etavar >= 0)
88  {
89  Real sum = 0.0;
90  for (unsigned int i = 0; i < _ncs; ++i)
91  sum += (*_prop_dhdeta[_phase[i]][etavar])[_qp] * (*_cs[i])[_qp] * _a_cs[i];
92 
93  return _test[_i][_qp] * sum * _phi[_j][_qp];
94  }
95 
96  return 0.0;
97 }
const std::size_t _neta
Order parameters for each phase .
int _l
Position of the nonlinear variable in the cs list.
const JvarMap & _cs_map
std::vector< std::vector< const MaterialProperty< Real > * > > _prop_dhdeta
const std::size_t _ncs
Sublattice concentrations.
const unsigned int _c_var
std::vector< VariableName > _eta_names
std::vector< const VariableValue * > _cs
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
const VariableValue & _c
Physical concentration.
std::vector< Real > _a_cs
Sublattice site numbers.
const JvarMap & _eta_map
registerMooseObject("PhaseFieldApp", SLKKSMultiPhaseConcentration)
Enforce sum of phase sublattice concentrations to be the real concentration.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const std::size_t _nh
SLKKSMultiPhaseConcentration(const InputParameters &parameters)
std::vector< const MaterialProperty< Real > * > _prop_h
Switching functions for each phase and their derivatives w.r.t. all etas.
std::vector< unsigned int > _phase
phase index of each cs entry
Enforce sum of phase sublattice concentrations to be the real concentration.
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
std::vector< MaterialPropertyName > _h_names
Switching function names.
static InputParameters validParams()
std::vector< unsigned int > _ns
Number of sublattices per phase.
static const std::string k
Definition: NS.h:130