LCOV - code coverage report
Current view: top level - src/postprocessors - SCMTHPowerPostprocessor.C (source / functions) Hit Total Coverage
Test: idaholab/moose subchannel: #31730 (e8b711) with base e0c998 Lines: 28 30 93.3 %
Date: 2025-10-29 16:55:46 Functions: 4 4 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 "SCMTHPowerPostprocessor.h"
      11             : #include "FEProblemBase.h"
      12             : #include "SolutionHandle.h"
      13             : #include "MooseMesh.h"
      14             : #include "SCM.h"
      15             : #include "SubChannel1PhaseProblem.h"
      16             : 
      17             : registerMooseObject("SubChannelApp", SCMTHPowerPostprocessor);
      18             : 
      19             : InputParameters
      20         162 : SCMTHPowerPostprocessor::validParams()
      21             : {
      22         162 :   InputParameters params = GeneralPostprocessor::validParams();
      23         162 :   params.addClassDescription(
      24             :       "Calculates the total power of the subchannel assembly $[W]$ via the "
      25             :       "thermal-hydraulic enthalpy flow rate balance between inlet and outlet.");
      26         162 :   return params;
      27           0 : }
      28             : 
      29          81 : SCMTHPowerPostprocessor::SCMTHPowerPostprocessor(const InputParameters & parameters)
      30             :   : GeneralPostprocessor(parameters),
      31          81 :     _mesh(SCM::getConstMesh<SubChannelMesh>(_fe_problem.mesh())),
      32          81 :     _value(0)
      33             : {
      34          81 : }
      35             : 
      36             : void
      37          81 : SCMTHPowerPostprocessor::execute()
      38             : {
      39          81 :   const auto scm_problem = dynamic_cast<SubChannel1PhaseProblem *>(&_fe_problem);
      40          81 :   const auto n_channels = _mesh.getNumOfChannels();
      41          81 :   auto n_cells = _mesh.getNumOfAxialCells();
      42          81 :   auto mdot_soln = SolutionHandle(_fe_problem.getVariable(0, "mdot"));
      43          81 :   auto h_soln = SolutionHandle(_fe_problem.getVariable(0, "h"));
      44             : 
      45          81 :   if (!scm_problem)
      46           0 :     mooseError("SCMTHPowerPostprocessor can only be used within a subchannel 1phase problem.");
      47             : 
      48             :   Real power_in = 0.0;
      49             :   Real power_out = 0.0;
      50             : 
      51        1557 :   for (unsigned int i_ch = 0; i_ch < n_channels; i_ch++)
      52             :   {
      53        1476 :     auto * node_in = _mesh.getChannelNode(i_ch, 0);
      54        1476 :     auto * node_out = _mesh.getChannelNode(i_ch, n_cells);
      55             : 
      56        1476 :     const Real mdot_in = mdot_soln(node_in);
      57        1476 :     const Real h_in = h_soln(node_in);
      58        1476 :     const Real mdot_out = mdot_soln(node_out);
      59        1476 :     const Real h_out = h_soln(node_out);
      60             : 
      61        1476 :     power_in += mdot_in * h_in;
      62        1476 :     power_out += mdot_out * h_out;
      63             :   }
      64             : 
      65          81 :   _value = power_out - power_in;
      66          81 : }
      67             : 
      68             : Real
      69          81 : SCMTHPowerPostprocessor::getValue() const
      70             : {
      71          81 :   return _value;
      72             : }

Generated by: LCOV version 1.14