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 "ShaftTimeDerivativeScalarKernel.h" 11 : #include "ShaftConnectableUserObjectInterface.h" 12 : #include "UserObject.h" 13 : #include "MooseVariableScalar.h" 14 : #include "Assembly.h" 15 : 16 : registerMooseObject("ThermalHydraulicsApp", ShaftTimeDerivativeScalarKernel); 17 : 18 : InputParameters 19 4 : ShaftTimeDerivativeScalarKernel::validParams() 20 : { 21 4 : InputParameters params = ScalarKernel::validParams(); 22 8 : params.addRequiredParam<std::vector<UserObjectName>>("uo_names", 23 : "Names of shaft-connectable user objects"); 24 4 : params.addClassDescription("Adds a time derivative term to the shaft ODE"); 25 8 : params.set<MultiMooseEnum>("vector_tags") = "time"; 26 8 : params.set<MultiMooseEnum>("matrix_tags") = "system time"; 27 : 28 4 : return params; 29 0 : } 30 : 31 2 : ShaftTimeDerivativeScalarKernel::ShaftTimeDerivativeScalarKernel(const InputParameters & parameters) 32 : : ScalarKernel(parameters), 33 4 : _u_dot(_var.uDot()), 34 2 : _du_dot_du(_var.duDotDu()), 35 4 : _uo_names(getParam<std::vector<UserObjectName>>("uo_names")), 36 4 : _n_components(_uo_names.size()) 37 : { 38 2 : _shaft_connected_uos.resize(_n_components); 39 4 : for (unsigned int i = 0; i < _n_components; ++i) 40 : { 41 2 : _shaft_connected_uos[i] = 42 2 : &getUserObjectByName<ShaftConnectableUserObjectInterface>(_uo_names[i]); 43 : } 44 2 : } 45 : 46 : void 47 12 : ShaftTimeDerivativeScalarKernel::reinit() 48 : { 49 12 : } 50 : 51 : void 52 10 : ShaftTimeDerivativeScalarKernel::computeResidual() 53 : { 54 10 : prepareVectorTag(_assembly, _var.number()); 55 : 56 : Real sum_inertias = 0; 57 20 : for (unsigned int i = 0; i < _n_components; ++i) 58 10 : sum_inertias += _shaft_connected_uos[i]->getMomentOfInertia(); 59 : 60 10 : _local_re(0) += sum_inertias * _u_dot[0]; 61 : 62 10 : accumulateTaggedLocalResidual(); 63 10 : } 64 : 65 : void 66 2 : ShaftTimeDerivativeScalarKernel::computeJacobian() 67 : { 68 2 : prepareMatrixTag(_assembly, _var.number(), _var.number()); 69 : 70 : Real sum_inertias = 0; 71 4 : for (unsigned int i = 0; i < _n_components; ++i) 72 2 : sum_inertias += _shaft_connected_uos[i]->getMomentOfInertia(); 73 : 74 : // FIXME: Add dI_domega * domega_dt 75 2 : _local_ke(0, 0) += sum_inertias * _du_dot_du[0]; 76 : 77 2 : accumulateTaggedLocalMatrix(); 78 : 79 4 : for (unsigned int i = 0; i < _n_components; ++i) 80 : { 81 2 : DenseMatrix<Real> jacobian_block; 82 : std::vector<dof_id_type> dofs_j; 83 2 : _shaft_connected_uos[i]->getMomentOfInertiaJacobianData(jacobian_block, dofs_j); 84 2 : jacobian_block.scale(_u_dot[0]); 85 2 : addJacobian(_assembly, jacobian_block, _var.dofIndices(), dofs_j, _var.scalingFactor()); 86 2 : } 87 2 : }