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
13#include "metaphysicl/raw_type.h"
14
17
18template <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
38template <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
51template <bool is_ad>
52void
57
58template <bool is_ad>
59void
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
106template class RankTwoInvariantTempl<false>;
107template class RankTwoInvariantTempl<true>;
void mooseError(Args &&... args)
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)
auto raw_value(const Eigen::Map< T > &in)
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, Point &direction)