LCOV - code coverage report
Current view: top level - src/mesh - QuadInterWrapperMesh.C (source / functions) Hit Total Coverage
Test: idaholab/moose subchannel: #31405 (292dce) with base fef103 Lines: 25 70 35.7 %
Date: 2025-09-04 07:58:06 Functions: 5 10 50.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 "QuadInterWrapperMesh.h"
      11             : 
      12             : #include <cmath>
      13             : 
      14             : #include "libmesh/edge_edge2.h"
      15             : #include "libmesh/unstructured_mesh.h"
      16             : 
      17             : registerMooseObject("SubChannelApp", QuadInterWrapperMesh);
      18             : 
      19             : InputParameters
      20         102 : QuadInterWrapperMesh::validParams()
      21             : {
      22         102 :   InputParameters params = InterWrapperMesh::validParams();
      23         102 :   params.addClassDescription("Creates an inter-wrappper mesh container for a square "
      24             :                              "lattice subchannel arrangement");
      25         102 :   return params;
      26           0 : }
      27             : 
      28          51 : QuadInterWrapperMesh::QuadInterWrapperMesh(const InputParameters & params)
      29          51 :   : InterWrapperMesh(params), _pin_mesh_exist(false)
      30             : {
      31          51 : }
      32             : 
      33           0 : QuadInterWrapperMesh::QuadInterWrapperMesh(const QuadInterWrapperMesh & other_mesh)
      34             :   : InterWrapperMesh(other_mesh),
      35           0 :     _nx(other_mesh._nx),
      36           0 :     _ny(other_mesh._ny),
      37           0 :     _n_channels(other_mesh._n_channels),
      38           0 :     _n_gaps(other_mesh._n_gaps),
      39           0 :     _n_assemblies(other_mesh._n_assemblies),
      40           0 :     _side_bypass_length(other_mesh._side_bypass_length),
      41           0 :     _nodes(other_mesh._nodes),
      42           0 :     _gapnodes(other_mesh._gapnodes),
      43           0 :     _gap_to_chan_map(other_mesh._gap_to_chan_map),
      44           0 :     _chan_to_gap_map(other_mesh._chan_to_gap_map),
      45           0 :     _chan_to_pin_map(other_mesh._chan_to_pin_map),
      46           0 :     _pin_to_chan_map(other_mesh._pin_to_chan_map),
      47           0 :     _sign_id_crossflow_map(other_mesh._sign_id_crossflow_map),
      48           0 :     _gij_map(other_mesh._gij_map),
      49           0 :     _pin_mesh_exist(other_mesh._pin_mesh_exist)
      50             : {
      51           0 :   if (_nx < 2 && _ny < 2)
      52           0 :     mooseError(name(), ": The number of assemblies cannot be less than 1 in both directions. ");
      53           0 : }
      54             : 
      55             : std::unique_ptr<MooseMesh>
      56           0 : QuadInterWrapperMesh::safeClone() const
      57             : {
      58           0 :   return _app.getFactory().copyConstruct(*this);
      59             : }
      60             : 
      61             : void
      62          51 : QuadInterWrapperMesh::buildMesh()
      63             : {
      64          51 : }
      65             : 
      66             : unsigned int
      67       51840 : QuadInterWrapperMesh::getSubchannelIndexFromPoint(const Point & p) const
      68             : {
      69       51840 :   Real offset_x = (_nx - 1) * _assembly_pitch / 2.0;
      70       51840 :   Real offset_y = (_ny - 1) * _assembly_pitch / 2.0;
      71       51840 :   unsigned int i = (p(0) + offset_x + 0.5 * _assembly_pitch) / _assembly_pitch;
      72       51840 :   unsigned int j = (p(1) + offset_y + 0.5 * _assembly_pitch) / _assembly_pitch;
      73       51840 :   return j * _nx + i;
      74             : }
      75             : 
      76             : unsigned int
      77       38280 : QuadInterWrapperMesh::channelIndex(const Point & pt) const
      78             : {
      79             :   // this is identical to getSubchannelIndexFromPoint, but when it is given a point "outside" the
      80             :   // normal subchannel geometry (i.e. a point that lies in a gap around the lattice) we still report
      81             :   // a valid subchannel index this is needed for transferring the solution onto a visualization mesh
      82             : 
      83       38280 :   Real offset_x = (_nx - 1) * _assembly_pitch / 2.0;
      84       38280 :   Real offset_y = (_ny - 1) * _assembly_pitch / 2.0;
      85       38280 :   int i = (pt(0) + offset_x + 0.5 * _assembly_pitch) / _assembly_pitch;
      86       38280 :   int j = (pt(1) + offset_y + 0.5 * _assembly_pitch) / _assembly_pitch;
      87             : 
      88       38280 :   i = std::max(0, i);
      89       38280 :   i = std::min(i, (int)(_nx - 1));
      90             : 
      91       38280 :   j = std::max(0, j);
      92       38280 :   j = std::min(j, (int)(_ny - 1));
      93             : 
      94       38280 :   return j * _nx + i;
      95             : }
      96             : 
      97             : unsigned int
      98           0 : QuadInterWrapperMesh::getPinIndexFromPoint(const Point & p) const
      99             : {
     100           0 :   Real offset_x = (_nx - 2) * _assembly_pitch / 2.0;
     101           0 :   Real offset_y = (_ny - 2) * _assembly_pitch / 2.0;
     102           0 :   unsigned int i = (p(0) + offset_x + 0.5 * _assembly_pitch) / _assembly_pitch;
     103           0 :   unsigned int j = (p(1) + offset_y + 0.5 * _assembly_pitch) / _assembly_pitch;
     104           0 :   return j * (_nx - 1) + i;
     105             : }
     106             : 
     107             : unsigned int
     108           0 : QuadInterWrapperMesh::pinIndex(const Point & p) const
     109             : {
     110           0 :   Real offset_x = (_nx - 2) * _assembly_pitch / 2.0;
     111           0 :   Real offset_y = (_ny - 2) * _assembly_pitch / 2.0;
     112           0 :   int i = (p(0) + offset_x + 0.5 * _assembly_pitch) / _assembly_pitch;
     113           0 :   int j = (p(1) + offset_y + 0.5 * _assembly_pitch) / _assembly_pitch;
     114             : 
     115           0 :   i = std::max(0, i);
     116           0 :   i = std::min(i, (int)(_nx - 2));
     117             : 
     118           0 :   j = std::max(0, j);
     119           0 :   j = std::min(j, (int)(_ny - 2));
     120             : 
     121           0 :   return j * (_nx - 1) + i;
     122             : }
     123             : 
     124             : void
     125           0 : QuadInterWrapperMesh::generatePinCenters(
     126             :     unsigned int nx, unsigned int ny, Real pitch, Real elev, std::vector<Point> & pin_centers)
     127             : {
     128             :   mooseAssert(nx >= 2, "Number of channels in x-direction must be 2 or more.");
     129             :   mooseAssert(ny >= 2, "Number of channels in y-direction must be 2 or more.");
     130             : 
     131           0 :   Real offset_x = (nx - 2) * pitch / 2.0;
     132           0 :   Real offset_y = (ny - 2) * pitch / 2.0;
     133           0 :   for (unsigned int iy = 0; iy < ny - 1; iy++)
     134           0 :     for (unsigned int ix = 0; ix < nx - 1; ix++)
     135           0 :       pin_centers.push_back(Point(pitch * ix - offset_x, pitch * iy - offset_y, elev));
     136           0 : }

Generated by: LCOV version 1.14