LCOV - code coverage report
Current view: top level - src/outputs - QuadSubChannelNormalSliceValues.C (source / functions) Hit Total Coverage
Test: idaholab/moose subchannel: #32971 (54bef8) with base c6cf66 Lines: 45 46 97.8 %
Date: 2026-05-29 20:40:47 Functions: 3 3 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 "QuadSubChannelNormalSliceValues.h"
      11             : #include "SolutionHandle.h"
      12             : #include "FEProblemBase.h"
      13             : 
      14             : registerMooseObject("SubChannelApp", QuadSubChannelNormalSliceValues);
      15             : 
      16             : InputParameters
      17         272 : QuadSubChannelNormalSliceValues::validParams()
      18             : {
      19         272 :   InputParameters params = FileOutput::validParams();
      20         544 :   params.addRequiredParam<VariableName>("variable", "Variable you want the value of");
      21         544 :   params.addRequiredParam<Real>("height", "Axial location of normal slice [m]");
      22         272 :   params.addClassDescription("Prints out a user selected value at a user selected axial height in "
      23             :                              "a matrix format to be used for post-processing");
      24         272 :   params.suppressParameter<bool>("append_date");
      25         272 :   params.suppressParameter<std::string>("append_date_format");
      26         272 :   params.suppressParameter<unsigned int>("padding");
      27         272 :   params.suppressParameter<std::vector<std::string>>("output_if_base_contains");
      28         272 :   return params;
      29           0 : }
      30             : 
      31         136 : QuadSubChannelNormalSliceValues::QuadSubChannelNormalSliceValues(const InputParameters & parameters)
      32             :   : FileOutput(parameters),
      33         136 :     _mesh(dynamic_cast<QuadSubChannelMesh &>(*_mesh_ptr)),
      34         272 :     _variable(getParam<VariableName>("variable")),
      35         408 :     _height(getParam<Real>("height"))
      36             : {
      37         136 :   _exit_value.resize(_mesh.getNy(), _mesh.getNx());
      38         136 : }
      39             : 
      40             : void
      41          97 : QuadSubChannelNormalSliceValues::output()
      42             : {
      43             :   // Accessing new solution handles should be done in parallel
      44          97 :   auto val_soln = SolutionHandle(_problem_ptr->getVariable(0, _variable));
      45          97 :   if (processor_id() > 0)
      46          24 :     return;
      47          73 :   auto nz = _mesh.getNumOfAxialCells();
      48          73 :   auto z_grid = _mesh.getZGrid();
      49          73 :   auto n_channels = _mesh.getNumOfChannels();
      50             :   auto total_length =
      51          73 :       _mesh.getHeatedLength() + _mesh.getHeatedLengthEntry() + _mesh.getHeatedLengthExit();
      52             : 
      53          73 :   if (_height >= total_length)
      54             :   {
      55         768 :     for (unsigned int i_ch = 0; i_ch < n_channels; i_ch++)
      56             :     {
      57         738 :       auto * node = _mesh.getChannelNode(i_ch, nz);
      58         738 :       unsigned int i = (i_ch / _mesh.getNx());   // row
      59         738 :       unsigned int j = i_ch - i * _mesh.getNx(); // column
      60         738 :       _exit_value(i, j) = val_soln(node);
      61             :     }
      62             :   }
      63             :   else
      64             :   {
      65         328 :     for (unsigned int iz = 0; iz < nz; iz++)
      66             :     {
      67         328 :       if (_height >= z_grid[iz] && _height < z_grid[iz + 1])
      68             :       {
      69         730 :         for (unsigned int i_ch = 0; i_ch < n_channels; i_ch++)
      70             :         {
      71         687 :           auto * node_out = _mesh.getChannelNode(i_ch, iz + 1);
      72         687 :           auto * node_in = _mesh.getChannelNode(i_ch, iz);
      73         687 :           unsigned int i = (i_ch / _mesh.getNx());   // row
      74         687 :           unsigned int j = i_ch - i * _mesh.getNx(); // column
      75         687 :           _exit_value(i, j) = val_soln(node_in) + (val_soln(node_out) - val_soln(node_in)) *
      76         687 :                                                       (_height - z_grid[iz]) /
      77         687 :                                                       (z_grid[iz + 1] - z_grid[iz]);
      78             :         }
      79             :         break;
      80             :       }
      81             :     }
      82             :   }
      83             : 
      84          73 :   std::ofstream myfile;
      85          73 :   myfile.open(_file_base, std::ofstream::trunc);
      86          73 :   myfile << std::setprecision(10) << std::fixed << _exit_value << "\n";
      87          73 :   myfile.close();
      88          73 : }

Generated by: LCOV version 1.14