https://mooseframework.inl.gov
SubChannelDelta.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 
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 
24 {
26  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  params.addRequiredParam<AuxVariableName>("variable", "Variable you want the delta of");
30  return params;
31 }
32 
34  : GeneralPostprocessor(parameters),
35  _mesh(SCM::getConstMesh<SubChannelMesh>(_fe_problem.mesh())),
36  _variable(getParam<AuxVariableName>("variable")),
37  _value(0)
38 {
39 }
40 
41 void
43 {
44  auto nz = _mesh.getNumOfAxialCells();
45  auto n_channels = _mesh.getNumOfChannels();
47  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  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, nz);
55  mass_flow_in += mdot_soln(node_in);
56  auto Delta = abs(Soln(node_in) - Soln(node_out));
57  sum_Delta_mass_flow_in += Delta * mdot_soln(node_in);
58  }
59 
60  _value = sum_Delta_mass_flow_in / mass_flow_in;
61 }
62 
63 Real
65 {
66  return _value;
67 }
MetaPhysicL::DualNumber< V, D, asd > abs(const MetaPhysicL::DualNumber< V, D, asd > &a)
virtual const unsigned int & getNumOfChannels() const =0
Return the number of channels per layer.
virtual void execute() override
SubChannelDelta(const InputParameters &params)
AuxVariableName const & _variable
variable name
const SubChannelMesh & _mesh
geometric information
MeshBase & mesh
Provide a simple RAII interface for linear lagrange solution variables.
void addRequiredParam(const std::string &name, const std::string &doc_string)
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()
Calculates the overall change of a chosen variable between the inlet and outlet of the subchannel ass...
static InputParameters validParams()
const T & getConstMesh(const MooseMesh &mesh)
function to cast const mesh
Definition: SCM.h:21
registerMooseObject("SubChannelApp", SubChannelDelta)
virtual const unsigned int & getNumOfAxialCells() const
Return the number of axial cells.
Real _value
value we want to calculate
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
FEProblemBase & _fe_problem
void addClassDescription(const std::string &doc_string)
Base class for subchannel meshes.
Definition: SCM.h:16
virtual Real getValue() const override