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 "StrainEnergyRateDensity.h" 11 : #include "RankTwoTensor.h" 12 : #include "MooseMesh.h" 13 : 14 : registerMooseObject("SolidMechanicsApp", StrainEnergyRateDensity); 15 : registerMooseObject("SolidMechanicsApp", ADStrainEnergyRateDensity); 16 : 17 : template <bool is_ad> 18 : InputParameters 19 242 : StrainEnergyRateDensityTempl<is_ad>::validParams() 20 : { 21 242 : InputParameters params = Material::validParams(); 22 242 : params.addClassDescription("Computes the strain energy density rate using a combination of the " 23 : "elastic and inelastic components of the strain increment, which is a " 24 : "valid assumption for monotonic behavior."); 25 484 : params.addParam<std::string>("base_name", 26 : "Optional parameter that allows the user to define " 27 : "multiple mechanics material systems on the same " 28 : "block, i.e. for multiple phases"); 29 484 : params.addRequiredRangeCheckedParam<std::vector<MaterialName>>( 30 : "inelastic_models", 31 : "inelastic_models_size=1", 32 : "The material objects to use to calculate the strain energy rate density."); 33 242 : return params; 34 0 : } 35 : 36 : template <bool is_ad> 37 180 : StrainEnergyRateDensityTempl<is_ad>::StrainEnergyRateDensityTempl( 38 : const InputParameters & parameters) 39 : : DerivativeMaterialInterface<Material>(parameters), 40 180 : _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""), 41 180 : _strain_energy_rate_density(declareProperty<Real>(_base_name + "strain_energy_rate_density")), 42 180 : _stress(getGenericMaterialProperty<RankTwoTensor, is_ad>(_base_name + "stress")), 43 180 : _strain_rate(getGenericMaterialProperty<RankTwoTensor, is_ad>(_base_name + "strain_rate")), 44 540 : _num_models(getParam<std::vector<MaterialName>>("inelastic_models").size()) 45 : { 46 180 : } 47 : 48 : template <bool is_ad> 49 : void 50 180 : StrainEnergyRateDensityTempl<is_ad>::initialSetup() 51 : { 52 360 : std::vector<MaterialName> models = getParam<std::vector<MaterialName>>("inelastic_models"); 53 : 54 : // Store inelastic models as generic StressUpdateBase. 55 360 : for (unsigned int i = 0; i < _num_models; ++i) 56 : { 57 180 : GenericStressUpdateBase<is_ad> * inelastic_model_stress_update = 58 180 : dynamic_cast<GenericStressUpdateBase<is_ad> *>(&getMaterialByName(models[i])); 59 : 60 180 : if (inelastic_model_stress_update) 61 180 : _inelastic_models.push_back(inelastic_model_stress_update); 62 : } 63 180 : } 64 : 65 : template <bool is_ad> 66 : void 67 0 : StrainEnergyRateDensityTempl<is_ad>::initQpStatefulProperties() 68 : { 69 0 : _strain_energy_rate_density[_qp] = 0.0; 70 0 : } 71 : 72 : template <bool is_ad> 73 : void 74 518840 : StrainEnergyRateDensityTempl<is_ad>::computeQpProperties() 75 : { 76 1037680 : for (unsigned int i = 0; i < _inelastic_models.size(); ++i) 77 : { 78 518840 : _inelastic_models[i]->setQp(_qp); 79 518840 : _strain_energy_rate_density[_qp] = MetaPhysicL::raw_value( 80 518840 : _inelastic_models[i]->computeStrainEnergyRateDensity(_stress, _strain_rate)); 81 : } 82 518840 : }