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