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 "ShaftComponentTorqueScalarKernel.h" 11 : #include "MooseVariableScalar.h" 12 : #include "Assembly.h" 13 : #include "UserObject.h" 14 : #include "ShaftConnectableUserObjectInterface.h" 15 : 16 : registerMooseObject("ThermalHydraulicsApp", ShaftComponentTorqueScalarKernel); 17 : 18 : InputParameters 19 4 : ShaftComponentTorqueScalarKernel::validParams() 20 : { 21 4 : InputParameters params = ScalarKernel::validParams(); 22 8 : params.addRequiredParam<UserObjectName>("shaft_connected_component_uo", 23 : "Shaft connected component user object name"); 24 4 : params.addClassDescription("Torque contributed by a component connected to a shaft"); 25 4 : return params; 26 0 : } 27 : 28 2 : ShaftComponentTorqueScalarKernel::ShaftComponentTorqueScalarKernel( 29 2 : const InputParameters & parameters) 30 : : ScalarKernel(parameters), 31 2 : _shaft_connected_component_uo( 32 2 : getUserObject<ShaftConnectableUserObjectInterface>("shaft_connected_component_uo")) 33 : { 34 2 : } 35 : 36 : void 37 12 : ShaftComponentTorqueScalarKernel::reinit() 38 : { 39 12 : } 40 : 41 : void 42 10 : ShaftComponentTorqueScalarKernel::computeResidual() 43 : { 44 10 : prepareVectorTag(_assembly, _var.number()); 45 : 46 10 : _local_re(0) -= _shaft_connected_component_uo.getTorque(); 47 : 48 10 : accumulateTaggedLocalResidual(); 49 10 : } 50 : 51 : void 52 2 : ShaftComponentTorqueScalarKernel::computeJacobian() 53 : { 54 2 : DenseMatrix<Real> jacobian_block; 55 : std::vector<dof_id_type> dofs_j; 56 2 : _shaft_connected_component_uo.getTorqueJacobianData(jacobian_block, dofs_j); 57 : jacobian_block.scale(-1); 58 2 : addJacobian(_assembly, jacobian_block, _var.dofIndices(), dofs_j, _var.scalingFactor()); 59 2 : }