https://mooseframework.inl.gov
DerivativeMultiPhaseMaterial.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 {
18  params.addClassDescription("Two phase material that combines n phase materials using a switching "
19  "function with and n non-conserved order parameters (to be used with "
20  "SwitchingFunctionConstraint*).");
21  params.addCoupledVar("etas", "Order parameters for all phases.");
22  return params;
23 }
24 
26  : DerivativeMultiPhaseBase(parameters), _dhi(_num_etas), _d2hi(_num_etas), _d3hi(_num_etas)
27 {
28  // verify that the user supplied one less eta than the number of phases
29  if (_num_hi != _num_etas)
30  paramError("hi_names", "The number of hi_names must be equal to the number of coupled etas");
31 
32  for (unsigned int i = 0; i < _num_etas; ++i)
33  {
34  _dhi[i] = &getMaterialPropertyDerivative<Real>(_hi_names[i], _eta_names[i]);
35  _d2hi[i] = &getMaterialPropertyDerivative<Real>(_hi_names[i], _eta_names[i], _eta_names[i]);
36 
38  _d3hi[i] = &getMaterialPropertyDerivative<Real>(
39  _hi_names[i], _eta_names[i], _eta_names[i], _eta_names[i]);
40  }
41 }
42 
43 Real
45 {
46  const unsigned int i = argIndex(i_var);
47  const int i_eta = _eta_index[i];
48 
49  if (i_eta >= 0)
50  return (*_dhi[i_eta])[_qp] * (*_prop_Fi[i_eta])[_qp] + _W * (*_dg[i_eta])[_qp];
51  else
52  {
53  Real dF = 0.0;
54  for (unsigned n = 0; n < _num_fi; ++n)
55  dF += (*_hi[n])[_qp] * (*_prop_dFi[n][i])[_qp];
56  return dF;
57  }
58 }
59 
60 Real
61 DerivativeMultiPhaseMaterial::computeD2F(unsigned int i_var, unsigned int j_var)
62 {
63  const unsigned int i = argIndex(i_var);
64  const int i_eta = _eta_index[i];
65  const unsigned int j = argIndex(j_var);
66  const int j_eta = _eta_index[j];
67 
68  // all arguments are eta-variables
69 
70  if (i_eta >= 0 && j_eta >= 0)
71  {
72  // if the derivatives are taken w.r.t. a single eta the d2hi term for eta_i appears, otherwise
73  // it drops out
74  // because we assume that hi _only_ depends on eta_i
75  Real d2F = (i_eta == j_eta) ? (*_d2hi[i_eta])[_qp] * (*_prop_Fi[i_eta])[_qp] : 0.0;
76 
77  return d2F + _W * (*_d2g[i_eta][j_eta])[_qp];
78  }
79 
80  // one argument is an eta-variable
81 
82  if (i_eta >= 0)
83  return (*_dhi[i_eta])[_qp] * (*_prop_dFi[i_eta][j])[_qp];
84 
85  if (j_eta >= 0)
86  return (*_dhi[j_eta])[_qp] * (*_prop_dFi[j_eta][i])[_qp];
87 
88  // no arguments are eta-variables
89 
90  Real d2F = 0.0;
91  for (unsigned n = 0; n < _num_fi; ++n)
92  d2F += (*_hi[n])[_qp] * (*_prop_d2Fi[n][i][j])[_qp];
93  return d2F;
94 }
95 
96 Real
97 DerivativeMultiPhaseMaterial::computeD3F(unsigned int i_var, unsigned int j_var, unsigned int k_var)
98 {
99  const unsigned int i = argIndex(i_var);
100  const int i_eta = _eta_index[i];
101  const unsigned int j = argIndex(j_var);
102  const int j_eta = _eta_index[j];
103  const unsigned int k = argIndex(k_var);
104  const int k_eta = _eta_index[k];
105 
106  // all arguments are eta-variables
107 
108  if (i_eta >= 0 && j_eta >= 0 && k_eta >= 0)
109  {
110  // if the derivatives are taken w.r.t. a single eta the d3hi term for eta_i appears, otherwise
111  // it drops out
112  // because we assume that hi _only_ depends on eta_i
113  Real d3F =
114  (i_eta == j_eta && j_eta == k_eta) ? (*_d3hi[i_eta])[_qp] * (*_prop_Fi[i_eta])[_qp] : 0.0;
115 
116  return d3F + _W * (*_d3g[i_eta][j_eta][k_eta])[_qp];
117  }
118 
119  // two arguments are eta-variables
120 
121  if (i_eta >= 0 && j_eta >= 0)
122  return (i_eta == j_eta) ? (*_d2hi[i_eta])[_qp] * (*_prop_dFi[i_eta][k])[_qp] : 0.0;
123 
124  if (j_eta >= 0 && k_eta >= 0)
125  return (j_eta == k_eta) ? (*_d2hi[j_eta])[_qp] * (*_prop_dFi[j_eta][i])[_qp] : 0.0;
126 
127  if (k_eta >= 0 && i_eta >= 0)
128  return (k_eta == i_eta) ? (*_d2hi[k_eta])[_qp] * (*_prop_dFi[k_eta][j])[_qp] : 0.0;
129 
130  // one argument is an eta-variable
131 
132  if (i_eta >= 0)
133  return (*_dhi[i_eta])[_qp] * (*_prop_d2Fi[i_eta][j][k])[_qp];
134 
135  if (j_eta >= 0)
136  return (*_dhi[j_eta])[_qp] * (*_prop_d2Fi[j_eta][i][k])[_qp];
137 
138  if (k_eta >= 0)
139  return (*_dhi[k_eta])[_qp] * (*_prop_d2Fi[k_eta][i][j])[_qp];
140 
141  // no arguments are eta-variables
142 
143  Real d3F = 0.0;
144  for (unsigned n = 0; n < _num_fi; ++n)
145  d3F += (*_hi[n])[_qp] * (*_prop_d3Fi[n][i][j][k])[_qp];
146  return d3F;
147 }
virtual Real computeDF(unsigned int i_var)
std::vector< std::vector< std::vector< const MaterialProperty< Real > * > > > _prop_d2Fi
Second derivatives of Fi.
std::vector< std::vector< std::vector< const MaterialProperty< Real > * > > > _d3g
std::vector< const MaterialProperty< Real > * > _dg
Barrier function derivatives.
std::vector< const MaterialProperty< Real > * > _d2hi
registerMooseObject("PhaseFieldApp", DerivativeMultiPhaseMaterial)
std::vector< MaterialPropertyName > _hi_names
phase switching function names
unsigned int _num_etas
name of the order parameter variable
std::vector< std::vector< std::vector< std::vector< const MaterialProperty< Real > * > > > > _prop_d3Fi
Third derivatives of Fi.
Real _W
Phase transformation energy barrier.
std::vector< const MaterialProperty< Real > * > _hi
Switching functions.
Multi phase free energy material that combines an arbitrary number of phase free energies to a global...
std::vector< const MaterialProperty< Real > * > _d3hi
void paramError(const std::string &param, Args... args) const
unsigned int argIndex(unsigned int i_var) const
virtual Real computeD3F(unsigned int i_var, unsigned int j_var, unsigned int k_var)
void addCoupledVar(const std::string &name, const std::string &doc_string)
std::vector< VariableName > _eta_names
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::vector< std::vector< const MaterialProperty< Real > * > > _d2g
static InputParameters validParams()
void addClassDescription(const std::string &doc_string)
std::vector< int > _eta_index
If the variable a non-conserved OP this array holds the index into the etas parameter vector for a gi...
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
DerivativeMaterial child class to evaluate a parsed function for the free energy and automatically pr...
std::vector< const MaterialProperty< Real > * > _prop_Fi
Function value of the i phase.
std::vector< std::vector< const MaterialProperty< Real > * > > _prop_dFi
Derivatives of Fi w.r.t. arg[i].
std::vector< const MaterialProperty< Real > * > _dhi
Function value of the i phase.
DerivativeMultiPhaseMaterial(const InputParameters &parameters)
static const std::string k
Definition: NS.h:130
virtual Real computeD2F(unsigned int i_var, unsigned int j_var)