https://mooseframework.inl.gov
EigenDecompositionMaterial.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 
15 
16 template <bool is_ad>
19 {
21  params.addClassDescription("Emits material properties for the eigenvalues and eigenvectors of a "
22  "symmetric rank two tensor.");
23  params.addRequiredParam<MaterialPropertyName>(
24  "rank_two_tensor",
25  "The name of the symmetric rank two tensor to used in eigen decomposition.");
26  params.addParam<std::string>(
27  "base_name",
28  "Optional parameter to allow multiple tensors to be decomposed on the same block.");
29  return params;
30 }
31 
32 template <bool is_ad>
34  const InputParameters & parameters)
35  : Material(parameters),
36  _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""),
37  _tensor(getGenericMaterialProperty<RankTwoTensor, is_ad>("rank_two_tensor")),
38  _max_eigen_vector(
39  declareGenericProperty<RealVectorValue, is_ad>(_base_name + "max_eigen_vector")),
40  _mid_eigen_vector(
41  declareGenericProperty<RealVectorValue, is_ad>(_base_name + "mid_eigen_vector")),
42  _min_eigen_vector(
43  declareGenericProperty<RealVectorValue, is_ad>(_base_name + "min_eigen_vector")),
44  _max_eigen_value(declareGenericProperty<Real, is_ad>(_base_name + "max_eigen_value")),
45  _mid_eigen_value(declareGenericProperty<Real, is_ad>(_base_name + "mid_eigen_value")),
46  _min_eigen_value(declareGenericProperty<Real, is_ad>(_base_name + "min_eigen_value"))
47 {
48  if (LIBMESH_DIM != 3)
49  mooseError("EigenDecompositionMaterial is only defined for LIBMESH_DIM=3");
50 }
51 
52 template <bool is_ad>
53 void
55 {
56 
57  if (!_tensor[_qp].isSymmetric())
58  mooseError("EigenDecompositionMaterial will only operate on symmetric rank two tensors.");
59 
60  std::vector<GenericReal<is_ad>> eigval(3, 0.0);
62 
63  _tensor[_qp].symmetricEigenvaluesEigenvectors(eigval, eigvec);
64 
65  _max_eigen_vector[_qp] = eigvec.column(2);
66  _mid_eigen_vector[_qp] = eigvec.column(1);
67  _min_eigen_vector[_qp] = eigvec.column(0);
68 
69  _max_eigen_value[_qp] = eigval[2];
70  _mid_eigen_value[_qp] = eigval[1];
71  _min_eigen_value[_qp] = eigval[0];
72 }
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void mooseError(Args &&... args)
void addRequiredParam(const std::string &name, const std::string &doc_string)
registerMooseObject("SolidMechanicsApp", EigenDecompositionMaterial)
static InputParameters validParams()
Perform eigendecomposition on a RankTwoTensor material property.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
EigenDecompositionMaterialTempl(const InputParameters &parameters)
void mooseError(Args &&... args) const
void addClassDescription(const std::string &doc_string)
Moose::GenericType< RankTwoTensor, is_ad > GenericRankTwoTensor