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 "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> 19 : InputParameters 20 30358 : RankTwoAuxTempl<is_ad>::validParams() 21 : { 22 30358 : InputParameters params = NodalPatchRecovery::validParams(); 23 30358 : params.addClassDescription("Access a component of a RankTwoTensor"); 24 60716 : params.addRequiredParam<MaterialPropertyName>("rank_two_tensor", 25 : "The rank two material tensor name"); 26 60716 : 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 60716 : 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 60716 : params.addParam<unsigned int>("selected_qp", "Evaluate the tensor at this specific quadpoint"); 35 60716 : params.addParamNamesToGroup("selected_qp", "Advanced"); 36 30358 : return params; 37 0 : } 38 : 39 : template <bool is_ad> 40 15080 : RankTwoAuxTempl<is_ad>::RankTwoAuxTempl(const InputParameters & parameters) 41 : : NodalPatchRecovery(parameters), 42 15080 : _tensor(getGenericMaterialProperty<RankTwoTensor, is_ad>("rank_two_tensor")), 43 30160 : _i(getParam<unsigned int>("index_i")), 44 30160 : _j(getParam<unsigned int>("index_j")), 45 30160 : _has_selected_qp(isParamValid("selected_qp")), 46 30292 : _selected_qp(_has_selected_qp ? getParam<unsigned int>("selected_qp") : 0) 47 : { 48 15080 : } 49 : 50 : template <bool is_ad> 51 : Real 52 262719600 : RankTwoAuxTempl<is_ad>::computeValue() 53 : { 54 262719600 : unsigned int qp = _qp; 55 262719600 : if (_has_selected_qp) 56 : { 57 2304 : if (_selected_qp >= _q_point.size()) 58 : { 59 : Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx); 60 0 : mooseError("RankTwoAux. selected_qp specified as ", 61 0 : _selected_qp, 62 : " but there are only ", 63 0 : _q_point.size(), 64 : " quadpoints in the element"); 65 : } 66 : qp = _selected_qp; 67 : } 68 : 69 262719600 : return RankTwoScalarTools::component(MetaPhysicL::raw_value(_tensor[qp]), _i, _j); 70 : } 71 : 72 : template class RankTwoAuxTempl<false>; 73 : template class RankTwoAuxTempl<true>;