LCOV - code coverage report
Current view: top level - src/userobjects - HexagonalSubchannelBin.C (source / functions) Hit Total Coverage
Test: neams-th-coe/cardinal: ddd5f2 Lines: 57 59 96.6 %
Date: 2026-06-07 19:35:24 Functions: 4 4 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /********************************************************************/
       2             : /*                  SOFTWARE COPYRIGHT NOTIFICATION                 */
       3             : /*                             Cardinal                             */
       4             : /*                                                                  */
       5             : /*                  (c) 2021 UChicago Argonne, LLC                  */
       6             : /*                        ALL RIGHTS RESERVED                       */
       7             : /*                                                                  */
       8             : /*                 Prepared by UChicago Argonne, LLC                */
       9             : /*               Under Contract No. DE-AC02-06CH11357               */
      10             : /*                With the U. S. Department of Energy               */
      11             : /*                                                                  */
      12             : /*             Prepared by Battelle Energy Alliance, LLC            */
      13             : /*               Under Contract No. DE-AC07-05ID14517               */
      14             : /*                With the U. S. Department of Energy               */
      15             : /*                                                                  */
      16             : /*                 See LICENSE for full restrictions                */
      17             : /********************************************************************/
      18             : 
      19             : #include "HexagonalSubchannelBin.h"
      20             : 
      21             : registerMooseObject("CardinalApp", HexagonalSubchannelBin);
      22             : 
      23             : InputParameters
      24         143 : HexagonalSubchannelBin::validParams()
      25             : {
      26         143 :   InputParameters params = SpatialBinUserObject::validParams();
      27         286 :   params.addRequiredRangeCheckedParam<Real>(
      28             :       "bundle_pitch", "bundle_pitch > 0", "Bundle pitch, or flat-to-flat distance across bundle");
      29         286 :   params.addRequiredRangeCheckedParam<Real>(
      30             :       "pin_pitch", "pin_pitch > 0", "Pin pitch, or distance between pin centers");
      31         286 :   params.addRequiredRangeCheckedParam<Real>(
      32             :       "pin_diameter", "pin_diameter > 0", "Pin outer diameter");
      33         286 :   params.addRequiredRangeCheckedParam<unsigned int>(
      34             :       "n_rings", "n_rings >= 1", "Number of pin rings, including the centermost pin as a 'ring'");
      35         286 :   params.addParam<bool>(
      36             :       "pin_centered_bins",
      37         286 :       false,
      38             :       "Whether the bins should be channel-centered (false) or pin-centered (true)");
      39             : 
      40         286 :   MooseEnum directions("x y z", "z");
      41         286 :   params.addParam<MooseEnum>(
      42             :       "axis", directions, "vertical axis of the reactor (x, y, or z) along which pins are aligned");
      43         143 :   params.addClassDescription(
      44             :       "Creates a unique spatial bin for each subchannel in a hexagonal lattice");
      45         143 :   return params;
      46         143 : }
      47             : 
      48          71 : HexagonalSubchannelBin::HexagonalSubchannelBin(const InputParameters & parameters)
      49             :   : SpatialBinUserObject(parameters),
      50          71 :     _bundle_pitch(getParam<Real>("bundle_pitch")),
      51         142 :     _pin_pitch(getParam<Real>("pin_pitch")),
      52         142 :     _pin_diameter(getParam<Real>("pin_diameter")),
      53         142 :     _n_rings(getParam<unsigned int>("n_rings")),
      54          71 :     _axis(parameters.get<MooseEnum>("axis")),
      55         213 :     _pin_centered_bins(getParam<bool>("pin_centered_bins"))
      56             : {
      57          71 :   _hex_lattice.reset(new HexagonalLatticeUtils(_bundle_pitch,
      58          71 :                                                _pin_pitch,
      59          71 :                                                _pin_diameter,
      60             :                                                0.0 /* wire diameter, unused */,
      61             :                                                1.0 /* wire pitch, unused */,
      62          71 :                                                _n_rings,
      63          71 :                                                _axis,
      64          71 :                                                0. /*rotation_around_axis*/));
      65             : 
      66          71 :   if (_axis == 0) // x vertical axis
      67           0 :     _directions = {1, 2};
      68          71 :   else if (_axis == 1) // y vertical axis
      69           0 :     _directions = {0, 2};
      70             :   else // z vertical axis
      71          71 :     _directions = {0, 1};
      72             : 
      73          71 :   if (_pin_centered_bins)
      74             :   {
      75             :     // the bin centers are the pin centroids
      76         368 :     for (const auto & p : _hex_lattice->pinCenters())
      77         340 :       _bin_centers.push_back(p);
      78             : 
      79             :     // except for the last bin, which is just the enclosing region; we
      80             :     // just pick one point in this region
      81             :     Real x;
      82          28 :     if (_n_rings % 2 == 0)
      83             :       x = 0.0;
      84             :     else
      85          12 :       x = 0.5 * _hex_lattice->pinPitch();
      86             : 
      87          28 :     Point leftover(x, _bundle_pitch / 2.0 - _hex_lattice->pinBundleSpacing() / 2.0, 0.0);
      88          28 :     _bin_centers.push_back(leftover);
      89             :   }
      90             :   else
      91             :   {
      92             :     // the bin centers are the channel centroids
      93         517 :     for (unsigned int i = 0; i < _hex_lattice->nInteriorChannels(); ++i)
      94             :     {
      95         474 :       auto corners = _hex_lattice->interiorChannelCornerCoordinates(i);
      96         474 :       _bin_centers.push_back(_hex_lattice->channelCentroid(corners));
      97         474 :     }
      98             : 
      99         373 :     for (unsigned int i = 0; i < _hex_lattice->nEdgeChannels(); ++i)
     100             :     {
     101         330 :       auto corners = _hex_lattice->edgeChannelCornerCoordinates(i);
     102         330 :       _bin_centers.push_back(_hex_lattice->channelCentroid(corners));
     103         330 :     }
     104             : 
     105         301 :     for (unsigned int i = 0; i < _hex_lattice->nCornerChannels(); ++i)
     106             :     {
     107         258 :       auto corners = _hex_lattice->cornerChannelCornerCoordinates(i);
     108         258 :       _bin_centers.push_back(_hex_lattice->channelCentroid(corners));
     109         258 :     }
     110             :   }
     111          71 : }
     112             : 
     113             : unsigned int
     114    41901970 : HexagonalSubchannelBin::bin(const Point & p) const
     115             : {
     116    41901970 :   if (_pin_centered_bins)
     117      131680 :     return _hex_lattice->pinIndex(p);
     118             :   else
     119    41770290 :     return _hex_lattice->channelIndex(p);
     120             : }
     121             : 
     122             : unsigned int
     123       58117 : HexagonalSubchannelBin::num_bins() const
     124             : {
     125       58117 :   if (_pin_centered_bins)
     126          76 :     return _hex_lattice->nPins() + 1;
     127             :   else
     128       58041 :     return _hex_lattice->nChannels();
     129             : }

Generated by: LCOV version 1.14