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