https://mooseframework.inl.gov
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 
15 
18 {
20  params.addRequiredParam<VariableName>("variable", "Variable you want the value of");
21  params.addRequiredParam<Real>("height", "Axial location of normal slice [m]");
22  params.addClassDescription("Prints out a user selected value at a user selected axial height in "
23  "a matrix format to be used for post-processing");
24  params.suppressParameter<bool>("append_date");
25  params.suppressParameter<std::string>("append_date_format");
26  params.suppressParameter<unsigned int>("padding");
27  params.suppressParameter<std::vector<std::string>>("output_if_base_contains");
28  return params;
29 }
30 
32  : FileOutput(parameters),
33  _mesh(dynamic_cast<QuadSubChannelMesh &>(*_mesh_ptr)),
34  _variable(getParam<VariableName>("variable")),
35  _height(getParam<Real>("height"))
36 {
37  _exit_value.resize(_mesh.getNy(), _mesh.getNx());
38 }
39 
40 void
42 {
43  auto val_soln = SolutionHandle(_problem_ptr->getVariable(0, _variable));
44  auto nz = _mesh.getNumOfAxialCells();
45  auto z_grid = _mesh.getZGrid();
46  auto n_channels = _mesh.getNumOfChannels();
47  auto total_length =
49 
50  if (_height >= total_length)
51  {
52  for (unsigned int i_ch = 0; i_ch < n_channels; i_ch++)
53  {
54  auto * node = _mesh.getChannelNode(i_ch, nz);
55  unsigned int i = (i_ch / _mesh.getNx()); // row
56  unsigned int j = i_ch - i * _mesh.getNx(); // column
57  _exit_value(i, j) = val_soln(node);
58  }
59  }
60  else
61  {
62  for (unsigned int iz = 0; iz < nz; iz++)
63  {
64  if (_height >= z_grid[iz] && _height < z_grid[iz + 1])
65  {
66  for (unsigned int i_ch = 0; i_ch < n_channels; i_ch++)
67  {
68  auto * node_out = _mesh.getChannelNode(i_ch, iz + 1);
69  auto * node_in = _mesh.getChannelNode(i_ch, iz);
70  unsigned int i = (i_ch / _mesh.getNx()); // row
71  unsigned int j = i_ch - i * _mesh.getNx(); // column
72  _exit_value(i, j) = val_soln(node_in) + (val_soln(node_out) - val_soln(node_in)) *
73  (_height - z_grid[iz]) /
74  (z_grid[iz + 1] - z_grid[iz]);
75  }
76  break;
77  }
78  }
79  }
80 
81  std::ofstream myfile;
82  myfile.open(_file_base, std::ofstream::trunc);
83  myfile << std::setprecision(10) << std::fixed << _exit_value << "\n";
84  myfile.close();
85 }
virtual const std::vector< Real > & getZGrid() const
Get axial location of layers.
std::string _file_base
Provide a simple RAII interface for linear lagrange solution variables.
Creates the mesh of subchannels in a quadrilateral lattice.
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
void suppressParameter(const std::string &name)
virtual const Real & getHeatedLength() const
Return heated length.
FEProblemBase * _problem_ptr
static InputParameters validParams()
QuadSubChannelNormalSliceValues(const InputParameters &params)
registerMooseObject("SubChannelApp", QuadSubChannelNormalSliceValues)
Eigen::MatrixXd _exit_value
matrix that holds the value of the variable the user wants to print
virtual const unsigned int & getNumOfAxialCells() const
Return the number of axial cells.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual const unsigned int & getNy() const
Number of subchannels in the -y direction.
virtual Node * getChannelNode(unsigned int i_chan, unsigned iz) const override
Get the subchannel mesh node for a given channel index and elevation index.
virtual const unsigned int & getNumOfChannels() const override
Return the number of channels per layer.
const VariableName & _variable
The name of the variable.
void addClassDescription(const std::string &doc_string)
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
virtual const Real & getHeatedLengthExit() const
Return unheated length at exit.
Prints out a user selected variable value in matrix format at a specific plane.
virtual const unsigned int & getNx() const
Number of subchannels in the -x direction.
const Real & _height
The axial location where the plane is.
virtual const Real & getHeatedLengthEntry() const
Return unheated length at entry.