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 "RankTwoScalarAux.h" 11 : #include "RankTwoScalarTools.h" 12 : 13 : #include "metaphysicl/raw_type.h" 14 : 15 : registerMooseObject("TensorMechanicsApp", RankTwoScalarAux); 16 : registerMooseObject("TensorMechanicsApp", ADRankTwoScalarAux); 17 : 18 : template <bool is_ad> 19 : InputParameters 20 968 : RankTwoScalarAuxTempl<is_ad>::validParams() 21 : { 22 968 : InputParameters params = NodalPatchRecovery::validParams(); 23 968 : params.addClassDescription("Compute a scalar property of a RankTwoTensor"); 24 1936 : params.addRequiredParam<MaterialPropertyName>("rank_two_tensor", 25 : "The rank two material tensor name"); 26 1936 : params.addParam<MooseEnum>( 27 : "scalar_type", RankTwoScalarTools::scalarOptions(), "Type of scalar output"); 28 1936 : 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 1936 : params.addParamNamesToGroup("selected_qp", "Advanced"); 34 : 35 968 : params.addParam<Point>( 36 : "point1", 37 968 : Point(0, 0, 0), 38 : "Start point for axis used to calculate some cylindrical material tensor quantities"); 39 968 : params.addParam<Point>("point2", 40 968 : Point(0, 1, 0), 41 : "End point for axis used to calculate some material tensor quantities"); 42 1936 : params.addParam<Point>("direction", Point(0, 0, 1), "Direction vector"); 43 968 : return params; 44 0 : } 45 : 46 : template <bool is_ad> 47 483 : RankTwoScalarAuxTempl<is_ad>::RankTwoScalarAuxTempl(const InputParameters & parameters) 48 : : NodalPatchRecovery(parameters), 49 483 : _tensor(getGenericMaterialProperty<RankTwoTensor, is_ad>("rank_two_tensor")), 50 966 : _scalar_type(getParam<MooseEnum>("scalar_type")), 51 966 : _has_selected_qp(isParamValid("selected_qp")), 52 501 : _selected_qp(_has_selected_qp ? getParam<unsigned int>("selected_qp") : 0), 53 483 : _point1(parameters.get<Point>("point1")), 54 483 : _point2(parameters.get<Point>("point2")), 55 966 : _input_direction(parameters.get<Point>("direction") / parameters.get<Point>("direction").norm()) 56 : { 57 483 : } 58 : 59 : template <bool is_ad> 60 : Real 61 7121849 : RankTwoScalarAuxTempl<is_ad>::computeValue() 62 : { 63 7121849 : unsigned int qp = _qp; 64 7121849 : if (_has_selected_qp) 65 : { 66 144 : 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 7121849 : return RankTwoScalarTools::getQuantity(MetaPhysicL::raw_value(_tensor[qp]), 79 7121849 : _scalar_type, 80 7121849 : _point1, 81 7121849 : _point2, 82 7121849 : _q_point[qp], 83 14243698 : _input_direction); 84 : } 85 : 86 : template class RankTwoScalarAuxTempl<false>; 87 : template class RankTwoScalarAuxTempl<true>;