LCOV - code coverage report
Current view: top level - src/components - ShaftConnectedMotor.C (source / functions) Hit Total Coverage
Test: idaholab/moose thermal_hydraulics: #32971 (54bef8) with base c6cf66 Lines: 30 38 78.9 %
Date: 2026-05-29 20:41:18 Functions: 5 5 100.0 %
Legend: Lines: hit not hit

          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 "ShaftConnectedMotor.h"
      11             : #include "Shaft.h"
      12             : 
      13             : registerMooseObject("ThermalHydraulicsApp", ShaftConnectedMotor);
      14             : 
      15             : InputParameters
      16         276 : ShaftConnectedMotor::validParams()
      17             : {
      18         276 :   InputParameters params = Component::validParams();
      19         276 :   params += ShaftConnectable::validParams();
      20         552 :   params.addRequiredParam<FunctionName>("torque", "Driving torque supplied by the motor [kg-m^2]");
      21         552 :   params.addRequiredParam<FunctionName>("inertia", "Moment of inertia from the motor [N-m]");
      22         552 :   params.addParam<bool>("ad", true, "Use AD version or not");
      23         276 :   params.addClassDescription("Motor to drive a shaft component");
      24         276 :   return params;
      25           0 : }
      26             : 
      27         138 : ShaftConnectedMotor::ShaftConnectedMotor(const InputParameters & parameters)
      28             :   : Component(parameters),
      29             :     ShaftConnectable(this),
      30         138 :     _torque_fn_name(getParam<FunctionName>("torque")),
      31         414 :     _inertia_fn_name(getParam<FunctionName>("inertia"))
      32             : {
      33         138 : }
      34             : 
      35             : void
      36         138 : ShaftConnectedMotor::check() const
      37             : {
      38         138 :   checkShaftConnection(this);
      39         138 : }
      40             : 
      41             : void
      42         128 : ShaftConnectedMotor::addVariables()
      43             : {
      44         128 : }
      45             : 
      46             : void
      47         128 : ShaftConnectedMotor::addMooseObjects()
      48             : {
      49         128 :   const Shaft & shaft = getComponentByName<Shaft>(_shaft_name);
      50         128 :   const VariableName shaft_speed_var_name = shaft.getOmegaVariableName();
      51             : 
      52         128 :   const UserObjectName & uo_name = getShaftConnectedUserObjectName();
      53         256 :   if (getParam<bool>("ad"))
      54             :   {
      55         128 :     std::string class_name = "ADShaftConnectedMotorUserObject";
      56         128 :     InputParameters params = _factory.getValidParams(class_name);
      57         128 :     params.set<FunctionName>("torque") = _torque_fn_name;
      58         256 :     params.set<FunctionName>("inertia") = _inertia_fn_name;
      59         384 :     params.set<std::vector<VariableName>>("shaft_speed") = {shaft_speed_var_name};
      60         128 :     getTHMProblem().addUserObject(class_name, uo_name, params);
      61         128 :   }
      62             :   else
      63             :   {
      64           0 :     std::string class_name = "ShaftConnectedMotorUserObject";
      65           0 :     InputParameters params = _factory.getValidParams(class_name);
      66           0 :     params.set<FunctionName>("torque") = _torque_fn_name;
      67           0 :     params.set<FunctionName>("inertia") = _inertia_fn_name;
      68           0 :     params.set<std::vector<VariableName>>("shaft_speed") = {shaft_speed_var_name};
      69           0 :     getTHMProblem().addUserObject(class_name, uo_name, params);
      70           0 :   }
      71         128 : }

Generated by: LCOV version 1.14