https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ViscoplasticityStressUpdateBase.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
11
12template <bool is_ad>
15{
17 params.addClassDescription("Base class used to calculate viscoplastic responses to be used in "
18 "ComputeMultiplePorousInelasticStress");
19 params.addParam<Real>("max_inelastic_increment",
20 1.0e-4,
21 "The maximum inelastic strain increment allowed in a time step");
22 params.addParam<std::string>(
23 "inelastic_strain_name",
24 "viscoplasticity",
25 "Name of the material property that stores the effective inelastic strain");
26 params.addParam<bool>("verbose", false, "Flag to output verbose information");
27 params.addParam<MaterialPropertyName>(
28 "porosity_name", "porosity", "Name of porosity material property");
29 params.addParam<std::string>("total_strain_base_name", "Base name for the total strain");
30 params.addRangeCheckedParam<Real>(
31 "initial_porosity", 0.0, "initial_porosity>=0.0 & initial_porosity<1.0", "Initial porosity");
32 MooseEnum negative_behavior("ZERO INITIAL_CONDITION EXCEPTION", "INITIAL_CONDITION");
33 params.addParam<MooseEnum>(
34 "negative_behavior", negative_behavior, "Enum how to handle negative porosities");
35
36 params.addParamNamesToGroup("inelastic_strain_name", "Advanced");
37 return params;
38}
39
40template <bool is_ad>
42 const InputParameters & parameters)
43 : StressUpdateBaseTempl<is_ad>(parameters),
44 _total_strain_base_name(this->isParamValid("total_strain_base_name")
45 ? this->template getParam<std::string>("total_strain_base_name") +
46 "_"
47 : ""),
48 _strain_increment(this->template getGenericMaterialProperty<RankTwoTensor, is_ad>(
49 _total_strain_base_name + "strain_increment")),
50 _effective_inelastic_strain(this->template declareGenericProperty<Real, is_ad>(
51 _base_name + "effective_" + this->template getParam<std::string>("inelastic_strain_name"))),
52 _effective_inelastic_strain_old(this->template getMaterialPropertyOld<Real>(
53 _base_name + "effective_" + this->template getParam<std::string>("inelastic_strain_name"))),
54 _inelastic_strain(this->template declareGenericProperty<RankTwoTensor, is_ad>(
55 _base_name + this->template getParam<std::string>("inelastic_strain_name"))),
56 _inelastic_strain_old(this->template getMaterialPropertyOld<RankTwoTensor>(
57 _base_name + this->template getParam<std::string>("inelastic_strain_name"))),
58 _max_inelastic_increment(this->template getParam<Real>("max_inelastic_increment")),
59 _intermediate_porosity(0.0),
60 _porosity_old(this->template getMaterialPropertyOld<Real>("porosity_name")),
61 _verbose(this->template getParam<bool>("verbose")),
62 _initial_porosity(this->template getParam<Real>("initial_porosity")),
63 _negative_behavior(this->template getParam<MooseEnum>("negative_behavior")
64 .template getEnum<NegativeBehavior>())
65{
66}
67
68template <bool is_ad>
69void
71{
72 _effective_inelastic_strain[_qp] = 0.0;
73 _inelastic_strain[_qp].zero();
74}
75
76template <bool is_ad>
77void
79{
80 _effective_inelastic_strain[_qp] = _effective_inelastic_strain_old[_qp];
81 _inelastic_strain[_qp] = _inelastic_strain_old[_qp];
82}
83
84template <bool is_ad>
85Real
87{
88 const Real scalar_inelastic_strain_incr =
89 std::abs(MetaPhysicL::raw_value(_effective_inelastic_strain[_qp]) -
90 _effective_inelastic_strain_old[_qp]);
91
92 if (!scalar_inelastic_strain_incr)
93 return std::numeric_limits<Real>::max();
94
95 return _dt * _max_inelastic_increment / scalar_inelastic_strain_incr;
96}
97
98template <bool is_ad>
99void
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 _intermediate_porosity =
108 (1.0 - _porosity_old[_qp]) * (_strain_increment[_qp] - elastic_strain_increment).trace() +
109 _porosity_old[_qp];
110
111 if (_intermediate_porosity < 0.0)
112 {
113 if (_negative_behavior == NegativeBehavior::ZERO)
114 _intermediate_porosity = 0.0;
115 if (_negative_behavior == NegativeBehavior::INITIAL_CONDITION)
116 _intermediate_porosity = _initial_porosity;
117 if (_negative_behavior == NegativeBehavior::EXCEPTION)
118 mooseException("In ", _name, ": porosity is negative.");
119 }
120
121 using std::isnan;
122 if (isnan(_intermediate_porosity))
123 mooseException("In ", _name, ": porosity is nan. Cutting timestep.");
124}
125
Moose::GenericType< RankTwoTensor, is_ad > GenericRankTwoTensor
void addParamNamesToGroup(const std::string &space_delim_names, const std::string group_name)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
void addRangeCheckedParam(const std::string &name, const T &value, const std::string &parsed_function, const std::string &doc_string)
StressUpdateBase is a material that is not called by MOOSE because of the compute=false flag set in t...
static InputParameters validParams()
void updateIntermediatePorosity(const GenericRankTwoTensor< is_ad > &elastic_strain_increment)
ViscoplasticityStressUpdateBaseTempl(const InputParameters &parameters)
virtual void propagateQpStatefulProperties() override
If updateState is not called during a timestep, this will be.
auto raw_value(const Eigen::Map< T > &in)