LCOV - code coverage report
Current view: top level - src/materials - RankTwoSphericalComponent.C (source / functions) Hit Total Coverage
Test: idaholab/moose tensor_mechanics: d6b47a Lines: 26 26 100.0 %
Date: 2024-02-27 11:53:14 Functions: 8 8 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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 "RankTwoSphericalComponent.h"
      11             : #include "RankTwoScalarTools.h"
      12             : 
      13             : #include "metaphysicl/raw_type.h"
      14             : 
      15             : registerMooseObject("TensorMechanicsApp", RankTwoSphericalComponent);
      16             : registerMooseObject("TensorMechanicsApp", ADRankTwoSphericalComponent);
      17             : 
      18             : template <bool is_ad>
      19             : InputParameters
      20         180 : RankTwoSphericalComponentTempl<is_ad>::validParams()
      21             : {
      22         180 :   InputParameters params = Material::validParams();
      23         180 :   params.addClassDescription(
      24             :       "Compute components of a rank-2 tensor in a spherical coordinate system");
      25         360 :   params.addRequiredParam<MaterialPropertyName>("rank_two_tensor",
      26             :                                                 "The rank two material tensor name");
      27         360 :   params.addRequiredParam<MaterialPropertyName>(
      28             :       "property_name", "Name of the material property computed by this model");
      29         360 :   MooseEnum sphericalTypes("HoopStress RadialStress");
      30         360 :   params.addParam<MooseEnum>(
      31             :       "spherical_component", sphericalTypes, "Type of spherical scalar output");
      32         360 :   params.addParam<Point>("spherical_center_point",
      33             :                          "Center point of the spherical coordinate system.");
      34         180 :   return params;
      35         180 : }
      36             : 
      37             : template <bool is_ad>
      38         135 : RankTwoSphericalComponentTempl<is_ad>::RankTwoSphericalComponentTempl(
      39             :     const InputParameters & parameters)
      40             :   : Material(parameters),
      41         135 :     _tensor(getGenericMaterialProperty<RankTwoTensor, is_ad>("rank_two_tensor")),
      42         270 :     _property(declareGenericProperty<Real, is_ad>("property_name")),
      43         270 :     _spherical_component(getParam<MooseEnum>("spherical_component")
      44             :                              .template getEnum<RankTwoScalarTools::SphericalComponent>()),
      45         540 :     _center(isParamValid("spherical_center_point") ? getParam<Point>("spherical_center_point")
      46         135 :                                                    : Point(0, 0, 0))
      47             : {
      48         135 : }
      49             : 
      50             : template <bool is_ad>
      51             : void
      52         348 : RankTwoSphericalComponentTempl<is_ad>::initQpStatefulProperties()
      53             : {
      54         348 :   _property[_qp] = 0.0;
      55         348 : }
      56             : 
      57             : template <bool is_ad>
      58             : void
      59        3426 : RankTwoSphericalComponentTempl<is_ad>::computeQpProperties()
      60             : {
      61             :   Point dummy_direction;
      62             : 
      63        3426 :   _property[_qp] = RankTwoScalarTools::getSphericalComponent(MetaPhysicL::raw_value(_tensor[_qp]),
      64        3426 :                                                              _spherical_component,
      65        3426 :                                                              _center,
      66        3426 :                                                              _q_point[_qp],
      67             :                                                              dummy_direction);
      68        3426 : }
      69             : 
      70             : template class RankTwoSphericalComponentTempl<false>;
      71             : template class RankTwoSphericalComponentTempl<true>;

Generated by: LCOV version 1.14