LCOV - code coverage report
Current view: top level - src/postprocessors - SubChannelDelta.C (source / functions) Hit Total Coverage
Test: idaholab/moose subchannel: #31730 (e8b711) with base e0c998 Lines: 25 26 96.2 %
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 "SubChannelDelta.h"
      11             : #include "SolutionHandle.h"
      12             : #include "FEProblemBase.h"
      13             : #include "Function.h"
      14             : #include "MooseMesh.h"
      15             : #include "MooseVariable.h"
      16             : #include "SubProblem.h"
      17             : #include "libmesh/system.h"
      18             : #include "SCM.h"
      19             : 
      20             : registerMooseObject("SubChannelApp", SubChannelDelta);
      21             : 
      22             : InputParameters
      23         360 : SubChannelDelta::validParams()
      24             : {
      25         360 :   InputParameters params = GeneralPostprocessor::validParams();
      26         360 :   params.addClassDescription(
      27             :       "Calculates an absolute overall inlet-mass-flow-rate weighted difference, of a chosen "
      28             :       "variable, for the whole subchannel assembly, from inlet to outlet");
      29         720 :   params.addRequiredParam<AuxVariableName>("variable", "Variable you want the delta of");
      30         360 :   return params;
      31           0 : }
      32             : 
      33         180 : SubChannelDelta::SubChannelDelta(const InputParameters & parameters)
      34             :   : GeneralPostprocessor(parameters),
      35         180 :     _mesh(SCM::getConstMesh<SubChannelMesh>(_fe_problem.mesh())),
      36         360 :     _variable(getParam<AuxVariableName>("variable")),
      37         180 :     _value(0)
      38             : {
      39         180 : }
      40             : 
      41             : void
      42         180 : SubChannelDelta::execute()
      43             : {
      44         180 :   auto nz = _mesh.getNumOfAxialCells();
      45         180 :   auto n_channels = _mesh.getNumOfChannels();
      46         180 :   auto Soln = SolutionHandle(_fe_problem.getVariable(/*tid*/ 0, _variable));
      47         180 :   auto mdot_soln = SolutionHandle(_fe_problem.getVariable(/*tid*/ 0, "mdot"));
      48             : 
      49             :   auto mass_flow_in = 0.0;
      50             :   auto sum_Delta_mass_flow_in = 0.0;
      51        4968 :   for (unsigned int i_ch = 0; i_ch < n_channels; i_ch++)
      52             :   {
      53        4788 :     auto * node_in = _mesh.getChannelNode(i_ch, 0);
      54        4788 :     auto * node_out = _mesh.getChannelNode(i_ch, nz);
      55        4788 :     mass_flow_in += mdot_soln(node_in);
      56        4788 :     auto Delta = abs(Soln(node_in) - Soln(node_out));
      57        4788 :     sum_Delta_mass_flow_in += Delta * mdot_soln(node_in);
      58             :   }
      59             : 
      60         180 :   _value = sum_Delta_mass_flow_in / mass_flow_in;
      61         180 : }
      62             : 
      63             : Real
      64         180 : SubChannelDelta::getValue() const
      65             : {
      66         180 :   return _value;
      67             : }

Generated by: LCOV version 1.14