https://mooseframework.inl.gov
SLKKSMultiPhaseBase.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 
10 #include "SLKKSMultiPhaseBase.h"
11 
14 {
15  auto params = Kernel::validParams();
16  params.addRequiredCoupledVar("cs", "Array of sublattice concentrations phase for all phases");
17  params.addCoupledVar("eta", "Order parameters for all phases");
18  params.addRequiredParam<std::vector<unsigned int>>("ns", "Number of sublattices in each phase");
19  params.addRequiredParam<std::vector<Real>>("as", "Sublattice site fractions n all phases");
20  params.addRequiredParam<std::vector<MaterialPropertyName>>(
21  "h_names", "Switching Function Materials for all phases");
22  return params;
23 }
24 
25 // Phase interpolation func
28  _ncs(coupledComponents("cs")),
29  _cs(_ncs),
30  _cs_map(getParameterJvarMap("cs")),
31  _ns(getParam<std::vector<unsigned int>>("ns")),
32  _neta(coupledComponents("eta")),
33  _eta_names(_neta),
34  _eta_map(getParameterJvarMap("eta")),
35  _a_cs(getParam<std::vector<Real>>("as")),
36  _h_names(getParam<std::vector<MaterialPropertyName>>("h_names")),
37  _nh(_h_names.size()),
38  _phase(_ncs),
39  _c(coupledValue("c")),
40  _c_var(coupled("c"))
41 {
42  // consistent number of phases?
43  if (_ns.size() != _nh)
44  paramError("ns",
45  "Need to pass in as many switching functions (parameter `h_names`) as size of "
46  "number of sublattices in each phase (parameter `ns`)");
47 
48  // sum up ns numbers
49  unsigned int nssum = 0;
50  for (auto i : _ns)
51  {
52  if (i == 0)
53  paramError("ns", "All sublattice counts must be larger than zero");
54  nssum += i;
55  }
56 
57  if (nssum != _ncs)
58  paramError("ns", "Numbers need to sum up to the number of passed in cs variables");
59  if (_ncs == 0)
60  paramError("cs", "Need to supply at least 1 phase sublattice concentration");
61 
62  // get order parameter names
63  for (std::size_t i = 0; i < _neta; ++i)
64  _eta_names[i] = coupledName("eta", i);
65 
66  // Load concentration variables into the arrays
67  for (std::size_t i = 0; i < _ncs; ++i)
68  _cs[i] = &coupledValue("cs", i);
69 
70  // normalize sublattice counts within each phase
71  std::size_t k = 0;
72  for (std::size_t i = 0; i < _nh; ++i)
73  {
74  // sum site counts
75  Real sum = _a_cs[k];
76  for (unsigned int j = 1; j < _ns[i]; ++j)
77  sum += _a_cs[j + k];
78  if (sum <= 0)
79  paramError("as", "Sum of sublattice site counts in each phase must be larger than zero");
80 
81  // normalize
82  for (unsigned int j = 0; j < _ns[i]; ++j)
83  {
84  _a_cs[j + k] /= sum;
85 
86  // remember phase index
87  _phase[j + k] = i;
88  }
89 
90  // next phase
91  k += _ns[i];
92  }
93 
94  // consistency checks
95  if (k != _ncs)
96  mooseError("Internal error");
97 }
const std::size_t _neta
Order parameters for each phase .
static InputParameters validParams()
void mooseError(Args &&... args)
const std::size_t _ncs
Sublattice concentrations.
std::vector< VariableName > _eta_names
std::vector< const VariableValue * > _cs
std::vector< Real > _a_cs
Sublattice site numbers.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const std::size_t _nh
std::vector< unsigned int > _phase
phase index of each cs entry
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
SLKKSMultiPhaseBase(const InputParameters &parameters)
static InputParameters validParams()
std::vector< unsigned int > _ns
Number of sublattices per phase.
static const std::string k
Definition: NS.h:130
void ErrorVector unsigned int