LCOV - code coverage report
Current view: top level - include/mesh - QuadSubChannelMesh.h (source / functions) Hit Total Coverage
Test: idaholab/moose subchannel: #33187 (5aa0b2) with base d7c4bd Lines: 25 25 100.0 %
Date: 2026-06-30 12:24:57 Functions: 14 14 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             : #pragma once
      11             : 
      12             : #include "SubChannelMesh.h"
      13             : #include "SubChannelEnums.h"
      14             : 
      15             : #include <map>
      16             : #include <vector>
      17             : #include <memory>  // for unique_ptr
      18             : #include <utility> // for std::pair
      19             : 
      20             : /**
      21             :  * Creates the mesh of subchannels in a quadrilateral lattice.
      22             :  */
      23             : class QuadSubChannelMesh : public SubChannelMesh
      24             : {
      25             : public:
      26             :   QuadSubChannelMesh(const InputParameters & parameters);
      27             :   QuadSubChannelMesh(const QuadSubChannelMesh & other_mesh);
      28             : 
      29             :   std::unique_ptr<MooseMesh> safeClone() const override;
      30             :   void buildMesh() override;
      31             : 
      32             :   /**
      33             :    * Compute undeformed bundle-average inlet hydraulic quantities from generated mesh geometry
      34             :    */
      35             :   void computeAssemblyHydraulicParameters();
      36             : 
      37             :   Real getSubchannelFlowArea(unsigned int i_chan, Real z) const override;
      38             :   Real getSubchannelWettedPerimeter(unsigned int i_chan) const override;
      39             : 
      40   835205456 :   Node * getChannelNode(unsigned int i_chan, unsigned int iz) const override
      41             :   {
      42   835205456 :     return _nodes[i_chan][iz];
      43             :   }
      44             : 
      45     2147920 :   Node * getPinNode(unsigned int i_pin, unsigned int iz) const override
      46             :   {
      47     2147920 :     return _pin_nodes[i_pin][iz];
      48             :   }
      49             : 
      50         475 :   unsigned int getNumOfChannels() const override { return processor_id() == 0 ? _n_channels : 0; }
      51         137 :   unsigned int getNumOfGapsPerLayer() const override { return processor_id() == 0 ? _n_gaps : 0; }
      52         352 :   unsigned int getNumOfPins() const override { return processor_id() == 0 ? _n_pins : 0; }
      53             : 
      54   144908160 :   const std::pair<unsigned int, unsigned int> & getGapChannels(unsigned int i_gap) const override
      55             :   {
      56   144908160 :     return _gap_to_chan_map[i_gap];
      57             :   }
      58        1080 :   const std::pair<unsigned int, unsigned int> & getGapPins(unsigned int i_gap) const override
      59             :   {
      60        1080 :     return _gap_to_pin_map[i_gap];
      61             :   }
      62    43217580 :   const std::vector<unsigned int> & getChannelGaps(unsigned int i_chan) const override
      63             :   {
      64    43217580 :     return _chan_to_gap_map[i_chan];
      65             :   }
      66      126645 :   const std::vector<unsigned int> & getPinChannels(unsigned int i_pin) const override
      67             :   {
      68      126645 :     return _pin_to_chan_map[i_pin];
      69             :   }
      70      328652 :   const std::vector<unsigned int> & getChannelPins(unsigned int i_chan) const override
      71             :   {
      72      328652 :     return _chan_to_pin_map[i_chan];
      73             :   }
      74    10108948 :   const Real & getPitch() const override { return _pitch; }
      75   192748680 :   const Real & getCrossflowSign(unsigned int i_chan, unsigned int i_local) const override
      76             :   {
      77   192748680 :     return _sign_id_crossflow_map[i_chan][i_local];
      78             :   }
      79             : 
      80             :   /// Number of subchannels in the -x direction
      81             :   const unsigned int & getNx() const { return _nx; }
      82             :   /// Number of subchannels in the -y direction
      83             :   const unsigned int & getNy() const { return _ny; }
      84             : 
      85             :   /**
      86             :    * Returns the side gap, not to be confused with the gap between pins, this refers to the gap
      87             :    * next to the duct. Edge Pitch W = (pitch/2 - pin_diameter/2 + gap) [m]
      88             :    */
      89             :   const Real & getSideGap() const { return _side_gap; }
      90             : 
      91             :   unsigned int getSubchannelIndexFromPoint(const Point & p) const override;
      92             :   unsigned int channelIndex(const Point & point) const override;
      93             : 
      94             :   unsigned int getPinIndexFromPoint(const Point & p) const override;
      95             :   unsigned int pinIndex(const Point & p) const override;
      96             : 
      97     7542383 :   EChannelType getSubchannelType(unsigned int index) const override { return _subch_type[index]; }
      98             : 
      99    73389840 :   Real getGapWidth(unsigned int axial_index, unsigned int gap_index) const override
     100             :   {
     101    73389840 :     return _gij_map[axial_index][gap_index];
     102             :   }
     103             : 
     104             :   /**
     105             :    * Set the gap width for a given axial cell and gap index
     106             :    */
     107             :   void setGapWidth(unsigned int axial_index, unsigned int gap_index, Real gap_width)
     108             :   {
     109         360 :     _gij_map[axial_index][gap_index] = gap_width;
     110         360 :   }
     111             : 
     112             : protected:
     113             :   /// number of subchannels in the x direction
     114             :   unsigned int _nx;
     115             :   /// number of subchannels in the y direction
     116             :   unsigned int _ny;
     117             :   /// number of subchannels in total
     118             :   unsigned int _n_channels;
     119             :   /// Number of gaps per layer
     120             :   unsigned int _n_gaps;
     121             :   /// Number of pins
     122             :   unsigned int _n_pins;
     123             : 
     124             :   /**
     125             :    * The side gap, not to be confused with the gap between pins, this refers to the gap
     126             :    * next to the duct or else the distance between the subchannel centroid to the duct wall.
     127             :    * Edge Pitch W = (pitch/2 - pin_diameter/2 + gap) [m]
     128             :    */
     129             :   Real _side_gap;
     130             : 
     131             :   /// vector of subchannel nodes
     132             :   std::vector<std::vector<Node *>> _nodes;
     133             :   /// vector of fuel pin nodes
     134             :   std::vector<std::vector<Node *>> _pin_nodes;
     135             :   /// vector of gap (interface between pairs of neighboring subchannels) nodes
     136             :   std::vector<std::vector<Node *>> _gapnodes;
     137             : 
     138             :   /// map relating gap index to subchannel index
     139             :   std::vector<std::pair<unsigned int, unsigned int>> _gap_to_chan_map;
     140             :   /// map relating gap index to fuel pin index
     141             :   std::vector<std::pair<unsigned int, unsigned int>> _gap_to_pin_map;
     142             :   /// map relating subchannel index to gap index
     143             :   std::vector<std::vector<unsigned int>> _chan_to_gap_map;
     144             :   /// map relating subchannel index to fuel pin index
     145             :   std::vector<std::vector<unsigned int>> _chan_to_pin_map;
     146             :   /// map relating fuel pin index to subchannel index
     147             :   std::vector<std::vector<unsigned int>> _pin_to_chan_map;
     148             : 
     149             :   /// Matrix used to give local sign to crossflow quantities
     150             :   std::vector<std::vector<double>> _sign_id_crossflow_map;
     151             :   /// Vector to store gap size
     152             :   std::vector<std::vector<Real>> _gij_map;
     153             :   /// Subchannel type
     154             :   std::vector<EChannelType> _subch_type;
     155             : 
     156             : public:
     157             :   static InputParameters validParams();
     158             : 
     159             :   /**
     160             :    * Generate pin centers
     161             :    *
     162             :    * @param nx number of channels in x-direction (must be more than 1)
     163             :    * @param ny number of channels in y-direction (must be more than 1)
     164             :    * @param elev elevation in z-direction
     165             :    * @param pin_centers Positions in 3D space of pin centers
     166             :    */
     167             :   static void generatePinCenters(
     168             :       unsigned int nx, unsigned int ny, Real pitch, Real elev, std::vector<Point> & pin_centers);
     169             : 
     170             :   friend class SCMQuadAssemblyMeshGenerator;
     171             : };

Generated by: LCOV version 1.14