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 "ViscoplasticityStressUpdateBase.h" 11 : 12 : template <bool is_ad> 13 : InputParameters 14 1016 : ViscoplasticityStressUpdateBaseTempl<is_ad>::validParams() 15 : { 16 1016 : InputParameters params = StressUpdateBaseTempl<is_ad>::validParams(); 17 1016 : params.addClassDescription("Base class used to calculate viscoplastic responses to be used in " 18 : "ComputeMultiplePorousInelasticStress"); 19 2032 : params.addParam<Real>("max_inelastic_increment", 20 2032 : 1.0e-4, 21 : "The maximum inelastic strain increment allowed in a time step"); 22 2032 : params.addParam<std::string>( 23 : "inelastic_strain_name", 24 : "viscoplasticity", 25 : "Name of the material property that stores the effective inelastic strain"); 26 2032 : params.addParam<bool>("verbose", false, "Flag to output verbose information"); 27 2032 : params.addParam<MaterialPropertyName>( 28 : "porosity_name", "porosity", "Name of porosity material property"); 29 2032 : params.addParam<std::string>("total_strain_base_name", "Base name for the total strain"); 30 3048 : params.addRangeCheckedParam<Real>( 31 2032 : "initial_porosity", 0.0, "initial_porosity>=0.0 & initial_porosity<1.0", "Initial porosity"); 32 2032 : MooseEnum negative_behavior("ZERO INITIAL_CONDITION EXCEPTION", "INITIAL_CONDITION"); 33 2032 : params.addParam<MooseEnum>( 34 : "negative_behavior", negative_behavior, "Enum how to handle negative porosities"); 35 : 36 2032 : params.addParamNamesToGroup("inelastic_strain_name", "Advanced"); 37 1016 : return params; 38 1016 : } 39 : 40 : template <bool is_ad> 41 762 : ViscoplasticityStressUpdateBaseTempl<is_ad>::ViscoplasticityStressUpdateBaseTempl( 42 : const InputParameters & parameters) 43 : : StressUpdateBaseTempl<is_ad>(parameters), 44 834 : _total_strain_base_name(this->isParamValid("total_strain_base_name") 45 762 : ? this->template getParam<std::string>("total_strain_base_name") + 46 : "_" 47 : : ""), 48 762 : _strain_increment(this->template getGenericMaterialProperty<RankTwoTensor, is_ad>( 49 762 : _total_strain_base_name + "strain_increment")), 50 3048 : _effective_inelastic_strain(this->template declareGenericProperty<Real, is_ad>( 51 762 : _base_name + "effective_" + this->template getParam<std::string>("inelastic_strain_name"))), 52 3048 : _effective_inelastic_strain_old(this->template getMaterialPropertyOld<Real>( 53 : _base_name + "effective_" + this->template getParam<std::string>("inelastic_strain_name"))), 54 2286 : _inelastic_strain(this->template declareGenericProperty<RankTwoTensor, is_ad>( 55 : _base_name + this->template getParam<std::string>("inelastic_strain_name"))), 56 2286 : _inelastic_strain_old(this->template getMaterialPropertyOld<RankTwoTensor>( 57 : _base_name + this->template getParam<std::string>("inelastic_strain_name"))), 58 1524 : _max_inelastic_increment(this->template getParam<Real>("max_inelastic_increment")), 59 762 : _intermediate_porosity(0.0), 60 1524 : _porosity_old(this->template getMaterialPropertyOld<Real>("porosity_name")), 61 1524 : _verbose(this->template getParam<bool>("verbose")), 62 1524 : _initial_porosity(this->template getParam<Real>("initial_porosity")), 63 1524 : _negative_behavior(this->template getParam<MooseEnum>("negative_behavior") 64 762 : .template getEnum<NegativeBehavior>()) 65 : { 66 762 : } 67 : 68 : template <bool is_ad> 69 : void 70 5392 : ViscoplasticityStressUpdateBaseTempl<is_ad>::initQpStatefulProperties() 71 : { 72 5392 : _effective_inelastic_strain[_qp] = 0.0; 73 5392 : _inelastic_strain[_qp].zero(); 74 5392 : } 75 : 76 : template <bool is_ad> 77 : void 78 0 : ViscoplasticityStressUpdateBaseTempl<is_ad>::propagateQpStatefulProperties() 79 : { 80 0 : _effective_inelastic_strain[_qp] = _effective_inelastic_strain_old[_qp]; 81 0 : _inelastic_strain[_qp] = _inelastic_strain_old[_qp]; 82 0 : } 83 : 84 : template <bool is_ad> 85 : Real 86 413792 : ViscoplasticityStressUpdateBaseTempl<is_ad>::computeTimeStepLimit() 87 : { 88 : const Real scalar_inelastic_strain_incr = 89 413792 : std::abs(MetaPhysicL::raw_value(_effective_inelastic_strain[_qp]) - 90 413792 : _effective_inelastic_strain_old[_qp]); 91 : 92 413792 : if (!scalar_inelastic_strain_incr) 93 : return std::numeric_limits<Real>::max(); 94 : 95 36352 : return _dt * _max_inelastic_increment / scalar_inelastic_strain_incr; 96 : } 97 : 98 : template <bool is_ad> 99 : void 100 446434 : ViscoplasticityStressUpdateBaseTempl<is_ad>::updateIntermediatePorosity( 101 : const GenericRankTwoTensor<is_ad> & elastic_strain_increment) 102 : { 103 : // Subtract elastic strain from strain increment to find all inelastic strain increments 104 : // calculated so far except the one that we're about to calculate. Then calculate intermediate 105 : // porosity from all inelastic strain increments calculated so far except the one that we're about 106 : // to calculate 107 892868 : _intermediate_porosity = 108 1339302 : (1.0 - _porosity_old[_qp]) * (_strain_increment[_qp] - elastic_strain_increment).trace() + 109 446434 : _porosity_old[_qp]; 110 : 111 446434 : if (_intermediate_porosity < 0.0) 112 : { 113 3106 : if (_negative_behavior == NegativeBehavior::ZERO) 114 1552 : _intermediate_porosity = 0.0; 115 3106 : if (_negative_behavior == NegativeBehavior::INITIAL_CONDITION) 116 1552 : _intermediate_porosity = _initial_porosity; 117 3106 : if (_negative_behavior == NegativeBehavior::EXCEPTION) 118 2 : mooseException("In ", _name, ": porosity is negative."); 119 : } 120 : 121 446432 : if (std::isnan(_intermediate_porosity)) 122 0 : mooseException("In ", _name, ": porosity is nan. Cutting timestep."); 123 446432 : } 124 : 125 : template class ViscoplasticityStressUpdateBaseTempl<false>; 126 : template class ViscoplasticityStressUpdateBaseTempl<true>;