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 "MaterialTensorIntegral.h" 11 : #include "RankTwoScalarTools.h" 12 : 13 : #include "metaphysicl/raw_type.h" 14 : 15 : registerMooseObject("SolidMechanicsApp", MaterialTensorIntegral); 16 : registerMooseObject("SolidMechanicsApp", ADMaterialTensorIntegral); 17 : 18 : template <bool is_ad> 19 : InputParameters 20 520 : MaterialTensorIntegralTempl<is_ad>::validParams() 21 : { 22 520 : InputParameters params = ElementIntegralPostprocessor::validParams(); 23 520 : params.addClassDescription("This postprocessor computes an element integral of " 24 : "a component of a material tensor as specified by " 25 : "the user-supplied indices"); 26 1040 : params.addRequiredParam<MaterialPropertyName>("rank_two_tensor", 27 : "The rank two material property tensor name"); 28 1040 : 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 1040 : 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 520 : params.set<bool>("use_displaced_mesh") = true; 37 520 : return params; 38 0 : } 39 : 40 : template <bool is_ad> 41 260 : MaterialTensorIntegralTempl<is_ad>::MaterialTensorIntegralTempl(const InputParameters & parameters) 42 : : ElementIntegralPostprocessor(parameters), 43 260 : _tensor(getGenericMaterialProperty<RankTwoTensor, is_ad>("rank_two_tensor")), 44 520 : _i(getParam<unsigned int>("index_i")), 45 780 : _j(getParam<unsigned int>("index_j")) 46 : { 47 260 : } 48 : 49 : template <bool is_ad> 50 : Real 51 5104 : MaterialTensorIntegralTempl<is_ad>::computeQpIntegral() 52 : { 53 5104 : return RankTwoScalarTools::component(MetaPhysicL::raw_value(_tensor[_qp]), _i, _j); 54 : } 55 : 56 : template class MaterialTensorIntegralTempl<false>; 57 : template class MaterialTensorIntegralTempl<true>;