LCOV - code coverage report
Current view: top level - src/outputs - QuadSubChannelNormalSliceValues.C (source / functions) Hit Total Coverage
Test: idaholab/moose subchannel: #31405 (292dce) with base fef103 Lines: 43 44 97.7 %
Date: 2025-09-04 07:58:06 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         348 : QuadSubChannelNormalSliceValues::validParams()
      18             : {
      19         348 :   InputParameters params = FileOutput::validParams();
      20         696 :   params.addRequiredParam<VariableName>("variable", "Variable you want the value of");
      21         696 :   params.addRequiredParam<Real>("height", "Axial location of normal slice [m]");
      22         348 :   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         348 :   params.suppressParameter<bool>("append_date");
      25         348 :   params.suppressParameter<std::string>("append_date_format");
      26         348 :   params.suppressParameter<unsigned int>("padding");
      27         348 :   params.suppressParameter<std::vector<std::string>>("output_if_base_contains");
      28         348 :   return params;
      29           0 : }
      30             : 
      31         174 : QuadSubChannelNormalSliceValues::QuadSubChannelNormalSliceValues(const InputParameters & parameters)
      32             :   : FileOutput(parameters),
      33         174 :     _mesh(dynamic_cast<QuadSubChannelMesh &>(*_mesh_ptr)),
      34         348 :     _variable(getParam<VariableName>("variable")),
      35         522 :     _height(getParam<Real>("height"))
      36             : {
      37         174 :   _exit_value.resize(_mesh.getNy(), _mesh.getNx());
      38         174 : }
      39             : 
      40             : void
      41         120 : QuadSubChannelNormalSliceValues::output()
      42             : {
      43         120 :   auto val_soln = SolutionHandle(_problem_ptr->getVariable(0, _variable));
      44         120 :   auto nz = _mesh.getNumOfAxialCells();
      45         120 :   auto z_grid = _mesh.getZGrid();
      46         120 :   auto n_channels = _mesh.getNumOfChannels();
      47             :   auto total_length =
      48         120 :       _mesh.getHeatedLength() + _mesh.getHeatedLengthEntry() + _mesh.getHeatedLengthExit();
      49             : 
      50         120 :   if (_height >= total_length)
      51             :   {
      52        1182 :     for (unsigned int i_ch = 0; i_ch < n_channels; i_ch++)
      53             :     {
      54        1134 :       auto * node = _mesh.getChannelNode(i_ch, nz);
      55        1134 :       unsigned int i = (i_ch / _mesh.getNx());   // row
      56        1134 :       unsigned int j = i_ch - i * _mesh.getNx(); // column
      57        1134 :       _exit_value(i, j) = val_soln(node);
      58             :     }
      59             :   }
      60             :   else
      61             :   {
      62         552 :     for (unsigned int iz = 0; iz < nz; iz++)
      63             :     {
      64         552 :       if (_height >= z_grid[iz] && _height < z_grid[iz + 1])
      65             :       {
      66        1170 :         for (unsigned int i_ch = 0; i_ch < n_channels; i_ch++)
      67             :         {
      68        1098 :           auto * node_out = _mesh.getChannelNode(i_ch, iz + 1);
      69        1098 :           auto * node_in = _mesh.getChannelNode(i_ch, iz);
      70        1098 :           unsigned int i = (i_ch / _mesh.getNx());   // row
      71        1098 :           unsigned int j = i_ch - i * _mesh.getNx(); // column
      72        1098 :           _exit_value(i, j) = val_soln(node_in) + (val_soln(node_out) - val_soln(node_in)) *
      73        1098 :                                                       (_height - z_grid[iz]) /
      74        1098 :                                                       (z_grid[iz + 1] - z_grid[iz]);
      75             :         }
      76             :         break;
      77             :       }
      78             :     }
      79             :   }
      80             : 
      81         120 :   std::ofstream myfile;
      82         120 :   myfile.open(_file_base, std::ofstream::trunc);
      83         120 :   myfile << std::setprecision(10) << std::fixed << _exit_value << "\n";
      84         120 :   myfile.close();
      85         120 : }

Generated by: LCOV version 1.14