www.mooseframework.org
ThirdPhaseSuppressionMaterial.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  params.addRequiredCoupledVar("etas", "eta_i order parameters, one for each h");
16  params.addClassDescription(
17  "Free Energy contribution that penalizes more than two order parameters being non-zero");
18  return params;
19 }
20 
22  : DerivativeMaterialInterface<Material>(parameters),
23  _function_name(getParam<std::string>("function_name")),
24  _num_eta(coupledComponents("etas")),
25  _eta(_num_eta),
26  _prop_g(declareProperty<Real>(_function_name)),
27  _prop_dg(_num_eta),
28  _prop_d2g(_num_eta)
29 {
30  std::vector<std::string> eta_name(_num_eta);
31  for (unsigned int i = 0; i < _num_eta; ++i)
32  {
33  _prop_d2g[i].resize(_num_eta);
34  // declare derivative properties, fetch eta values
35  eta_name[i] = getVar("etas", i)->name();
36  }
37  for (unsigned int i = 0; i < _num_eta; ++i)
38  {
39  _prop_dg[i] = &declarePropertyDerivative<Real>(_function_name, eta_name[i]);
40  _eta[i] = &coupledValue("etas", i);
41  for (unsigned int j = i; j < _num_eta; ++j)
42  {
43  _prop_d2g[i][j] = _prop_d2g[j][i] =
44  &declarePropertyDerivative<Real>(_function_name, eta_name[i], eta_name[j]);
45  }
46  }
47 }
48 
49 void
51 {
52  // Initialize properties to zero before accumulating
53  _prop_g[_qp] = 0.0;
54  for (unsigned int i = 0; i < _num_eta; ++i)
55  {
56  (*_prop_dg[i])[_qp] = 0.0;
57  for (unsigned int j = i; j < _num_eta; ++j)
58  (*_prop_d2g[i][j])[_qp] = 0.0;
59  }
60 
61  // Create Interface barrier preventing interfaces involving more than two order parameters
62  for (unsigned int i = 0; i < _num_eta; ++i)
63  for (unsigned int j = 0; j < i; ++j)
64  for (unsigned int k = 0; k < j; ++k)
65  {
66  const Real ni = (*_eta[i])[_qp];
67  const Real nj = (*_eta[j])[_qp];
68  const Real nk = (*_eta[k])[_qp];
69 
70  _prop_g[_qp] += ni * ni * nj * nj * nk * nk;
71  (*_prop_dg[i])[_qp] += 2 * ni * nj * nj * nk * nk;
72  (*_prop_dg[j])[_qp] += 2 * ni * ni * nj * nk * nk;
73  (*_prop_dg[k])[_qp] += 2 * ni * ni * nj * nj * nk;
74  (*_prop_d2g[i][i])[_qp] += 2 * nj * nj * nk * nk;
75  (*_prop_d2g[j][j])[_qp] += 2 * ni * ni * nk * nk;
76  (*_prop_d2g[k][k])[_qp] += 2 * ni * ni * nj * nj;
77  (*_prop_d2g[i][j])[_qp] += 4 * ni * nj * nk * nk;
78  (*_prop_d2g[i][k])[_qp] += 4 * ni * nj * nj * nk;
79  (*_prop_d2g[k][j])[_qp] += 4 * ni * ni * nj * nk;
80  }
81 }
std::vector< std::vector< MaterialProperty< Real > * > > _prop_d2g
Material properties to store the second derivatives.
InputParameters validParams< ThirdPhaseSuppressionMaterial >()
unsigned int _num_eta
order parameters
std::vector< const VariableValue * > _eta
ThirdPhaseSuppressionMaterial(const InputParameters &parameters)
MaterialProperty< Real > & _prop_g
Barrier functions and their drivatives.
std::vector< MaterialProperty< Real > * > _prop_dg
std::string _function_name
name of the function of eta (used to generate the material property names)