www.mooseframework.org
ThirdPhaseSuppressionMaterial.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 
16 {
18  params.addParam<std::string>("function_name", "g", "actual name for g(eta_i)");
19  params.addRequiredCoupledVar("etas", "eta_i order parameters, one for each h");
20  params.addClassDescription(
21  "Free Energy contribution that penalizes more than two order parameters being non-zero");
22  return params;
23 }
24 
27  _function_name(getParam<std::string>("function_name")),
28  _num_eta(coupledComponents("etas")),
29  _eta(coupledValues("etas")),
30  _prop_g(declareProperty<Real>(_function_name)),
31  _prop_dg(_num_eta),
32  _prop_d2g(_num_eta)
33 {
34  const auto eta_name = coupledNames("etas");
35 
36  for (unsigned int i = 0; i < _num_eta; ++i)
37  _prop_d2g[i].resize(_num_eta);
38 
39  for (unsigned int i = 0; i < _num_eta; ++i)
40  {
41  _prop_dg[i] = &declarePropertyDerivative<Real>(_function_name, eta_name[i]);
42  for (unsigned int j = i; j < _num_eta; ++j)
43  {
44  _prop_d2g[i][j] = _prop_d2g[j][i] =
45  &declarePropertyDerivative<Real>(_function_name, eta_name[i], eta_name[j]);
46  }
47  }
48 }
49 
50 void
52 {
53  // Initialize properties to zero before accumulating
54  _prop_g[_qp] = 0.0;
55  for (unsigned int i = 0; i < _num_eta; ++i)
56  {
57  (*_prop_dg[i])[_qp] = 0.0;
58  for (unsigned int j = i; j < _num_eta; ++j)
59  (*_prop_d2g[i][j])[_qp] = 0.0;
60  }
61 
62  // Create Interface barrier preventing interfaces involving more than two order parameters
63  for (unsigned int i = 0; i < _num_eta; ++i)
64  for (unsigned int j = 0; j < i; ++j)
65  for (unsigned int k = 0; k < j; ++k)
66  {
67  const Real ni = (*_eta[i])[_qp];
68  const Real nj = (*_eta[j])[_qp];
69  const Real nk = (*_eta[k])[_qp];
70 
71  _prop_g[_qp] += ni * ni * nj * nj * nk * nk;
72  (*_prop_dg[i])[_qp] += 2 * ni * nj * nj * nk * nk;
73  (*_prop_dg[j])[_qp] += 2 * ni * ni * nj * nk * nk;
74  (*_prop_dg[k])[_qp] += 2 * ni * ni * nj * nj * nk;
75  (*_prop_d2g[i][i])[_qp] += 2 * nj * nj * nk * nk;
76  (*_prop_d2g[j][j])[_qp] += 2 * ni * ni * nk * nk;
77  (*_prop_d2g[k][k])[_qp] += 2 * ni * ni * nj * nj;
78  (*_prop_d2g[i][j])[_qp] += 4 * ni * nj * nk * nk;
79  (*_prop_d2g[i][k])[_qp] += 4 * ni * nj * nj * nk;
80  (*_prop_d2g[k][j])[_qp] += 4 * ni * ni * nj * nk;
81  }
82 }
const unsigned int _num_eta
order parameters
std::vector< std::vector< MaterialProperty< Real > * > > _prop_d2g
Material properties to store the second derivatives.
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
const std::vector< const VariableValue * > _eta
std::vector< VariableName > coupledNames(const std::string &var_name) const
static InputParameters validParams()
ThirdPhaseSuppressionMaterial(const InputParameters &parameters)
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
OPInterfaceBarrierMaterial is a Free Energy Penalty contribution material that acts on all of the eta...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
registerMooseObject("PhaseFieldApp", ThirdPhaseSuppressionMaterial)
void addClassDescription(const std::string &doc_string)
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
MaterialProperty< Real > & _prop_g
Barrier functions and their drivatives.
std::vector< MaterialProperty< Real > * > _prop_dg
std::string _function_name
name of the function of eta (used to generate the material property names)
static const std::string k
Definition: NS.h:124