https://mooseframework.inl.gov
Loading...
Searching...
No Matches
DerivativeMultiPhaseBase.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
14{
16
17 // Phase materials 1-n
18 params.addRequiredParam<std::vector<MaterialPropertyName>>(
19 "fi_names", "List of free energies for the n phases");
20 params.addParam<std::vector<MaterialPropertyName>>(
21 "hi_names", "Switching Function Materials that provide h(eta_i)");
22
23 // All arguments of the phase free energies
24 params.addCoupledVar("coupled_variables", "Vector of variable arguments of the fi free energies");
25 params.addCoupledVar("displacement_gradients",
26 "Vector of displacement gradient variables (see "
27 "Modules/PhaseField/DisplacementGradients "
28 "action)");
29
30 // Barrier
31 params.addParam<MaterialPropertyName>(
32 "g", "g", "Barrier Function Material that provides g(eta_i)");
33 params.addParam<Real>("W", 0.0, "Energy barrier for the phase transformation from A to B");
34
35 return params;
36}
37
40 _eta_index(_nargs, -1),
41 _num_etas(coupledComponents("etas")),
42 _eta_names(_num_etas),
43 _eta_vars(_num_etas),
44 _fi_names(getParam<std::vector<MaterialPropertyName>>("fi_names")),
45 _num_fi(_fi_names.size()),
46 _prop_Fi(_num_fi),
47 _prop_dFi(_num_fi),
48 _prop_d2Fi(_num_fi),
49 _prop_d3Fi(_num_fi),
50 _hi_names(getParam<std::vector<MaterialPropertyName>>("hi_names")),
51 _num_hi(_hi_names.size()),
52 _hi(_num_hi),
53 _g(getMaterialProperty<Real>("g")),
54 _dg(_num_etas),
55 _d2g(_num_etas),
56 _d3g(_num_etas),
57 _W(getParam<Real>("W"))
58{
59 // check passed in parameter vectors
60 if (_num_fi != _num_hi)
61 mooseError("Need to pass in as many hi_names as fi_names in DerivativeMultiPhaseBase ", name());
62
63 // get order parameter names and libmesh variable names, set barrier function derivatives
64 for (unsigned int i = 0; i < _num_etas; ++i)
65 {
66 _eta_names[i] = coupledName("etas", i);
67 _eta_vars[i] = coupled("etas", i);
68
69 // for each coupled variable we need to know if it was coupled through "etas"
70 // and - if so - which coupled component of "etas" it comes from
72
73 // barrier function derivatives
74 _dg[i] = &getMaterialPropertyDerivative<Real>("g", _eta_names[i]);
75 _d2g[i].resize(_num_etas);
77 _d3g[i].resize(_num_etas);
78
79 for (unsigned int j = 0; j < _num_etas; ++j)
80 {
81 _d2g[i][j] = &getMaterialPropertyDerivative<Real>("g", _eta_names[i], _eta_names[j]);
82
84 {
85 _d3g[i][j].resize(_num_etas);
86 for (unsigned int k = 0; k < _num_etas; ++k)
87 _d3g[i][j][k] = &getMaterialPropertyDerivative<Real>(
88 "g", _eta_names[i], _eta_names[j], _eta_names[k]);
89 }
90 }
91 }
92
93 // reserve space and set phase material properties
94 for (unsigned int n = 0; n < _num_fi; ++n)
95 {
96 // get phase free energy
97 _prop_Fi[n] = &getMaterialPropertyByName<Real>(_fi_names[n]);
98 _prop_dFi[n].resize(_nargs);
99 _prop_d2Fi[n].resize(_nargs);
100 _prop_d3Fi[n].resize(_nargs);
101
102 // get switching function
103 _hi[n] = &getMaterialPropertyByName<Real>(_hi_names[n]);
104
105 for (unsigned int i = 0; i < _nargs; ++i)
106 {
107 _prop_dFi[n][i] = &getMaterialPropertyDerivative<Real>(_fi_names[n], _arg_names[i]);
108 _prop_d2Fi[n][i].resize(_nargs);
109
111 _prop_d3Fi[n][i].resize(_nargs);
112
113 for (unsigned int j = 0; j < _nargs; ++j)
114 {
115 _prop_d2Fi[n][i][j] =
116 &getMaterialPropertyDerivative<Real>(_fi_names[n], _arg_names[i], _arg_names[j]);
117
119 {
120 _prop_d3Fi[n][i][j].resize(_nargs);
121
122 for (unsigned int k = 0; k < _nargs; ++k)
123 _prop_d3Fi[n][i][j][k] = &getMaterialPropertyDerivative<Real>(
125 }
126 }
127 }
128 }
129}
130
131void
133{
134 for (unsigned int n = 0; n < _num_fi; ++n)
135 validateCoupling<Real>(_fi_names[n]);
136}
137
138Real
140{
141 Real F = 0.0;
142 for (unsigned n = 0; n < _num_fi; ++n)
143 F += (*_hi[n])[_qp] * (*_prop_Fi[n])[_qp];
144 return F + _W * _g[_qp];
145}
VariableName coupledName(const std::string &var_name, unsigned int comp=0) const
virtual unsigned int coupled(const std::string &var_name, unsigned int comp=0) const
static InputParameters validParams()
std::vector< unsigned int > _eta_vars
unsigned int _num_etas
name of the order parameter variable
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...
Real _W
Phase transformation energy barrier.
std::vector< MaterialPropertyName > _fi_names
phase derivative material names
DerivativeMultiPhaseBase(const InputParameters &parameters)
std::vector< std::vector< std::vector< const MaterialProperty< Real > * > > > _d3g
const MaterialProperty< Real > & _g
Barrier function .
static InputParameters validParams()
std::vector< MaterialPropertyName > _hi_names
phase switching function names
std::vector< VariableName > _eta_names
std::vector< std::vector< std::vector< std::vector< const MaterialProperty< Real > * > > > > _prop_d3Fi
Third derivatives of Fi.
std::vector< const MaterialProperty< Real > * > _prop_Fi
Function value of the i phase.
std::vector< const MaterialProperty< Real > * > _dg
Barrier function derivatives.
std::vector< std::vector< const MaterialProperty< Real > * > > _prop_dFi
Derivatives of Fi w.r.t. arg[i].
std::vector< const MaterialProperty< Real > * > _hi
Switching functions.
std::vector< std::vector< const MaterialProperty< Real > * > > _d2g
std::vector< std::vector< std::vector< const MaterialProperty< Real > * > > > _prop_d2Fi
Second derivatives of Fi.
std::vector< std::string > _arg_names
unsigned int argIndex(unsigned int i_var) const
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addCoupledVar(const std::string &name, const std::string &doc_string)
const std::string & name() const
void mooseError(Args &&... args) const