Line data Source code
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" 12 : #include "GrainTrackerInterface.h" 13 : 14 : registerMooseObject("PhaseFieldApp", ACSEDGPoly); 15 : 16 : InputParameters 17 184 : ACSEDGPoly::validParams() 18 : { 19 184 : InputParameters params = ACBulk<Real>::validParams(); 20 184 : params.addClassDescription("Stored Energy contribution to grain growth"); 21 368 : params.addRequiredCoupledVar("v", "Array of coupled variable names"); 22 368 : params.addRequiredParam<unsigned int>("deformed_grain_num", 23 : "Number of OP representing deformed grains"); 24 368 : params.addRequiredParam<UserObjectName>("grain_tracker", 25 : "The GrainTracker UserObject to get values from."); 26 368 : params.addRequiredParam<unsigned int>("op_index", "The index for the current order parameter"); 27 184 : return params; 28 0 : } 29 : 30 96 : ACSEDGPoly::ACSEDGPoly(const InputParameters & parameters) 31 : : ACBulk<Real>(parameters), 32 96 : _op_num(coupledComponents("v")), 33 96 : _vals(coupledValues("v")), 34 96 : _vals_var(coupledIndices("v")), 35 192 : _beta(getMaterialProperty<Real>("beta")), 36 192 : _rho_eff(getMaterialProperty<Real>("rho_eff")), 37 192 : _Disloc_Den_i(getMaterialProperty<Real>("Disloc_Den_i")), 38 192 : _deformed_grain_num(getParam<unsigned int>("deformed_grain_num")), 39 96 : _grain_tracker(getUserObject<GrainTrackerInterface>("grain_tracker")), 40 288 : _op_index(getParam<unsigned int>("op_index")) 41 : { 42 96 : } 43 : 44 : Real 45 172032000 : ACSEDGPoly::computeDFDOP(PFFunctionType type) 46 : { 47 : Real SumEtaj = 0.0; 48 1376256000 : for (unsigned int i = 0; i < _op_num; ++i) 49 1204224000 : SumEtaj += (*_vals[i])[_qp] * (*_vals[i])[_qp]; 50 : 51 : // Add the current OP to the sum 52 172032000 : Real SumEtai2 = SumEtaj + _u[_qp] * _u[_qp]; 53 : // Dislocation density in deformed grains 54 172032000 : Real rho_i = _Disloc_Den_i[_qp]; 55 : // undeformed grains are dislocation-free 56 172032000 : const auto & op_to_grain = _grain_tracker.getVarToFeatureVector(_current_elem->id()); 57 172032000 : const auto grn_index = op_to_grain[_op_index]; 58 172032000 : 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 172032000 : 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 172032000 : switch (type) 67 : { 68 166526976 : case Residual: 69 166526976 : return _beta[_qp] * drho_eff_detai; 70 : 71 5505024 : case Jacobian: 72 5505024 : return _beta[_qp] * _phi[_j][_qp] * 73 5505024 : (2.0 * SumEtai2 * ((rho_i - _rho_eff[_qp]) - _u[_qp] * drho_eff_detai) - 74 5505024 : 4.0 * _u[_qp] * _u[_qp] * (rho_i - _rho_eff[_qp])) / 75 5505024 : (SumEtai2 * SumEtai2); 76 : } 77 0 : mooseError("Invalid type passed in"); 78 : }