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  // Accessing new solution handles should be done in parallel
44  auto val_soln = SolutionHandle(_problem_ptr->getVariable(0, _variable));
45  if (processor_id() > 0)
46  return;
47  auto nz = _mesh.getNumOfAxialCells();
48  auto z_grid = _mesh.getZGrid();
49  auto n_channels = _mesh.getNumOfChannels();
50  auto total_length =
52 
53  if (_height >= total_length)
54  {
55  for (unsigned int i_ch = 0; i_ch < n_channels; i_ch++)
56  {
57  auto * node = _mesh.getChannelNode(i_ch, nz);
58  unsigned int i = (i_ch / _mesh.getNx()); // row
59  unsigned int j = i_ch - i * _mesh.getNx(); // column
60  _exit_value(i, j) = val_soln(node);
61  }
62  }
63  else
64  {
65  for (unsigned int iz = 0; iz < nz; iz++)
66  {
67  if (_height >= z_grid[iz] && _height < z_grid[iz + 1])
68  {
69  for (unsigned int i_ch = 0; i_ch < n_channels; i_ch++)
70  {
71  auto * node_out = _mesh.getChannelNode(i_ch, iz + 1);
72  auto * node_in = _mesh.getChannelNode(i_ch, iz);
73  unsigned int i = (i_ch / _mesh.getNx()); // row
74  unsigned int j = i_ch - i * _mesh.getNx(); // column
75  _exit_value(i, j) = val_soln(node_in) + (val_soln(node_out) - val_soln(node_in)) *
76  (_height - z_grid[iz]) /
77  (z_grid[iz + 1] - z_grid[iz]);
78  }
79  break;
80  }
81  }
82  }
83 
84  std::ofstream myfile;
85  myfile.open(_file_base, std::ofstream::trunc);
86  myfile << std::setprecision(10) << std::fixed << _exit_value << "\n";
87  myfile.close();
88 }
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()
virtual unsigned int getNumOfChannels() const override
Return the number of channels per layer.
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 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.
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.
processor_id_type processor_id() const
virtual const Real & getHeatedLengthEntry() const
Return unheated length at entry.