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 "RankTwoCartesianComponent.h" 11 : #include "RankTwoScalarTools.h" 12 : 13 : #include "metaphysicl/raw_type.h" 14 : 15 : registerMooseObject("SolidMechanicsApp", RankTwoCartesianComponent); 16 : registerMooseObject("SolidMechanicsApp", ADRankTwoCartesianComponent); 17 : 18 : template <bool is_ad> 19 : InputParameters 20 60104 : RankTwoCartesianComponentTempl<is_ad>::validParams() 21 : { 22 60104 : InputParameters params = Material::validParams(); 23 60104 : params.addClassDescription("Access a component of a RankTwoTensor"); 24 120208 : params.addRequiredParam<MaterialPropertyName>("rank_two_tensor", 25 : "The rank two material property tensor name"); 26 120208 : params.addRequiredParam<MaterialPropertyName>( 27 : "property_name", "Name of the material property computed by this model"); 28 120208 : params.addRequiredRangeCheckedParam<unsigned int>( 29 : "index_i", 30 : "index_i >= 0 & index_i <= 2", 31 : "The index i of ij for the tensor to output (0, 1, 2)"); 32 120208 : params.addRequiredRangeCheckedParam<unsigned int>( 33 : "index_j", 34 : "index_j >= 0 & index_j <= 2", 35 : "The index j of ij for the tensor to output (0, 1, 2)"); 36 60104 : return params; 37 0 : } 38 : 39 : template <bool is_ad> 40 45078 : RankTwoCartesianComponentTempl<is_ad>::RankTwoCartesianComponentTempl( 41 : const InputParameters & parameters) 42 : : Material(parameters), 43 45078 : _tensor(getGenericMaterialProperty<RankTwoTensor, is_ad>("rank_two_tensor")), 44 90156 : _property(declareGenericProperty<Real, is_ad>("property_name")), 45 90156 : _i(getParam<unsigned int>("index_i")), 46 135234 : _j(getParam<unsigned int>("index_j")) 47 : { 48 45078 : } 49 : 50 : template <bool is_ad> 51 : void 52 256 : RankTwoCartesianComponentTempl<is_ad>::initQpStatefulProperties() 53 : { 54 256 : _property[_qp] = 0.0; 55 256 : } 56 : 57 : template <bool is_ad> 58 : void 59 221716292 : RankTwoCartesianComponentTempl<is_ad>::computeQpProperties() 60 : { 61 221716292 : _property[_qp] = RankTwoScalarTools::component(MetaPhysicL::raw_value(_tensor[_qp]), _i, _j); 62 221716292 : } 63 : 64 : template class RankTwoCartesianComponentTempl<false>; 65 : template class RankTwoCartesianComponentTempl<true>;