LCOV - code coverage report
Current view: top level - src/components - Component1DJunction.C (source / functions) Hit Total Coverage
Test: idaholab/moose thermal_hydraulics: #30301 (3b550b) with base 2ad78d Lines: 38 41 92.7 %
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 "Component1DJunction.h"
      11             : #include "Component1D.h"
      12             : #include "THMMesh.h"
      13             : 
      14             : InputParameters
      15        3096 : Component1DJunction::validParams()
      16             : {
      17        3096 :   InputParameters params = Component1DConnection::validParams();
      18        6192 :   params.addPrivateParam<std::string>("component_type", "junction");
      19        6192 :   params.addRequiredParam<std::vector<BoundaryName>>("connections", "Junction connections");
      20        3096 :   return params;
      21           0 : }
      22             : 
      23        1548 : Component1DJunction::Component1DJunction(const InputParameters & params)
      24        1548 :   : Component1DConnection(params)
      25             : {
      26             :   const std::vector<BoundaryName> & connections =
      27        3096 :       getParam<std::vector<BoundaryName>>("connections");
      28        4490 :   for (const auto & connection_string : connections)
      29        2942 :     addConnection(connection_string);
      30        1548 : }
      31             : 
      32             : void
      33        1548 : Component1DJunction::setupMesh()
      34             : {
      35        1548 :   Component1DConnection::setupMesh();
      36             : 
      37        1548 :   const BoundaryID boundary_id = mesh().getNextBoundaryId();
      38             : 
      39        1548 :   auto & boundary_info = mesh().getMesh().get_boundary_info();
      40             : 
      41        4890 :   for (const auto & connection : getConnections())
      42             :   {
      43        3342 :     const std::string & comp_name = connection._component_name;
      44             : 
      45             :     if (hasComponentByName<Component1D>(comp_name))
      46             :     {
      47             :       const Component1D & comp = getComponentByName<Component1D>(comp_name);
      48        6684 :       for (auto && conn : comp.getConnections(connection._end_type))
      49             :         // add connection's side to sideset of all sides connected to this zero-D component
      50        3342 :         boundary_info.add_side(conn._elem, conn._side, boundary_id);
      51             :     }
      52             :   }
      53             : 
      54             :   // name the sideset corresponding to the sides of all connected component ends
      55        1548 :   boundary_info.sideset_name(boundary_id) = name();
      56             : 
      57        1548 :   const std::map<dof_id_type, std::vector<dof_id_type>> & node_to_elem = mesh().nodeToElemMap();
      58        4890 :   for (auto & nid : _nodes)
      59             :   {
      60             :     const auto & it = node_to_elem.find(nid);
      61        3342 :     if (it == node_to_elem.end())
      62           0 :       mooseError(name(), ": failed to find node ", nid, "in the mesh!");
      63             : 
      64             :     const std::vector<dof_id_type> & elems = it->second;
      65        6684 :     for (const auto & e : elems)
      66        3342 :       _connected_elems.push_back(e);
      67             :   }
      68        1548 : }
      69             : 
      70             : void
      71        1539 : Component1DJunction::initSecondary()
      72             : {
      73             :   Component1DConnection::initSecondary();
      74             : 
      75        4854 :   for (auto & eid : _connected_elems)
      76             :   {
      77        3315 :     const Elem * elem = constMesh().queryElemPtr(eid);
      78        3315 :     if (elem != nullptr && elem->processor_id() == processor_id())
      79        2304 :       _proc_ids.push_back(elem->processor_id());
      80             :     else
      81        1011 :       _proc_ids.push_back(0);
      82             :   }
      83        1539 :   comm().sum(_proc_ids);
      84        1539 : }
      85             : 
      86             : void
      87        1509 : Component1DJunction::check() const
      88             : {
      89        1509 :   Component1DConnection::check();
      90             : 
      91        1509 :   if (_connections.size() == 0)
      92           0 :     logError("There must be at least one connection.");
      93        1509 : }

Generated by: LCOV version 1.14