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 "SidesetMoment.h" 11 : #include "metaphysicl/raw_type.h" 12 : 13 : registerMooseObject("MastodonApp", SidesetMoment); 14 : registerMooseObject("MastodonApp", ADSidesetMoment); 15 : 16 : template <bool is_ad> 17 : InputParameters 18 30 : SidesetMomentTempl<is_ad>::validParams() 19 : { 20 30 : InputParameters params = SideIntegralPostprocessor::validParams(); 21 30 : params.addClassDescription("Computes the product of integrated reaction force and lever arm in a " 22 : "user-specified direction " 23 : "on a sideset from the surface traction"); 24 60 : params.addParam<MaterialPropertyName>("stress_tensor", "The rank two stress tensor name"); 25 60 : params.addParam<RealVectorValue>("stress_direction", "Stress direction"); 26 60 : params.addCoupledVar("pressure", "The scalar pressure"); 27 60 : params.addRequiredParam<RealVectorValue>( 28 : "reference_point", "Reference point on the sideset about which the moment is computed"); 29 60 : params.addRequiredParam<RealVectorValue>("moment_direction", "Moment direction"); 30 30 : params.set<bool>("use_displaced_mesh") = true; 31 30 : return params; 32 0 : } 33 : 34 : template <bool is_ad> 35 15 : SidesetMomentTempl<is_ad>::SidesetMomentTempl(const InputParameters & parameters) 36 : : SideIntegralPostprocessor(parameters), 37 45 : _tensor(isParamValid("stress_tensor") 38 21 : ? &getGenericMaterialProperty<RankTwoTensor, is_ad>("stress_tensor") 39 : : nullptr), 40 15 : _stress_direction(isParamValid("stress_direction") 41 21 : ? &getParam<RealVectorValue>("stress_direction") 42 : : nullptr), 43 27 : _pressure(isCoupled("pressure") ? &coupledValue("pressure") : nullptr), 44 30 : _reference_point(getParam<RealVectorValue>("reference_point")), 45 45 : _moment_direction(&getParam<RealVectorValue>("moment_direction")) 46 : { 47 15 : if (_tensor && _pressure) 48 0 : mooseError( 49 : "In block ", 50 : name(), 51 : ", both the stress tensor and the pressure should not be provided at the same time."); 52 15 : if (_tensor && !_stress_direction) 53 0 : mooseError("In block ", 54 : name(), 55 : ", a direction vector should be provided along with the stress tensor."); 56 15 : if (!_tensor && !_pressure) 57 0 : mooseError( 58 : "In block ", name(), ", either the stress tensor or the pressure should be provided."); 59 15 : } 60 : 61 : template <bool is_ad> 62 : Real 63 112 : SidesetMomentTempl<is_ad>::computeQpIntegral() 64 : { 65 112 : if (_tensor) 66 72 : _force_vector = 67 72 : (_normals[_qp] * (MetaPhysicL::raw_value((*_tensor)[_qp]) * (*_stress_direction))) * 68 72 : _normals[_qp]; 69 : else 70 40 : _force_vector = ((*_pressure)[_qp]) * _normals[_qp]; 71 : 72 112 : _moment_vector(0) = (_force_vector(1) * (_q_point[_qp] - _reference_point)(2) - 73 112 : _force_vector(2) * (_q_point[_qp] - _reference_point)(1)); 74 112 : _moment_vector(1) = (_force_vector(2) * (_q_point[_qp] - _reference_point)(0) - 75 112 : _force_vector(0) * (_q_point[_qp] - _reference_point)(2)); 76 112 : _moment_vector(2) = (_force_vector(0) * (_q_point[_qp] - _reference_point)(1) - 77 112 : _force_vector(1) * (_q_point[_qp] - _reference_point)(0)); 78 : 79 112 : return _moment_vector * (*_moment_direction); 80 : } 81 : 82 : template class SidesetMomentTempl<false>; 83 : template class SidesetMomentTempl<true>;