LCOV - code coverage report
Current view: top level - src/components - GateValve1Phase.C (source / functions) Hit Total Coverage
Test: idaholab/moose thermal_hydraulics: #30301 (3b550b) with base 2ad78d Lines: 60 61 98.4 %
Date: 2025-07-30 13:02:48 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 "GateValve1Phase.h"
      11             : #include "FlowChannel1Phase.h"
      12             : #include "FlowModelSinglePhase.h"
      13             : 
      14             : registerMooseObject("ThermalHydraulicsApp", GateValve1Phase);
      15             : 
      16             : InputParameters
      17         168 : GateValve1Phase::validParams()
      18             : {
      19         168 :   InputParameters params = FlowJunction1Phase::validParams();
      20             : 
      21         336 :   params.addRequiredParam<Real>("open_area_fraction", "Fraction of flow area that is open [-]");
      22             : 
      23         336 :   params.declareControllable("open_area_fraction");
      24             : 
      25         168 :   params.addClassDescription("Gate valve component for 1-phase flow");
      26             : 
      27         168 :   return params;
      28           0 : }
      29             : 
      30          84 : GateValve1Phase::GateValve1Phase(const InputParameters & params) : FlowJunction1Phase(params) {}
      31             : 
      32             : void
      33          84 : GateValve1Phase::setupMesh()
      34             : {
      35          84 :   FlowJunction1Phase::setupMesh();
      36             : 
      37             :   const auto & connected_elems = getConnectedElementIDs();
      38          84 :   if (connected_elems.size() == 2)
      39          82 :     getTHMProblem().augmentSparsity(connected_elems[0], connected_elems[1]);
      40          84 : }
      41             : 
      42             : void
      43          84 : GateValve1Phase::check() const
      44             : {
      45          84 :   FlowJunction1Phase::check();
      46             : 
      47             :   // Check that there are exactly 2 connections
      48          84 :   checkNumberOfConnections(2);
      49             : 
      50             :   // Log warning if slope reconstruction is used on one or more of the adjacent flow channels
      51             :   bool slope_reconstruction_used = false;
      52         254 :   for (const auto & connection : getConnections())
      53             :   {
      54         170 :     const std::string & comp_name = connection._component_name;
      55             :     if (hasComponentByName<FlowChannel1Phase>(comp_name))
      56             :     {
      57             :       const FlowChannel1Phase & comp = getComponentByName<FlowChannel1Phase>(comp_name);
      58             :       slope_reconstruction_used =
      59         170 :           slope_reconstruction_used || (comp.getSlopeReconstruction() != "none");
      60             :     }
      61             :   }
      62          84 :   if (slope_reconstruction_used)
      63           4 :     logWarning("Currently GateValve1Phase cannot perform slope reconstruction across the "
      64             :                "junction, so the slopes on the adjacent elements will be zero.");
      65          84 : }
      66             : 
      67             : void
      68          76 : GateValve1Phase::addMooseObjects()
      69             : {
      70          76 :   ExecFlagEnum execute_on(MooseUtils::getDefaultExecFlagEnum());
      71         380 :   execute_on = {EXEC_INITIAL, EXEC_LINEAR, EXEC_NONLINEAR};
      72             : 
      73             :   // Add user object for computing and storing the fluxes
      74             :   {
      75          76 :     const std::string class_name = "ADGateValve1PhaseUserObject";
      76          76 :     InputParameters params = _factory.getValidParams(class_name);
      77          76 :     params.set<std::vector<BoundaryName>>("boundary") = _boundary_names;
      78         152 :     params.set<std::vector<Real>>("normals") = _normals;
      79         152 :     params.set<std::vector<processor_id_type>>("processor_ids") = getConnectedProcessorIDs();
      80             :     // It is assumed that each channel should have the same numerical flux, so
      81             :     // just use the first one.
      82          76 :     params.set<UserObjectName>("numerical_flux") = _numerical_flux_names[0];
      83         152 :     params.set<Real>("open_area_fraction") = getParam<Real>("open_area_fraction");
      84         228 :     params.set<std::vector<VariableName>>("A") = {FlowModel::AREA};
      85         228 :     params.set<std::vector<VariableName>>("rhoA") = {FlowModelSinglePhase::RHOA};
      86         228 :     params.set<std::vector<VariableName>>("rhouA") = {FlowModelSinglePhase::RHOUA};
      87         228 :     params.set<std::vector<VariableName>>("rhoEA") = {FlowModelSinglePhase::RHOEA};
      88          76 :     params.set<std::string>("component_name") = name();
      89          76 :     params.set<ExecFlagEnum>("execute_on") = execute_on;
      90          76 :     getTHMProblem().addUserObject(class_name, _junction_uo_name, params);
      91             : 
      92          76 :     connectObject(params, _junction_uo_name, "open_area_fraction");
      93          76 :   }
      94             : 
      95             :   const std::vector<NonlinearVariableName> var_names = {
      96         304 :       FlowModelSinglePhase::RHOA, FlowModelSinglePhase::RHOUA, FlowModelSinglePhase::RHOEA};
      97             : 
      98             :   // Add BC to each of the connected flow channels
      99         228 :   for (std::size_t i = 0; i < _boundary_names.size(); i++)
     100         608 :     for (std::size_t j = 0; j < var_names.size(); j++)
     101             :     {
     102         456 :       const std::string class_name = "ADGateValve1PhaseBC";
     103         456 :       InputParameters params = _factory.getValidParams(class_name);
     104        1368 :       params.set<std::vector<BoundaryName>>("boundary") = {_boundary_names[i]};
     105         456 :       params.set<Real>("normal") = _normals[i];
     106         912 :       params.set<NonlinearVariableName>("variable") = var_names[j];
     107         912 :       params.set<UserObjectName>("gate_valve_uo") = _junction_uo_name;
     108         456 :       params.set<unsigned int>("connection_index") = i;
     109        1368 :       params.set<std::vector<VariableName>>("A_elem") = {FlowModel::AREA};
     110        1368 :       params.set<std::vector<VariableName>>("A_linear") = {FlowModel::AREA_LINEAR};
     111        1368 :       params.set<std::vector<VariableName>>("rhoA") = {FlowModelSinglePhase::RHOA};
     112        1368 :       params.set<std::vector<VariableName>>("rhouA") = {FlowModelSinglePhase::RHOUA};
     113        1368 :       params.set<std::vector<VariableName>>("rhoEA") = {FlowModelSinglePhase::RHOEA};
     114         456 :       params.set<bool>("implicit") = getTHMProblem().getImplicitTimeIntegrationFlag();
     115         912 :       getTHMProblem().addBoundaryCondition(
     116         456 :           class_name, genName(name(), i, var_names[j] + ":" + class_name), params);
     117         456 :     }
     118         228 : }

Generated by: LCOV version 1.14