www.mooseframework.org
RankTwoAux.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 "RankTwoAux.h"
11 #include "RankTwoScalarTools.h"
12 
13 #include "metaphysicl/raw_type.h"
14 
15 registerMooseObject("SolidMechanicsApp", RankTwoAux);
16 registerMooseObject("SolidMechanicsApp", ADRankTwoAux);
17 
18 template <bool is_ad>
21 {
23  params.addClassDescription("Access a component of a RankTwoTensor");
24  params.addRequiredParam<MaterialPropertyName>("rank_two_tensor",
25  "The rank two material tensor name");
26  params.addRequiredRangeCheckedParam<unsigned int>(
27  "index_i",
28  "index_i >= 0 & index_i <= 2",
29  "The index i of ij for the tensor to output (0, 1, 2)");
30  params.addRequiredRangeCheckedParam<unsigned int>(
31  "index_j",
32  "index_j >= 0 & index_j <= 2",
33  "The index j of ij for the tensor to output (0, 1, 2)");
34  params.addParam<unsigned int>("selected_qp", "Evaluate the tensor at this specific quadpoint");
35  params.addParamNamesToGroup("selected_qp", "Advanced");
36  return params;
37 }
38 
39 template <bool is_ad>
41  : NodalPatchRecovery(parameters),
42  _tensor(getGenericMaterialProperty<RankTwoTensor, is_ad>("rank_two_tensor")),
43  _i(getParam<unsigned int>("index_i")),
44  _j(getParam<unsigned int>("index_j")),
45  _has_selected_qp(isParamValid("selected_qp")),
46  _selected_qp(_has_selected_qp ? getParam<unsigned int>("selected_qp") : 0)
47 {
48 }
49 
50 template <bool is_ad>
51 Real
53 {
54  unsigned int qp = _qp;
55  if (_has_selected_qp)
56  {
57  if (_selected_qp >= _q_point.size())
58  {
59  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
60  mooseError("RankTwoAux. selected_qp specified as ",
61  _selected_qp,
62  " but there are only ",
63  _q_point.size(),
64  " quadpoints in the element");
65  }
66  qp = _selected_qp;
67  }
68 
69  return RankTwoScalarTools::component(MetaPhysicL::raw_value(_tensor[qp]), _i, _j);
70 }
71 
72 template class RankTwoAuxTempl<false>;
73 template class RankTwoAuxTempl<true>;
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 mooseError(Args &&... args)
virtual Real computeValue()
Definition: RankTwoAux.C:52
registerMooseObject("SolidMechanicsApp", RankTwoAux)
auto raw_value(const Eigen::Map< T > &in)
void addRequiredParam(const std::string &name, const std::string &doc_string)
RankTwoAuxTempl(const InputParameters &parameters)
Definition: RankTwoAux.C:40
static InputParameters validParams()
Definition: RankTwoAux.C:20
static InputParameters validParams()
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void addClassDescription(const std::string &doc_string)
T component(const RankTwoTensorTempl< T > &r2tensor, unsigned int i, unsigned int j)
void ErrorVector unsigned int
RankTwoAux is designed to take the data in the RankTwoTensor material property, for example stress or...
Definition: RankTwoAux.h:22
void addParamNamesToGroup(const std::string &space_delim_names, const std::string group_name)