https://mooseframework.inl.gov
RankTwoInvariant.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 
10 #include "RankTwoInvariant.h"
11 #include "RankTwoScalarTools.h"
12 
13 #include "metaphysicl/raw_type.h"
14 
15 registerMooseObject("SolidMechanicsApp", RankTwoInvariant);
16 registerMooseObject("SolidMechanicsApp", ADRankTwoInvariant);
17 
18 template <bool is_ad>
21 {
23  params.addClassDescription("Compute a invariant property of a RankTwoTensor");
24  params.addRequiredParam<MaterialPropertyName>("rank_two_tensor",
25  "The rank two material tensor name");
26  params.addRequiredParam<MaterialPropertyName>(
27  "property_name", "Name of the material property computed by this model");
28  MooseEnum mixedInvariants(
29  "VonMisesStress EffectiveStrain Hydrostatic L2norm VolumetricStrain FirstInvariant "
30  "SecondInvariant ThirdInvariant TriaxialityStress MaxShear StressIntensity MaxPrincipal "
31  "MidPrincipal MinPrincipal");
32 
33  params.addParam<MooseEnum>("invariant", mixedInvariants, "Type of invariant output");
34 
35  return params;
36 }
37 
38 template <bool is_ad>
40  : Material(parameters),
41  _invariant(
42  getParam<MooseEnum>("invariant").template getEnum<RankTwoScalarTools::InvariantType>()),
43  _stateful(_invariant == RankTwoScalarTools::InvariantType::EffectiveStrain),
44  _tensor(getGenericMaterialProperty<RankTwoTensor, is_ad>("rank_two_tensor")),
45  _tensor_old(_stateful ? &getMaterialPropertyOld<RankTwoTensor>("rank_two_tensor") : nullptr),
46  _property(declareGenericProperty<Real, is_ad>("property_name")),
47  _property_old(_stateful ? &getMaterialPropertyOld<Real>("property_name") : nullptr)
48 {
49 }
50 
51 template <bool is_ad>
52 void
54 {
55  _property[_qp] = 0.0;
56 }
57 
58 template <bool is_ad>
59 void
61 {
62  switch (_invariant)
63  {
67  {
68  Point dummy_direction;
70  MetaPhysicL::raw_value(_tensor[_qp]), _invariant, dummy_direction);
71  break;
72  }
73 
84  {
85  _property[_qp] =
87  break;
88  }
89 
91  {
92  mooseAssert(_tensor_old, "The selected invariant requires the input material to be stateful");
93  mooseAssert(_property_old,
94  "The selected invariant requires the output material to be stateful");
95  _property[_qp] = (*_property_old)[_qp] + RankTwoScalarTools::effectiveStrain(
96  MetaPhysicL::raw_value(_tensor[_qp]) -
97  MetaPhysicL::raw_value((*_tensor_old)[_qp]));
98  break;
99  }
100 
101  default:
102  mooseError("Not a recognized invariant for RankTwoInvariant");
103  }
104 }
105 
106 template class RankTwoInvariantTempl<false>;
107 template class RankTwoInvariantTempl<true>;
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void mooseError(Args &&... args)
auto raw_value(const Eigen::Map< T > &in)
registerMooseObject("SolidMechanicsApp", RankTwoInvariant)
static InputParameters validParams()
T effectiveStrain(const RankTwoTensorTempl< T > &strain)
void addRequiredParam(const std::string &name, const std::string &doc_string)
virtual void initQpStatefulProperties() override
T getInvariant(const RankTwoTensorTempl< T > &tensor, const InvariantType &scalar_type)
static InputParameters validParams()
RankTwoInvariantTempl(const InputParameters &parameters)
T getPrincipalComponent(const RankTwoTensorTempl< T > &tensor, const InvariantType &scalar_type, Point &direction)
RankTwoInvariant computes invariant scalar values from Rank-2 tensors.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual void computeQpProperties() override
void addClassDescription(const std::string &doc_string)