https://mooseframework.inl.gov
Loading...
Searching...
No Matches
SCMPlanarMean.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 "SCMPlanarMean.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{
26 params.addClassDescription("Calculates an mass-flow-rate averaged mean of the chosen "
27 "variable on a z-plane at a user defined height over all subchannels");
28 params.addRequiredParam<AuxVariableName>("variable", "Variable you want the mean of");
29 params.addRequiredParam<Real>("height", "Axial location of plane [m]");
30 return params;
31}
32
34 : GeneralPostprocessor(parameters),
35 _mesh(SCM::getConstMesh<SubChannelMesh>(_fe_problem.mesh())),
36 _variable(getParam<AuxVariableName>("variable")),
37 _height(getParam<Real>("height")),
38 _mean_value(0)
39{
40 if (MooseUtils::absoluteFuzzyLessThan(_height, _mesh.getZGrid().front()))
42 "height", _height, " is below the inlet of the mesh at ", _mesh.getZGrid().front(), ".");
44}
45
46void
48{
49 // Creating a solution handle is collective, so it must happen on every processor
50 const auto Soln = SolutionHandle(_fe_problem.getVariable(0, _variable));
51 const auto mdot_soln = SolutionHandle(_fe_problem.getVariable(0, "mdot"));
52 // The subchannel solution is only available on processor 0
53 if (processor_id() != 0)
54 return;
55
56 Real mass_flow = 0.0;
57 Real sum_sol_mass_flow = 0.0;
58 for (const auto i_ch : make_range(_mesh.getNumOfChannels()))
59 {
60 const auto * node_in = _mesh.getChannelNode(i_ch, _iz);
61 const auto * node_out = _mesh.getChannelNode(i_ch, _iz + 1);
62 const auto solution = Soln.interpolate(node_in, node_out, _weight);
63 const auto mdot = mdot_soln.interpolate(node_in, node_out, _weight);
64 mass_flow += mdot;
65 sum_sol_mass_flow += solution * mdot;
66 }
67 _mean_value = sum_sol_mass_flow / mass_flow;
68}
69
70void
72{
73 // The subchannel solution is only available on processor 0
75}
76
77Real
79{
80 return _mean_value;
81}
registerMooseObject("SubChannelApp", SCMPlanarMean)
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)
void paramError(const std::string &param, Args... args) const
Calculates a mass flow averaged mean of a subchannel variable on a plane.
Real _weight
linear interpolation weight of the height within the axial cell
const Real & _height
axial location [m]
const SubChannelMesh & _mesh
geometric information
virtual void execute() override
AuxVariableName const & _variable
name of variable
SCMPlanarMean(const InputParameters &params)
Real _mean_value
average value we want to calculate
virtual Real getValue() const override
unsigned int _iz
axial cell containing the height
virtual void finalize() override
static InputParameters validParams()
Provide a simple RAII interface for linear lagrange solution variables.
Base class for subchannel meshes.
virtual unsigned int getNumOfChannels() const =0
Return the number of channels per layer.
virtual const std::vector< Real > & getZGrid() const
Get axial location of layers.
std::pair< unsigned int, Real > getAxialInterpolation(Real z) const
Get the axial cell containing height z and the linear interpolation weight within it.
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.
void broadcast(T &data, const unsigned int root_id=0, const bool identical_sizes=false) const
FEProblemBase & _fe_problem
const Parallel::Communicator & _communicator
processor_id_type processor_id() const
MeshBase & mesh
Definition SCM.h:18