www.mooseframework.org
AsymmetricCrossTermBarrierFunctionMaterial.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<CrossTermBarrierFunctionBase>();
14  params.addClassDescription(
15  "Free energy contribution asymmetric across interfaces between arbitrary pairs of phases.");
16  params.addParam<std::vector<MaterialPropertyName>>(
17  "hi_names", "Switching Function Materials that provide h(eta_i)");
18  return params;
19 }
20 
22  const InputParameters & parameters)
23  : CrossTermBarrierFunctionBase(parameters), _h(_num_eta), _dh(_num_eta), _d2h(_num_eta)
24 {
25  // switching functions
26  const std::vector<MaterialPropertyName> & hi_names =
27  getParam<std::vector<MaterialPropertyName>>("hi_names");
28  if (hi_names.size() != _num_eta)
29  mooseError("The number of coupled etas must be equal to the number of hi_names in "
30  "AsymmetricCrossTermBarrierFunctionMaterial ",
31  name());
32 
33  for (unsigned int i = 0; i < _num_eta; ++i)
34  {
35  _h[i] = &getMaterialProperty<Real>(hi_names[i]);
36  _dh[i] = &getMaterialPropertyDerivative<Real>(hi_names[i], _eta_names[i]);
37  _d2h[i] = &getMaterialPropertyDerivative<Real>(hi_names[i], _eta_names[i], _eta_names[i]);
38  }
39 }
40 
41 void
43 {
44  // Initialize properties to zero before accumulating
46 
47  // Sum the components of our W_ij matrix to get constant used in our g function
48  for (unsigned int i = 0; i < _num_eta; ++i)
49  for (unsigned int j = i + 1; j < _num_eta; ++j)
50  {
51  // readable aliases
52  const Real ni = (*_eta[i])[_qp];
53  const Real nj = (*_eta[j])[_qp];
54 
55  const Real Wij = _W_ij[_num_eta * i + j];
56  const Real Wji = _W_ij[_num_eta * j + i];
57 
58  const Real hi = (*_h[i])[_qp];
59  const Real hj = (*_h[j])[_qp];
60  const Real dhi = (*_dh[i])[_qp];
61  const Real dhj = (*_dh[j])[_qp];
62  const Real d2hi = (*_d2h[i])[_qp];
63  const Real d2hj = (*_d2h[j])[_qp];
64 
65  // raw barrier term and derivatives
66  Real B, dBi, dBj, d2Bii, d2Bjj, d2Bij;
67  switch (_g_order)
68  {
69  case 0: // SIMPLE
70  B = 16.0 * ni * ni * nj * nj;
71  dBi = 16.0 * 2.0 * ni * nj * nj;
72  dBj = 16.0 * 2.0 * ni * ni * nj;
73  d2Bii = 16.0 * 2.0 * nj * nj;
74  d2Bjj = 16.0 * 2.0 * ni * ni;
75  d2Bij = 16.0 * 4.0 * ni * nj;
76  break;
77 
78  case 1: // LOW
79  B = 4.0 * ni * nj;
80  dBi = 4.0 * nj;
81  dBj = 4.0 * ni;
82  d2Bii = 0.0;
83  d2Bjj = 0.0;
84  d2Bij = 4.0;
85  break;
86 
87  default:
88  mooseError("Internal error");
89  }
90 
91  _prop_g[_qp] += (Wij * hi + Wji * hj) * B;
92  // first derivatives
93  (*_prop_dg[i])[_qp] += (Wij * hi + Wji * hj) * dBi + (Wij * dhi) * B;
94  (*_prop_dg[j])[_qp] += (Wij * hi + Wji * hj) * dBj + (Wji * dhj) * B;
95  // second derivatives (diagonal)
96  (*_prop_d2g[i][i])[_qp] +=
97  (Wij * hi + Wji * hj) * d2Bii + 2 * (Wij * dhi) * dBi + (Wij * d2hi) * B;
98  (*_prop_d2g[j][j])[_qp] +=
99  (Wij * hi + Wji * hj) * d2Bjj + 2 * (Wji * dhj) * dBj + (Wji * d2hj) * B;
100  // second derivatives (off-diagonal)
101  (*_prop_d2g[i][j])[_qp] =
102  (Wij * hi + Wji * hj) * (d2Bij) + (Wji * dhj) * dBi + (Wij * dhi) * dBj;
103  }
104 }
std::vector< Real > _W_ij
barrier function height matrix
std::vector< std::vector< MaterialProperty< Real > * > > _prop_d2g
unsigned int _num_eta
order parameters
std::vector< const MaterialProperty< Real > * > _h
Switching functions and their drivatives.
std::vector< MaterialProperty< Real > * > _prop_dg
std::vector< VariableName > _eta_names
std::vector< const MaterialProperty< Real > * > _d2h
std::vector< const MaterialProperty< Real > * > _dh
InputParameters validParams< AsymmetricCrossTermBarrierFunctionMaterial >()
MaterialProperty< Real > & _prop_g
Barrier function and its derivatives.
AsymmetricCrossTermBarrierFunctionMaterial(const InputParameters &parameters)
InputParameters validParams< CrossTermBarrierFunctionBase >()
std::vector< const VariableValue * > _eta
unsigned int _g_order
polynomial order of the switching function
CrossTermBarrierFunctionBase is the base to a set of free energy penalties that set the phase interfa...