https://mooseframework.inl.gov
Loading...
Searching...
No Matches
QuadSubChannelNormalSliceValues.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 "SCM.h"
14
16
19{
21 params.addRequiredParam<VariableName>("variable", "Variable you want the value of");
22 params.addRequiredParam<Real>("height", "Axial location of normal slice [m]");
23 params.addClassDescription("Prints out a user selected value at a user selected axial height in "
24 "a matrix format to be used for post-processing");
25 params.suppressParameter<bool>("append_date");
26 params.suppressParameter<std::string>("append_date_format");
27 params.suppressParameter<unsigned int>("padding");
28 params.suppressParameter<std::vector<std::string>>("output_if_base_contains");
29 return params;
30}
31
33 : FileOutput(parameters),
34 _mesh(SCM::getConstMesh<QuadSubChannelMesh>(*_mesh_ptr)),
35 _variable(getParam<VariableName>("variable")),
36 _height(getParam<Real>("height"))
37{
38 if (MooseUtils::absoluteFuzzyLessThan(_height, _mesh.getZGrid().front()))
40 "height", _height, " is below the inlet of the mesh at ", _mesh.getZGrid().front(), ".");
42 _exit_value.resize(_mesh.getNy(), _mesh.getNx());
43}
44
45void
47{
48 // Accessing new solution handles should be done in parallel
50 if (processor_id() > 0)
51 return;
52 const auto nx = _mesh.getNx();
53 for (const auto i_ch : make_range(_mesh.getNumOfChannels()))
54 {
55 const auto * node_in = _mesh.getChannelNode(i_ch, _iz);
56 const auto * node_out = _mesh.getChannelNode(i_ch, _iz + 1);
57 const unsigned int i = i_ch / nx; // row
58 const unsigned int j = i_ch - i * nx; // column
59 _exit_value(i, j) = val_soln.interpolate(node_in, node_out, _weight);
60 }
61
62 std::ofstream myfile;
63 myfile.open(_file_base, std::ofstream::trunc);
64 myfile << std::setprecision(10) << std::fixed << _exit_value << "\n";
65 myfile.close();
66}
registerMooseObject("SubChannelApp", QuadSubChannelNormalSliceValues)
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()
std::string _file_base
void suppressParameter(const std::string &name)
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
FEProblemBase * _problem_ptr
Creates the mesh of subchannels in a quadrilateral lattice.
unsigned int getNumOfChannels() const override
Return the number of channels per layer.
const unsigned int & getNx() const
Number of subchannels in the -x direction.
const unsigned int & getNy() const
Number of subchannels in the -y direction.
Node * getChannelNode(unsigned int i_chan, unsigned int iz) const override
Get the subchannel mesh node for a given channel index and elevation index.
Prints out a user selected variable value in matrix format at a specific plane.
Real _weight
linear interpolation weight of the height within the axial cell
Eigen::MatrixXd _exit_value
matrix that holds the value of the variable the user wants to print
const VariableName & _variable
The name of the variable.
const Real & _height
The axial location where the plane is.
QuadSubChannelNormalSliceValues(const InputParameters &params)
unsigned int _iz
axial cell containing the height
Provide a simple RAII interface for linear lagrange solution variables.
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.
processor_id_type processor_id() const
Definition SCM.h:18