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