LCOV - code coverage report
Current view: top level - src/components - JunctionOneToOne1Phase.C (source / functions) Hit Total Coverage
Test: idaholab/moose thermal_hydraulics: #30301 (3b550b) with base 2ad78d Lines: 61 62 98.4 %
Date: 2025-07-30 13:02:48 Functions: 6 6 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 "JunctionOneToOne1Phase.h"
      11             : #include "FlowChannel1Phase.h"
      12             : #include "FlowModelSinglePhase.h"
      13             : #include "THMMesh.h"
      14             : #include "SlopeReconstruction1DInterface.h"
      15             : 
      16             : registerMooseObject("ThermalHydraulicsApp", JunctionOneToOne1Phase);
      17             : 
      18             : InputParameters
      19         722 : JunctionOneToOne1Phase::validParams()
      20             : {
      21         722 :   InputParameters params = FlowJunction1Phase::validParams();
      22             : 
      23         722 :   params.addClassDescription(
      24             :       "Junction connecting one flow channel to one other flow channel for 1-phase flow");
      25             : 
      26         722 :   return params;
      27           0 : }
      28             : 
      29         361 : JunctionOneToOne1Phase::JunctionOneToOne1Phase(const InputParameters & params)
      30             :   : FlowJunction1Phase(params),
      31         722 :     _slope_reconstruction(
      32         361 :         SlopeReconstruction1DInterface<true>::getSlopeReconstructionMooseEnum("None"))
      33             : {
      34         361 : }
      35             : 
      36             : void
      37         361 : JunctionOneToOne1Phase::setupMesh()
      38             : {
      39         361 :   FlowJunction1Phase::setupMesh();
      40             : 
      41             :   const auto & connected_elems = getConnectedElementIDs();
      42         361 :   if (connected_elems.size() == 2)
      43         361 :     getTHMProblem().augmentSparsity(connected_elems[0], connected_elems[1]);
      44         361 : }
      45             : 
      46             : void
      47         361 : JunctionOneToOne1Phase::init()
      48             : {
      49         361 :   FlowJunction1Phase::init();
      50             : 
      51             :   // Get slope reconstruction option used
      52        1083 :   for (const auto & connection : getConnections())
      53             :   {
      54         722 :     const std::string & comp_name = connection._component_name;
      55             :     if (hasComponentByName<FlowChannel1Phase>(comp_name))
      56             :     {
      57             :       const FlowChannel1Phase & comp = getComponentByName<FlowChannel1Phase>(comp_name);
      58         722 :       _slope_reconstruction = comp.getSlopeReconstruction();
      59             :     }
      60             :   }
      61         361 : }
      62             : 
      63             : void
      64         361 : JunctionOneToOne1Phase::check() const
      65             : {
      66         361 :   FlowJunction1Phase::check();
      67             : 
      68             :   // Check that there are exactly 2 connections
      69         361 :   checkNumberOfConnections(2);
      70         361 : }
      71             : 
      72             : void
      73         361 : JunctionOneToOne1Phase::addMooseObjects()
      74             : {
      75         361 :   ExecFlagEnum execute_on(MooseUtils::getDefaultExecFlagEnum());
      76        1805 :   execute_on = {EXEC_INITIAL, EXEC_LINEAR, EXEC_NONLINEAR};
      77             : 
      78             :   // Add user object for computing and storing the fluxes
      79             :   {
      80         361 :     const std::string class_name = "ADJunctionOneToOne1PhaseUserObject";
      81         361 :     InputParameters params = _factory.getValidParams(class_name);
      82         361 :     params.set<std::vector<BoundaryName>>("boundary") = _boundary_names;
      83         722 :     params.set<std::vector<Real>>("normals") = _normals;
      84         361 :     params.set<std::vector<processor_id_type>>("processor_ids") = getConnectedProcessorIDs();
      85         722 :     params.set<UserObjectName>("fluid_properties") = _fp_name;
      86             :     // It is assumed that each channel should have the same numerical flux, so
      87             :     // just use the first one.
      88         722 :     params.set<UserObjectName>("numerical_flux") = _numerical_flux_names[0];
      89        1083 :     params.set<std::vector<VariableName>>("A_elem") = {FlowModel::AREA};
      90        1083 :     params.set<std::vector<VariableName>>("A_linear") = {FlowModel::AREA_LINEAR};
      91        1083 :     params.set<std::vector<VariableName>>("rhoA") = {FlowModelSinglePhase::RHOA};
      92        1083 :     params.set<std::vector<VariableName>>("rhouA") = {FlowModelSinglePhase::RHOUA};
      93        1083 :     params.set<std::vector<VariableName>>("rhoEA") = {FlowModelSinglePhase::RHOEA};
      94         361 :     params.set<std::string>("junction_name") = name();
      95         361 :     params.set<MooseEnum>("scheme") = _slope_reconstruction;
      96         361 :     params.set<ExecFlagEnum>("execute_on") = execute_on;
      97         361 :     getTHMProblem().addUserObject(class_name, _junction_uo_name, params);
      98         361 :   }
      99             : 
     100             :   const std::vector<NonlinearVariableName> var_names = {
     101        1444 :       FlowModelSinglePhase::RHOA, FlowModelSinglePhase::RHOUA, FlowModelSinglePhase::RHOEA};
     102             : 
     103             :   // Add BC to each of the connected flow channels
     104        1083 :   for (std::size_t i = 0; i < _boundary_names.size(); i++)
     105        2888 :     for (std::size_t j = 0; j < var_names.size(); j++)
     106             :     {
     107        2166 :       const std::string class_name = "ADJunctionOneToOne1PhaseBC";
     108        2166 :       InputParameters params = _factory.getValidParams(class_name);
     109        6498 :       params.set<std::vector<BoundaryName>>("boundary") = {_boundary_names[i]};
     110        2166 :       params.set<Real>("normal") = _normals[i];
     111        4332 :       params.set<NonlinearVariableName>("variable") = var_names[j];
     112        4332 :       params.set<UserObjectName>("junction_uo") = _junction_uo_name;
     113        2166 :       params.set<unsigned int>("connection_index") = i;
     114        6498 :       params.set<std::vector<VariableName>>("rhoA") = {FlowModelSinglePhase::RHOA};
     115        6498 :       params.set<std::vector<VariableName>>("rhouA") = {FlowModelSinglePhase::RHOUA};
     116        6498 :       params.set<std::vector<VariableName>>("rhoEA") = {FlowModelSinglePhase::RHOEA};
     117        2166 :       params.set<bool>("implicit") = getTHMProblem().getImplicitTimeIntegrationFlag();
     118        4332 :       getTHMProblem().addBoundaryCondition(
     119        2166 :           class_name, genName(name(), i, var_names[j] + ":" + class_name), params);
     120        2166 :     }
     121        1083 : }

Generated by: LCOV version 1.14