LCOV - code coverage report
Current view: top level - src/components - GateValve1Phase.C (source / functions) Hit Total Coverage
Test: idaholab/moose thermal_hydraulics: #32971 (54bef8) with base c6cf66 Lines: 60 61 98.4 %
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 "GateValve1Phase.h"
      11             : #include "FlowChannel1Phase.h"
      12             : #include "FlowModelSinglePhase.h"
      13             : 
      14             : registerMooseObject("ThermalHydraulicsApp", GateValve1Phase);
      15             : 
      16             : InputParameters
      17          88 : GateValve1Phase::validParams()
      18             : {
      19          88 :   InputParameters params = FlowJunction1Phase::validParams();
      20             : 
      21         176 :   params.addRequiredParam<Real>("open_area_fraction", "Fraction of flow area that is open [-]");
      22             : 
      23         176 :   params.declareControllable("open_area_fraction");
      24             : 
      25          88 :   params.addClassDescription("Gate valve component for 1-phase flow");
      26             : 
      27          88 :   return params;
      28           0 : }
      29             : 
      30          44 : GateValve1Phase::GateValve1Phase(const InputParameters & params) : FlowJunction1Phase(params) {}
      31             : 
      32             : void
      33          44 : GateValve1Phase::setupMesh()
      34             : {
      35          44 :   FlowJunction1Phase::setupMesh();
      36             : 
      37             :   const auto & connected_elems = getConnectedElementIDs();
      38          44 :   if (connected_elems.size() == 2)
      39          42 :     getTHMProblem().augmentSparsity(connected_elems[0], connected_elems[1]);
      40          44 : }
      41             : 
      42             : void
      43          44 : GateValve1Phase::check() const
      44             : {
      45          44 :   FlowJunction1Phase::check();
      46             : 
      47             :   // Check that there are exactly 2 connections
      48          44 :   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         134 :   for (const auto & connection : getConnections())
      53             :   {
      54          90 :     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          90 :           slope_reconstruction_used || (comp.getSlopeReconstruction() != "none");
      60             :     }
      61             :   }
      62          44 :   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          44 : }
      66             : 
      67             : void
      68          36 : GateValve1Phase::addMooseObjects()
      69             : {
      70          36 :   ExecFlagEnum execute_on(MooseUtils::getDefaultExecFlagEnum());
      71         180 :   execute_on = {EXEC_INITIAL, EXEC_LINEAR, EXEC_NONLINEAR};
      72             : 
      73             :   // Add user object for computing and storing the fluxes
      74             :   {
      75          36 :     const std::string class_name = "ADGateValve1PhaseUserObject";
      76          36 :     InputParameters params = _factory.getValidParams(class_name);
      77          36 :     params.set<std::vector<BoundaryName>>("boundary") = _boundary_names;
      78          72 :     params.set<std::vector<Real>>("normals") = _normals;
      79          72 :     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          36 :     params.set<UserObjectName>("numerical_flux") = _numerical_flux_names[0];
      83          72 :     params.set<Real>("open_area_fraction") = getParam<Real>("open_area_fraction");
      84         108 :     params.set<std::vector<VariableName>>("A") = {FlowModel::AREA};
      85         108 :     params.set<std::vector<VariableName>>("rhoA") = {FlowModelSinglePhase::RHOA};
      86         108 :     params.set<std::vector<VariableName>>("rhouA") = {FlowModelSinglePhase::RHOUA};
      87         108 :     params.set<std::vector<VariableName>>("rhoEA") = {FlowModelSinglePhase::RHOEA};
      88          36 :     params.set<std::string>("component_name") = name();
      89          36 :     params.set<ExecFlagEnum>("execute_on") = execute_on;
      90          36 :     getTHMProblem().addUserObject(class_name, _junction_uo_name, params);
      91             : 
      92          36 :     connectObject(params, _junction_uo_name, "open_area_fraction");
      93          36 :   }
      94             : 
      95             :   const std::vector<NonlinearVariableName> var_names = {
      96         144 :       FlowModelSinglePhase::RHOA, FlowModelSinglePhase::RHOUA, FlowModelSinglePhase::RHOEA};
      97             : 
      98             :   // Add BC to each of the connected flow channels
      99         108 :   for (std::size_t i = 0; i < _boundary_names.size(); i++)
     100         288 :     for (std::size_t j = 0; j < var_names.size(); j++)
     101             :     {
     102         216 :       const std::string class_name = "ADGateValve1PhaseBC";
     103         216 :       InputParameters params = _factory.getValidParams(class_name);
     104         648 :       params.set<std::vector<BoundaryName>>("boundary") = {_boundary_names[i]};
     105         216 :       params.set<Real>("normal") = _normals[i];
     106         432 :       params.set<NonlinearVariableName>("variable") = var_names[j];
     107         432 :       params.set<UserObjectName>("gate_valve_uo") = _junction_uo_name;
     108         216 :       params.set<unsigned int>("connection_index") = i;
     109         648 :       params.set<std::vector<VariableName>>("A_elem") = {FlowModel::AREA};
     110         648 :       params.set<std::vector<VariableName>>("A_linear") = {FlowModel::AREA_LINEAR};
     111         648 :       params.set<std::vector<VariableName>>("rhoA") = {FlowModelSinglePhase::RHOA};
     112         648 :       params.set<std::vector<VariableName>>("rhouA") = {FlowModelSinglePhase::RHOUA};
     113         648 :       params.set<std::vector<VariableName>>("rhoEA") = {FlowModelSinglePhase::RHOEA};
     114         216 :       params.set<bool>("implicit") = getTHMProblem().getImplicitTimeIntegrationFlag();
     115         432 :       getTHMProblem().addBoundaryCondition(
     116         216 :           class_name, genName(name(), i, var_names[j] + ":" + class_name), params);
     117         216 :     }
     118         108 : }

Generated by: LCOV version 1.14