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