https://mooseframework.inl.gov
SCMTHPowerPostprocessor.C
Go to the documentation of this file.
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 
11 #include "FEProblemBase.h"
12 #include "SolutionHandle.h"
13 #include "MooseMesh.h"
14 #include "SCM.h"
16 
18 
21 {
23  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  return params;
27 }
28 
30  : GeneralPostprocessor(parameters),
31  _mesh(SCM::getConstMesh<SubChannelMesh>(_fe_problem.mesh())),
32  _value(0)
33 {
34 }
35 
36 void
38 {
39  const auto scm_problem = dynamic_cast<SubChannel1PhaseProblem *>(&_fe_problem);
40  const auto n_channels = _mesh.getNumOfChannels();
42  auto mdot_soln = SolutionHandle(_fe_problem.getVariable(0, "mdot"));
43  auto h_soln = SolutionHandle(_fe_problem.getVariable(0, "h"));
44 
45  if (!scm_problem)
46  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  for (unsigned int i_ch = 0; i_ch < n_channels; i_ch++)
52  {
53  auto * node_in = _mesh.getChannelNode(i_ch, 0);
54  auto * node_out = _mesh.getChannelNode(i_ch, n_cells);
55 
56  const Real mdot_in = mdot_soln(node_in);
57  const Real h_in = h_soln(node_in);
58  const Real mdot_out = mdot_soln(node_out);
59  const Real h_out = h_soln(node_out);
60 
61  power_in += mdot_in * h_in;
62  power_out += mdot_out * h_out;
63  }
64 
65  _value = power_out - power_in;
66 }
67 
68 Real
70 {
71  return _value;
72 }
virtual const unsigned int & getNumOfChannels() const =0
Return the number of channels per layer.
Real _value
value we want to calculate
MeshBase & mesh
SCMTHPowerPostprocessor(const InputParameters &params)
Provide a simple RAII interface for linear lagrange solution variables.
static InputParameters validParams()
virtual const MooseVariableFieldBase & getVariable(const THREAD_ID tid, const std::string &var_name, Moose::VarKindType expected_var_type=Moose::VarKindType::VAR_ANY, Moose::VarFieldType expected_var_field_type=Moose::VarFieldType::VAR_FIELD_ANY) const override
virtual Node * getChannelNode(unsigned int i_chan, unsigned iz) const =0
Get the subchannel mesh node for a given channel index and elevation index.
static InputParameters validParams()
virtual Real getValue() const override
const T & getConstMesh(const MooseMesh &mesh)
function to cast const mesh
Definition: SCM.h:21
const SubChannelMesh & _mesh
geometric information
Base class for the 1-phase steady-state/transient subchannel solver.
virtual const unsigned int & getNumOfAxialCells() const
Return the number of axial cells.
registerMooseObject("SubChannelApp", SCMTHPowerPostprocessor)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
FEProblemBase & _fe_problem
Calculates the total power of the subchannel assembly $[W]$ considering the thermal-hydraulic balance...
void mooseError(Args &&... args) const
void addClassDescription(const std::string &doc_string)
Base class for subchannel meshes.
dof_id_type n_cells
virtual void execute() override
Definition: SCM.h:16