https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
21
24{
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
41void
43{
44 auto nz = _mesh.getNumOfAxialCells();
45 auto n_channels = _mesh.getNumOfChannels();
46 auto Soln = SolutionHandle(_fe_problem.getVariable(/*tid*/ 0, _variable));
47 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 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
63Real
65{
66 return _value;
67}
registerMooseObject("SubChannelApp", SubChannelDelta)
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
static InputParameters validParams()
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
Provide a simple RAII interface for linear lagrange solution variables.
Calculates the overall change of a chosen variable between the inlet and outlet of the subchannel ass...
Real _value
value we want to calculate
SubChannelDelta(const InputParameters &params)
const SubChannelMesh & _mesh
geometric information
AuxVariableName const & _variable
variable name
virtual void execute() override
virtual Real getValue() const override
static InputParameters validParams()
Base class for subchannel meshes.
virtual unsigned int getNumOfChannels() const =0
Return the number of channels per layer.
virtual Node * getChannelNode(unsigned int i_chan, unsigned int iz) const =0
Get the subchannel mesh node for a given channel index and elevation index.
virtual unsigned int getNumOfAxialCells() const
Return the number of axial cells.
FEProblemBase & _fe_problem
MeshBase & mesh
Definition SCM.h:17