LCOV - code coverage report
Current view: top level - src/postprocessors - SubChannelDelta.C (source / functions) Hit Total Coverage
Test: idaholab/moose subchannel: #31405 (292dce) with base fef103 Lines: 25 26 96.2 %
Date: 2025-09-04 07:58:06 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         204 : SubChannelDelta::validParams()
      24             : {
      25         204 :   InputParameters params = GeneralPostprocessor::validParams();
      26         204 :   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         408 :   params.addRequiredParam<AuxVariableName>("variable", "Variable you want the delta of");
      30         204 :   return params;
      31           0 : }
      32             : 
      33         102 : SubChannelDelta::SubChannelDelta(const InputParameters & parameters)
      34             :   : GeneralPostprocessor(parameters),
      35         102 :     _mesh(SCM::getConstMesh<SubChannelMesh>(_fe_problem.mesh())),
      36         204 :     _variable(getParam<AuxVariableName>("variable")),
      37         102 :     _value(0)
      38             : {
      39         102 : }
      40             : 
      41             : void
      42         102 : SubChannelDelta::execute()
      43             : {
      44         102 :   auto nz = _mesh.getNumOfAxialCells();
      45         102 :   auto n_channels = _mesh.getNumOfChannels();
      46         102 :   auto Soln = SolutionHandle(_fe_problem.getVariable(0, _variable));
      47         102 :   auto mdot_soln = SolutionHandle(_fe_problem.getVariable(0, "mdot"));
      48             : 
      49             :   auto mass_flow_in = 0.0;
      50             :   auto sum_Delta_mass_flow_in = 0.0;
      51        4818 :   for (unsigned int i_ch = 0; i_ch < n_channels; i_ch++)
      52             :   {
      53        4716 :     auto * node_in = _mesh.getChannelNode(i_ch, 0);
      54        4716 :     auto * node_out = _mesh.getChannelNode(i_ch, nz);
      55        4716 :     mass_flow_in += mdot_soln(node_in);
      56        4716 :     auto Delta = abs(Soln(node_in) - Soln(node_out));
      57        4716 :     sum_Delta_mass_flow_in += Delta * mdot_soln(node_in);
      58             :   }
      59             : 
      60         102 :   _value = sum_Delta_mass_flow_in / mass_flow_in;
      61         102 : }
      62             : 
      63             : Real
      64         102 : SubChannelDelta::getValue() const
      65             : {
      66         102 :   return _value;
      67             : }

Generated by: LCOV version 1.14