LCOV - code coverage report
Current view: top level - src/auxscalarkernels - RankTwoScalarAux.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: f45d79 Lines: 32 36 88.9 %
Date: 2025-07-25 05:00:39 Functions: 6 6 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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 "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>
      19             : InputParameters
      20        1948 : RankTwoScalarAuxTempl<is_ad>::validParams()
      21             : {
      22        1948 :   InputParameters params = NodalPatchRecovery::validParams();
      23        1948 :   params.addClassDescription("Compute a scalar property of a RankTwoTensor");
      24        3896 :   params.addRequiredParam<MaterialPropertyName>("rank_two_tensor",
      25             :                                                 "The rank two material tensor name");
      26        3896 :   params.addParam<MooseEnum>(
      27             :       "scalar_type", RankTwoScalarTools::scalarOptions(), "Type of scalar output");
      28        3896 :   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        3896 :   params.addParamNamesToGroup("selected_qp", "Advanced");
      34             : 
      35        1948 :   params.addParam<Point>(
      36             :       "point1",
      37        1948 :       Point(0, 0, 0),
      38             :       "Start point for axis used to calculate some cylindrical material tensor quantities");
      39        1948 :   params.addParam<Point>("point2",
      40        1948 :                          Point(0, 1, 0),
      41             :                          "End point for axis used to calculate some material tensor quantities");
      42        3896 :   params.addParam<Point>("direction", Point(0, 0, 1), "Direction vector");
      43        1948 :   return params;
      44           0 : }
      45             : 
      46             : template <bool is_ad>
      47         972 : RankTwoScalarAuxTempl<is_ad>::RankTwoScalarAuxTempl(const InputParameters & parameters)
      48             :   : NodalPatchRecovery(parameters),
      49         972 :     _tensor(getGenericMaterialProperty<RankTwoTensor, is_ad>("rank_two_tensor")),
      50        1944 :     _scalar_type(getParam<MooseEnum>("scalar_type")),
      51        1944 :     _has_selected_qp(isParamValid("selected_qp")),
      52        1008 :     _selected_qp(_has_selected_qp ? getParam<unsigned int>("selected_qp") : 0),
      53         972 :     _point1(parameters.get<Point>("point1")),
      54         972 :     _point2(parameters.get<Point>("point2")),
      55        1944 :     _input_direction(parameters.get<Point>("direction") / parameters.get<Point>("direction").norm())
      56             : {
      57         972 : }
      58             : 
      59             : template <bool is_ad>
      60             : Real
      61    13589230 : RankTwoScalarAuxTempl<is_ad>::computeValue()
      62             : {
      63    13589230 :   unsigned int qp = _qp;
      64    13589230 :   if (_has_selected_qp)
      65             :   {
      66         192 :     if (_selected_qp >= _q_point.size())
      67             :     {
      68             :       Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
      69           0 :       mooseError("RankTwoScalarAux.  selected_qp specified as ",
      70           0 :                  _selected_qp,
      71             :                  " but there are only ",
      72           0 :                  _q_point.size(),
      73             :                  " quadpoints in the element");
      74             :     }
      75             :     qp = _selected_qp;
      76             :   }
      77             : 
      78    13589230 :   return RankTwoScalarTools::getQuantity(MetaPhysicL::raw_value(_tensor[qp]),
      79    13589230 :                                          _scalar_type,
      80    13589230 :                                          _point1,
      81    13589230 :                                          _point2,
      82    13589230 :                                          _q_point[qp],
      83    27178460 :                                          _input_direction);
      84             : }
      85             : 
      86             : template class RankTwoScalarAuxTempl<false>;
      87             : template class RankTwoScalarAuxTempl<true>;

Generated by: LCOV version 1.14