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

Generated by: LCOV version 1.14