https://mooseframework.inl.gov
Loading...
Searching...
No Matches
SubChannelPointValue.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 "SolutionHandle.h"
12#include "FEProblemBase.h"
13#include "Function.h"
14#include "MooseMesh.h"
15#include "MooseVariable.h"
16#include "SubProblem.h"
17#include "SCM.h"
18
20
23{
25 params.addRequiredParam<VariableName>("variable", "Variable you want the value of");
26 params.addRequiredParam<Real>("height", "Axial location of point [m]");
27 params.addRequiredParam<unsigned int>("index", "Index of subchannel");
29 "Prints out a user selected value of a specified subchannel at a user selected axial height");
30 return params;
31}
32
34 : GeneralPostprocessor(parameters),
35 _mesh(SCM::getConstMesh<SubChannelMesh>(_fe_problem.mesh())),
36 _height(getParam<Real>("height")),
37 _i_ch(getParam<unsigned int>("index")),
38 _variable(getParam<VariableName>("variable")),
39 _value(0)
40{
41 // getNumOfChannels() is zero off rank 0, so every rank checks against the rank 0 count
42 auto n_channels = _mesh.getNumOfChannels();
43 _communicator.broadcast(n_channels);
44 if (_i_ch >= n_channels)
45 paramError("index", "is out of range; valid subchannel indices are 0 to ", n_channels - 1, ".");
46 // The last grid point is accumulated from cell widths, so it can differ from the configured
47 // outlet height by roundoff
48 const auto & z_grid = _mesh.getZGrid();
49 if (MooseUtils::absoluteFuzzyLessThan(_height, z_grid.front()) ||
50 MooseUtils::absoluteFuzzyGreaterThan(_height, z_grid.back()))
51 paramError("height",
52 _height,
53 " is outside the axial extent of the mesh, ",
54 z_grid.front(),
55 " to ",
56 z_grid.back(),
57 ".");
59}
60
61void
63{
64 // Creating a solution handle is collective, so it must happen on every processor
65 const auto soln = SolutionHandle(_fe_problem.getVariable(0, _variable));
66 // The subchannel solution is only available on processor 0
67 if (processor_id() != 0)
68 return;
69 _value = soln.interpolate(
71}
72
73void
78
79Real
81{
82 return _value;
83}
registerMooseObject("SubChannelApp", SubChannelPointValue)
void ErrorVector unsigned int
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
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.
Calculates the value of a user selected variable at a user selected point in the assembly.
static InputParameters validParams()
SubChannelPointValue(const InputParameters &params)
Real _weight
linear interpolation weight of the height within the axial cell
unsigned int _iz
axial cell containing the height
virtual void finalize() override
const unsigned int & _i_ch
subchannel index
virtual void execute() override
const Real & _height
axial location [m]
virtual Real getValue() const override
Real _value
value we want to calculate
const VariableName & _variable
name of variable
const SubChannelMesh & _mesh
geometric information
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