www.mooseframework.org
CrossTermBarrierFunctionBase.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
8 
9 template <>
10 InputParameters
12 {
13  InputParameters params = validParams<Material>();
14  params.addParam<std::string>("function_name", "g", "actual name for g(eta_i)");
15  MooseEnum g_order("SIMPLE=0 LOW", "SIMPLE");
16  params.addParam<MooseEnum>("g_order", g_order, "Polynomial order of the barrier function g(eta)");
17  params.addRequiredCoupledVar("etas", "eta_i order parameters, one for each h");
18  params.addRequiredParam<std::vector<Real>>("W_ij",
19  "Terms controlling barrier height set W=1 in "
20  "DerivativeMultiPhaseMaterial for these to "
21  "apply");
22  return params;
23 }
24 
26  : DerivativeMaterialInterface<Material>(parameters),
27  _function_name(getParam<std::string>("function_name")),
28  _g_order(getParam<MooseEnum>("g_order")),
29  _W_ij(getParam<std::vector<Real>>("W_ij")),
30  _num_eta(coupledComponents("etas")),
31  _eta_names(_num_eta),
32  _eta(_num_eta),
33  _prop_g(declareProperty<Real>(_function_name)),
34  _prop_dg(_num_eta),
35  _prop_d2g(_num_eta)
36 {
37  // if Vector W_ij is not the correct size to fill the matrix give error
38  if (_num_eta * _num_eta != _W_ij.size())
39  mooseError("Size of W_ij does not match (number of etas)^2. Supply W_ij of correct size.");
40 
41  // error out if the W_ij diagonal values are not zero
42  for (unsigned int i = 0; i < _num_eta; ++i)
43  if (_W_ij[_num_eta * i + i] != 0)
44  mooseError("Set on-diagonal values of W_ij to zero.");
45 
46  // declare g derivative properties, fetch eta values
47  for (unsigned int i = 0; i < _num_eta; ++i)
48  {
49  _prop_d2g[i].resize(_num_eta);
50  _eta_names[i] = getVar("etas", i)->name();
51  }
52 
53  for (unsigned int i = 0; i < _num_eta; ++i)
54  {
55  _prop_dg[i] = &declarePropertyDerivative<Real>(_function_name, _eta_names[i]);
56  _eta[i] = &coupledValue("etas", i);
57  for (unsigned int j = i; j < _num_eta; ++j)
58  {
59  _prop_d2g[i][j] = _prop_d2g[j][i] =
60  &declarePropertyDerivative<Real>(_function_name, _eta_names[i], _eta_names[j]);
61  }
62  }
63 }
64 
65 void
67 {
68  // Initialize properties to zero before accumulating
69  _prop_g[_qp] = 0.0;
70  for (unsigned int i = 0; i < _num_eta; ++i)
71  {
72  (*_prop_dg[i])[_qp] = 0.0;
73  (*_prop_d2g[i][i])[_qp] = 0.0;
74  }
75 }
std::vector< Real > _W_ij
barrier function height matrix
std::vector< std::vector< MaterialProperty< Real > * > > _prop_d2g
std::string _function_name
name of the function of eta (used to generate the material property names)
unsigned int _num_eta
order parameters
std::vector< MaterialProperty< Real > * > _prop_dg
std::vector< VariableName > _eta_names
InputParameters validParams< CrossTermBarrierFunctionBase >()
CrossTermBarrierFunctionBase(const InputParameters &parameters)
MaterialProperty< Real > & _prop_g
Barrier function and its derivatives.
std::vector< const VariableValue * > _eta