www.mooseframework.org
Console.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 #pragma once
11 
12 // MOOSE includes
13 #include "TableOutput.h"
14 
18 class Console : public TableOutput
19 {
20 public:
22 
27 
31  virtual ~Console();
32 
38  virtual void initialSetup() override;
39 
40  virtual void timestepSetup() override;
41 
52  virtual void output() override;
53 
59  virtual std::string filename() override;
60 
64  static void petscSetupOutput();
65 
69  void meshChanged() override;
70 
76  static std::string
77  outputNorm(const Real & old_norm, const Real & norm, const unsigned int precision = 6);
78 
83  {
85  mooseError(
86  "accessing console system information flags is not allowed after console initial setup");
87  return _system_info_flags;
88  }
89 
93  enum class TimeFormatEnum
94  {
95  PLAIN = 0,
96  SECOND = 1,
97  MINUTE = 2,
98  HOUR = 3,
99  DAY = 4,
100  DTIME = 5
101  };
102 
107 
108 protected:
112  virtual void outputInput() override;
113 
117  virtual void outputScalarVariables() override;
118 
122  virtual void outputPostprocessors() override;
123 
127  virtual void outputVectorPostprocessors() override
128  {
129  mooseError("Can't currently output VectorPostprocessors to the screen");
130  };
131 
135  virtual void outputReporters() override;
136 
140  virtual void outputSystemInformation() override;
141 
147  void writeTimestepInformation(bool output_dt);
148 
154  void write(std::string message, bool indent = true);
155 
164  void writeStreamToFile(bool append = true);
165 
169  void writeVariableNorms();
170 
172  std::string formatTime(const Real t) const;
173 
175  unsigned int _max_rows;
176 
179 
182 
185 
188 
190  bool _verbose;
191 
193  std::stringstream _file_output_stream;
194 
196  bool _perf_log;
197 
199  unsigned int _perf_log_interval;
200 
203 
206 
209 
212 
215 
217  std::vector<Real> _outlier_multiplier;
218 
220  unsigned int _precision;
221 
224 
227 
228 private:
239  void mooseConsole(const std::string & message);
240 
242  const std::ostringstream & _console_buffer;
243 
246 
249 
252 
255 
256  friend class OutputWarehouse;
257 
258 private:
261 
263 };
std::string indent(unsigned int spaces)
Create empty string for indenting.
Definition: ConsoleUtils.C:31
std::string formatTime(const Real t) const
A help function to format a time.
Definition: Console.C:472
bool _libmesh_log
Control the display libMesh performance log.
Definition: Console.h:205
unsigned int _precision
Number of significant digits.
Definition: Console.h:220
static void petscSetupOutput()
Output string for setting up PETSC output.
Definition: Console.C:810
TimeFormatEnum _time_format
Time format.
Definition: Console.h:223
void writeVariableNorms()
Print the L2-norms for each variable.
Definition: Console.C:530
virtual void outputSystemInformation() override
Print system information.
Definition: Console.C:694
MooseEnum _fit_mode
The FormattedTable fit mode.
Definition: Console.h:178
bool _all_variable_norms
Flag for writing all variable norms.
Definition: Console.h:211
An output object for writing to the console (screen)
Definition: Console.h:18
bool _verbose
Flag for writing detailed time step information.
Definition: Console.h:190
bool _write_screen
Flag for controlling outputting console information to screen.
Definition: Console.h:187
const std::ostringstream & _console_buffer
Reference to cached messages from calls to _console.
Definition: Console.h:242
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
MultiMooseEnum & systemInfoFlags()
Return system information flags.
Definition: Console.h:82
bool _allow_changing_sysinfo_flag
A boolean for protecting _system_info_flags from being changed undesirably.
Definition: Console.h:260
virtual void output() override
Customizes the order of output for the various components as well as adds additional output such as t...
Definition: Console.C:324
bool _outlier_variable_norms
Flag for writing outlier variable norms.
Definition: Console.h:214
bool _perf_header
State for the performance log header information.
Definition: Console.h:208
const bool _write_all_procs_to_files
Whether to write all processors to files.
Definition: Console.h:226
MultiMooseEnum _system_info_flags
Flags for controlling the what simulations information is shown.
Definition: Console.h:254
virtual std::string filename() override
Creates the output file name Appends the user-supplied &#39;file_base&#39; input parameter with a &#39;...
Definition: Console.C:304
virtual void outputPostprocessors() override
Prints the postprocessor table to the screen.
Definition: Console.C:646
bool _solve_log
State for solve performance log.
Definition: Console.h:202
std::stringstream _file_output_stream
Stream for storing information to be written to a file.
Definition: Console.h:193
TimeFormatEnum & timeFormat()
A reference to the time format to allow callers to set a new format for this console object...
Definition: Console.h:106
void write(std::string message, bool indent=true)
Write message to screen and/or file.
Definition: Console.C:773
unsigned int _perf_log_interval
The interval at which the performance log is printed.
Definition: Console.h:199
virtual void initialSetup() override
Initial setup function Prints the system information, this is done here so that the system informatio...
Definition: Console.C:260
virtual void timestepSetup() override
Gets called at the beginning of the timestep before this object is asked to do its job...
Definition: Console.C:318
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:31
virtual void outputInput() override
Print the input file at the beginning of the simulation.
Definition: Console.C:633
virtual void outputScalarVariables() override
Prints the aux scalar variables table to the screen.
Definition: Console.C:676
void mooseConsole(const std::string &message)
Add a message to the output streams.
Definition: Console.C:800
auto norm(const T &a) -> decltype(std::abs(a))
unsigned int _max_rows
The max number of table rows.
Definition: Console.h:175
Class for storing and utilizing output objects.
Real _old_nonlinear_norm
Storage for the old non linear residual (needed for color output and only when used when printing to ...
Definition: Console.h:248
bool _write_file
Flag for controlling outputting console information to a file.
Definition: Console.h:184
TimeFormatEnum
Time formatting options.
Definition: Console.h:93
virtual ~Console()
Destructor.
Definition: Console.C:246
bool _perf_log
State for all performance logging.
Definition: Console.h:196
void writeStreamToFile(bool append=true)
Write the file stream to the file.
Definition: Console.C:397
virtual void outputVectorPostprocessors() override
Not implemented.
Definition: Console.h:127
std::vector< Real > _outlier_multiplier
Multipliers for coloring variable residual norms (default [2, 0.8])
Definition: Console.h:217
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static std::string outputNorm(const Real &old_norm, const Real &norm, const unsigned int precision=6)
A helper function for outputting norms in color.
Definition: Console.C:615
static InputParameters validParams()
Definition: Console.C:30
void meshChanged() override
Performs console related printing when the mesh is changed.
Definition: Console.C:747
Real _old_linear_norm
Storage for the old linear residual (needed for color output and only when used when printing to the ...
Definition: Console.h:245
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
Base class for scalar variables and postprocessors output objects.
Definition: TableOutput.h:28
const InputParameters & parameters() const
Get the parameters of the object.
bool _scientific_time
Toggle for outputting time in time and dt in scientific notation.
Definition: Console.h:181
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
void writeTimestepInformation(bool output_dt)
Prints the time step information for the screen output.
Definition: Console.C:424
bool _print_mesh_changed_info
Flag for printing mesh information when the mesh changes.
Definition: Console.h:251
bool _last_message_ended_in_newline
Definition: Console.h:262
virtual void outputReporters() override
Prints the Reporter values to the screen.
Definition: Console.C:661
Console(const InputParameters &parameters)
Class constructor.
Definition: Console.C:179