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 "RankTwoAux.h" 11 : #include "RankTwoScalarTools.h" 12 : 13 : #include "metaphysicl/raw_type.h" 14 : 15 : registerMooseObject("TensorMechanicsApp", RankTwoAux); 16 : registerMooseObject("TensorMechanicsApp", ADRankTwoAux); 17 : 18 : template <bool is_ad> 19 : InputParameters 20 14849 : RankTwoAuxTempl<is_ad>::validParams() 21 : { 22 14849 : InputParameters params = NodalPatchRecovery::validParams(); 23 14849 : params.addClassDescription("Access a component of a RankTwoTensor"); 24 29698 : params.addRequiredParam<MaterialPropertyName>("rank_two_tensor", 25 : "The rank two material tensor name"); 26 29698 : 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 29698 : 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 29698 : params.addParam<unsigned int>("selected_qp", "Evaluate the tensor at this specific quadpoint"); 35 29698 : params.addParamNamesToGroup("selected_qp", "Advanced"); 36 14849 : return params; 37 0 : } 38 : 39 : template <bool is_ad> 40 7375 : RankTwoAuxTempl<is_ad>::RankTwoAuxTempl(const InputParameters & parameters) 41 : : NodalPatchRecovery(parameters), 42 7375 : _tensor(getGenericMaterialProperty<RankTwoTensor, is_ad>("rank_two_tensor")), 43 14750 : _i(getParam<unsigned int>("index_i")), 44 14750 : _j(getParam<unsigned int>("index_j")), 45 14750 : _has_selected_qp(isParamValid("selected_qp")), 46 14816 : _selected_qp(_has_selected_qp ? getParam<unsigned int>("selected_qp") : 0) 47 : { 48 7375 : } 49 : 50 : template <bool is_ad> 51 : Real 52 134587340 : RankTwoAuxTempl<is_ad>::computeValue() 53 : { 54 134587340 : unsigned int qp = _qp; 55 134587340 : if (_has_selected_qp) 56 : { 57 1568 : 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 134587340 : return RankTwoScalarTools::component(MetaPhysicL::raw_value(_tensor[qp]), _i, _j); 70 : } 71 : 72 : template class RankTwoAuxTempl<false>; 73 : template class RankTwoAuxTempl<true>;