www.mooseframework.org
ACGrGrMulti.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
7 #include "ACGrGrMulti.h"
8 
9 template <>
10 InputParameters
12 {
13  InputParameters params = validParams<ACGrGrBase>();
14  params.addClassDescription("Multi-phase poly-crystaline Allen-Cahn Kernel");
15  params.addRequiredParam<std::vector<MaterialPropertyName>>(
16  "gamma_names",
17  "List of gamma material property names for each other order parameter. Place "
18  "in same order as order parameters (v)!");
19  return params;
20 }
21 
22 ACGrGrMulti::ACGrGrMulti(const InputParameters & parameters)
23  : ACGrGrBase(parameters),
24  _gamma_names(getParam<std::vector<MaterialPropertyName>>("gamma_names")),
25  _num_j(_gamma_names.size()),
26  _prop_gammas(_num_j)
27 {
28  // check passed in parameter vectors
29  if (_num_j != coupledComponents("v"))
30  mooseError("Need to pass in as many gamma_names as coupled variables in v in ACGrGrMulti",
31  name());
32 
33  for (unsigned int n = 0; n < _num_j; ++n)
34  _prop_gammas[n] = &getMaterialPropertyByName<Real>(_gamma_names[n]);
35 }
36 
37 Real
39 {
40  // Sum all other order parameters
41  Real SumGammaEtaj = 0.0;
42  for (unsigned int i = 0; i < _op_num; ++i)
43  SumGammaEtaj += (*_prop_gammas[i])[_qp] * (*_vals[i])[_qp] * (*_vals[i])[_qp];
44 
45  // Calculate either the residual or Jacobian of the grain growth free energy
46  switch (type)
47  {
48  case Residual:
49  {
50  return _mu[_qp] * (_u[_qp] * _u[_qp] * _u[_qp] - _u[_qp] + 2.0 * _u[_qp] * SumGammaEtaj);
51  }
52 
53  case Jacobian:
54  {
55  return _mu[_qp] * (_phi[_j][_qp] * (3.0 * _u[_qp] * _u[_qp] - 1.0 + 2.0 * SumGammaEtaj));
56  }
57 
58  default:
59  mooseError("Invalid type passed in");
60  }
61 }
62 
63 Real
65 {
66  for (unsigned int i = 0; i < _op_num; ++i)
67  if (jvar == _vals_var[i])
68  {
69  // Derivative of SumGammaEtaj
70  const Real dSumGammaEtaj = 2.0 * (*_prop_gammas[i])[_qp] * (*_vals[i])[_qp] * _phi[_j][_qp];
71  const Real dDFDOP = _mu[_qp] * 2.0 * _u[_qp] * dSumGammaEtaj;
72 
73  return _L[_qp] * _test[_i][_qp] * dDFDOP;
74  }
75 
76  return 0.0;
77 }
This is the base class for kernels that calculate the residual for grain growth.
Definition: ACGrGrBase.h:23
const unsigned int _op_num
Definition: ACGrGrBase.h:29
const MaterialProperty< Real > & _L
Mobility.
Definition: ACBulk.h:44
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
Definition: ACGrGrMulti.C:64
std::vector< unsigned int > _vals_var
Definition: ACGrGrBase.h:32
std::vector< MaterialPropertyName > _gamma_names
Names of gammas for each order parameter.
Definition: ACGrGrMulti.h:33
unsigned int _num_j
Definition: ACGrGrMulti.h:34
InputParameters validParams< ACGrGrBase >()
Definition: ACGrGrBase.C:11
const MaterialProperty< Real > & _mu
Definition: ACGrGrBase.h:34
std::vector< const MaterialProperty< Real > * > _prop_gammas
Values of gammas for each order parameter.
Definition: ACGrGrMulti.h:37
InputParameters validParams< ACGrGrMulti >()
Definition: ACGrGrMulti.C:11
ACGrGrMulti(const InputParameters &parameters)
Definition: ACGrGrMulti.C:22
std::vector< const VariableValue * > _vals
Definition: ACGrGrBase.h:31
virtual Real computeDFDOP(PFFunctionType type)
Definition: ACGrGrMulti.C:38