www.mooseframework.org
RankTwoScalarAux.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 "RankTwoScalarAux.h"
11 #include "RankTwoScalarTools.h"
12 
13 #include "metaphysicl/raw_type.h"
14 
15 registerMooseObject("SolidMechanicsApp", RankTwoScalarAux);
16 registerMooseObject("SolidMechanicsApp", ADRankTwoScalarAux);
17 
18 template <bool is_ad>
21 {
23  params.addClassDescription("Compute a scalar property of a RankTwoTensor");
24  params.addRequiredParam<MaterialPropertyName>("rank_two_tensor",
25  "The rank two material tensor name");
26  params.addParam<MooseEnum>(
27  "scalar_type", RankTwoScalarTools::scalarOptions(), "Type of scalar output");
28  params.addParam<unsigned int>(
29  "selected_qp",
30  "Evaluate the tensor at this quadpoint. This option only needs to be used if "
31  "you are interested in a particular quadpoint in each element: otherwise do "
32  "not include this parameter in your input file");
33  params.addParamNamesToGroup("selected_qp", "Advanced");
34 
35  params.addParam<Point>(
36  "point1",
37  Point(0, 0, 0),
38  "Start point for axis used to calculate some cylindrical material tensor quantities");
39  params.addParam<Point>("point2",
40  Point(0, 1, 0),
41  "End point for axis used to calculate some material tensor quantities");
42  params.addParam<Point>("direction", Point(0, 0, 1), "Direction vector");
43  return params;
44 }
45 
46 template <bool is_ad>
48  : NodalPatchRecovery(parameters),
49  _tensor(getGenericMaterialProperty<RankTwoTensor, is_ad>("rank_two_tensor")),
50  _scalar_type(getParam<MooseEnum>("scalar_type")),
51  _has_selected_qp(isParamValid("selected_qp")),
52  _selected_qp(_has_selected_qp ? getParam<unsigned int>("selected_qp") : 0),
53  _point1(parameters.get<Point>("point1")),
54  _point2(parameters.get<Point>("point2")),
55  _input_direction(parameters.get<Point>("direction") / parameters.get<Point>("direction").norm())
56 {
57 }
58 
59 template <bool is_ad>
60 Real
62 {
63  unsigned int qp = _qp;
64  if (_has_selected_qp)
65  {
66  if (_selected_qp >= _q_point.size())
67  {
68  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
69  mooseError("RankTwoScalarAux. selected_qp specified as ",
70  _selected_qp,
71  " but there are only ",
72  _q_point.size(),
73  " quadpoints in the element");
74  }
75  qp = _selected_qp;
76  }
77 
79  _scalar_type,
80  _point1,
81  _point2,
82  _q_point[qp],
83  _input_direction);
84 }
85 
86 template class RankTwoScalarAuxTempl<false>;
87 template class RankTwoScalarAuxTempl<true>;
RankTwoScalarAux uses the namespace RankTwoScalarTools to compute scalar values from Rank-2 tensors...
T getQuantity(const RankTwoTensorTempl< T > &tensor, const MooseEnum &scalar_type, const Point &point1, const Point &point2, const Point &curr_point, Point &direction)
static InputParameters validParams()
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void mooseError(Args &&... args)
RankTwoScalarAuxTempl(const InputParameters &parameters)
auto raw_value(const Eigen::Map< T > &in)
MooseEnum scalarOptions()
This enum is left for legacy calls.
void addRequiredParam(const std::string &name, const std::string &doc_string)
auto norm(const T &a) -> decltype(std::abs(a))
registerMooseObject("SolidMechanicsApp", RankTwoScalarAux)
static InputParameters validParams()
virtual Real computeValue()
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void addClassDescription(const std::string &doc_string)
void ErrorVector unsigned int
const Elem & get(const ElemType type_in)
void addParamNamesToGroup(const std::string &space_delim_names, const std::string group_name)