https://mooseframework.inl.gov
Loading...
Searching...
No Matches
StrainEnergyRateDensity.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#include "RankTwoTensor.h"
12#include "MooseMesh.h"
13
16
17template <bool is_ad>
20{
22 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 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 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 return params;
34}
35
36template <bool is_ad>
38 const InputParameters & parameters)
40 _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""),
41 _strain_energy_rate_density(declareProperty<Real>(_base_name + "strain_energy_rate_density")),
42 _stress(getGenericMaterialProperty<RankTwoTensor, is_ad>(_base_name + "stress")),
43 _strain_rate(getGenericMaterialProperty<RankTwoTensor, is_ad>(_base_name + "strain_rate")),
44 _num_models(getParam<std::vector<MaterialName>>("inelastic_models").size())
45{
46}
47
48template <bool is_ad>
49void
51{
52 std::vector<MaterialName> models = getParam<std::vector<MaterialName>>("inelastic_models");
53
54 // Store inelastic models as generic StressUpdateBase.
55 for (unsigned int i = 0; i < _num_models; ++i)
56 {
57 GenericStressUpdateBase<is_ad> * inelastic_model_stress_update =
58 dynamic_cast<GenericStressUpdateBase<is_ad> *>(&getMaterialByName(models[i]));
59
60 if (inelastic_model_stress_update)
61 _inelastic_models.push_back(inelastic_model_stress_update);
62 }
63}
64
65template <bool is_ad>
66void
68{
69 _strain_energy_rate_density[_qp] = 0.0;
70}
71
72template <bool is_ad>
73void
75{
76 for (unsigned int i = 0; i < _inelastic_models.size(); ++i)
77 {
78 _inelastic_models[i]->setQp(_qp);
79 _strain_energy_rate_density[_qp] = MetaPhysicL::raw_value(
80 _inelastic_models[i]->computeStrainEnergyRateDensity(_stress, _strain_rate));
81 }
82}
registerMooseObject("SolidMechanicsApp", StrainEnergyRateDensity)
typename std::conditional< is_ad, ADStressUpdateBase, StressUpdateBase >::type GenericStressUpdateBase
void addRequiredRangeCheckedParam(const std::string &name, const std::string &parsed_function, const std::string &doc_string)
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)
static InputParameters validParams()
StrainEnergyRateDensity calculates the strain energy rate density.
virtual void initQpStatefulProperties() override
virtual void computeQpProperties() override
StrainEnergyRateDensityTempl(const InputParameters &parameters)
static InputParameters validParams()
virtual void initialSetup() override
auto raw_value(const Eigen::Map< T > &in)