www.mooseframework.org
ACSEDGPoly.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 "ACSEDGPoly.h"
8 #include "Material.h"
10 
11 template <>
12 InputParameters
14 {
15  InputParameters params = ACBulk<Real>::validParams();
16  params.addClassDescription("Stored Energy contribution to grain growth");
17  params.addRequiredCoupledVar("v", "Array of coupled variable names");
18  params.addRequiredParam<unsigned int>("deformed_grain_num",
19  "Number of OP representing deformed grains");
20  params.addRequiredParam<UserObjectName>("grain_tracker",
21  "The GrainTracker UserObject to get values from.");
22  return params;
23 }
24 
25 ACSEDGPoly::ACSEDGPoly(const InputParameters & parameters)
26  : ACBulk<Real>(parameters),
27  _op_num(coupledComponents("v")),
28  _vals(_op_num),
29  _vals_var(_op_num),
30  _beta(getMaterialProperty<Real>("beta")),
31  _rho_eff(getMaterialProperty<Real>("rho_eff")),
32  _Disloc_Den_i(getMaterialProperty<Real>("Disloc_Den_i")),
33  _deformed_grain_num(getParam<unsigned int>("deformed_grain_num")),
34  _grain_tracker(getUserObject<GrainTrackerInterface>("grain_tracker")),
35  _op_index(getParam<unsigned int>("op_index"))
36 {
37  // Loop through grains and load coupled variables into the arrays
38  for (unsigned int i = 0; i < _op_num; ++i)
39  {
40  _vals[i] = &coupledValue("v", i);
41  _vals_var[i] = coupled("v", i);
42  }
43 }
44 
45 Real
47 {
48  Real SumEtaj = 0.0;
49  for (unsigned int i = 0; i < _op_num; ++i)
50  SumEtaj += (*_vals[i])[_qp] * (*_vals[i])[_qp];
51 
52  // Add the current OP to the sum
53  Real SumEtai2 = SumEtaj + _u[_qp] * _u[_qp];
54  // Dislocation density in deformed grains
55  Real rho_i = _Disloc_Den_i[_qp];
56  // undeformed grains are dislocation-free
57  const auto & op_to_grain = _grain_tracker.getVarToFeatureVector(_current_elem->id());
58  const auto grn_index = op_to_grain[_op_index];
59  if (grn_index >= _deformed_grain_num)
60  rho_i = 0.0;
61 
62  // Calculate the contributions of the deformation energy to the residual and Jacobian
63  Real drho_eff_detai = 2.0 * _u[_qp] * (rho_i - _rho_eff[_qp]) / SumEtai2;
64 
65  // Calculate the Stored Energy contribution to either the residual or Jacobian of the grain growth
66  // free energy
67  switch (type)
68  {
69  case Residual:
70  return _beta[_qp] * drho_eff_detai;
71 
72  case Jacobian:
73  return _beta[_qp] * _phi[_j][_qp] *
74  (2.0 * SumEtai2 * ((rho_i - _rho_eff[_qp]) - _u[_qp] * drho_eff_detai) -
75  4.0 * _u[_qp] * _u[_qp] * (rho_i - _rho_eff[_qp])) /
76  (SumEtai2 * SumEtai2);
77  }
78  mooseError("Invalid type passed in");
79 }
const unsigned int _op_num
Definition: ACSEDGPoly.h:35
std::vector< unsigned int > _vals_var
Definition: ACSEDGPoly.h:38
This class defines the interface for the GrainTracking objects.
unsigned int _deformed_grain_num
number of deformed grains
Definition: ACSEDGPoly.h:50
const GrainTrackerInterface & _grain_tracker
Grain tracker object.
Definition: ACSEDGPoly.h:53
const MaterialProperty< Real > & _rho_eff
the average/effective dislocation density
Definition: ACSEDGPoly.h:44
virtual Real computeDFDOP(PFFunctionType type)
Definition: ACSEDGPoly.C:46
const MaterialProperty< Real > & _beta
the prefactor needed to calculate the deformation energy from dislocation density ...
Definition: ACSEDGPoly.h:41
unsigned int _op_index
index of the OP the kernel is currently acting on
Definition: ACSEDGPoly.h:56
This is the Allen-Cahn equation base class that implements the bulk or local energy term of the equat...
Definition: ACBulk.h:22
const MaterialProperty< Real > & _Disloc_Den_i
dislocation density in grain i
Definition: ACSEDGPoly.h:47
std::vector< const VariableValue * > _vals
Definition: ACSEDGPoly.h:37
virtual const std::vector< unsigned int > & getVarToFeatureVector(dof_id_type elem_id) const =0
Returns a list of active unique feature ids for a particular element.
InputParameters validParams< ACSEDGPoly >()
Definition: ACSEDGPoly.C:13
ACSEDGPoly(const InputParameters &parameters)
Definition: ACSEDGPoly.C:25
static InputParameters validParams()
Definition: ACBulk.h:72