https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
15
16template <bool is_ad>
19{
21 params.addClassDescription("Compute a invariant property of a RankTwoTensor");
22 params.addRequiredParam<MaterialPropertyName>("rank_two_tensor",
23 "The rank two material tensor name");
24 params.addRequiredParam<MaterialPropertyName>(
25 "property_name", "Name of the material property computed by this model");
26 MooseEnum mixedInvariants(
27 "VonMisesStress EffectiveStrain Hydrostatic L2norm VolumetricStrain FirstInvariant "
28 "SecondInvariant ThirdInvariant TriaxialityStress MaxShear StressIntensity MaxPrincipal "
29 "MidPrincipal MinPrincipal");
30
31 params.addParam<MooseEnum>("invariant", mixedInvariants, "Type of invariant output");
32
33 return params;
34}
35
36template <bool is_ad>
38 : Material(parameters),
39 _invariant(
40 getParam<MooseEnum>("invariant").template getEnum<RankTwoScalarTools::InvariantType>()),
41 _stateful(_invariant == RankTwoScalarTools::InvariantType::EffectiveStrain),
42 _tensor(getGenericMaterialProperty<RankTwoTensor, is_ad>("rank_two_tensor")),
43 _tensor_old(_stateful ? &getMaterialPropertyOld<RankTwoTensor>("rank_two_tensor") : nullptr),
44 _property(declareGenericProperty<Real, is_ad>("property_name")),
45 _property_old(_stateful ? &getMaterialPropertyOld<Real>("property_name") : nullptr)
46{
47}
48
49template <bool is_ad>
50void
55
56template <bool is_ad>
57void
59{
60 switch (_invariant)
61 {
65 {
66 GenericRealVectorValue<is_ad> dummy_direction;
67 _property[_qp] =
68 RankTwoScalarTools::getPrincipalComponent(_tensor[_qp], _invariant, dummy_direction);
69 break;
70 }
71
82 {
83 _property[_qp] = RankTwoScalarTools::getInvariant(_tensor[_qp], _invariant);
84 break;
85 }
86
88 {
89 mooseAssert(_tensor_old, "The selected invariant requires the input material to be stateful");
90 mooseAssert(_property_old,
91 "The selected invariant requires the output material to be stateful");
92 _property[_qp] = (*_property_old)[_qp] +
93 RankTwoScalarTools::effectiveStrain(_tensor[_qp] - (*_tensor_old)[_qp]);
94 break;
95 }
96
97 default:
98 mooseError("Not a recognized invariant for RankTwoInvariant");
99 }
100}
101
102template class RankTwoInvariantTempl<false>;
103template class RankTwoInvariantTempl<true>;
void mooseError(Args &&... args)
Moose::GenericType< RealVectorValue, is_ad > GenericRealVectorValue
registerMooseObject("SolidMechanicsApp", RankTwoInvariant)
void addRequiredParam(const std::string &name, 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()
RankTwoInvariant computes invariant scalar values from Rank-2 tensors.
virtual void initQpStatefulProperties() override
static InputParameters validParams()
virtual void computeQpProperties() override
RankTwoInvariantTempl(const InputParameters &parameters)
T effectiveStrain(const RankTwoTensorTempl< T > &strain)
T getInvariant(const RankTwoTensorTempl< T > &tensor, const InvariantType &scalar_type)
T getPrincipalComponent(const RankTwoTensorTempl< T > &tensor, const InvariantType &scalar_type, libMesh::TypeVector< T > &direction)