https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Console.h
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
10#pragma once
11
12// MOOSE includes
13#include "TableOutput.h"
14
18class Console : public TableOutput
19{
20public:
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 {
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
108protected:
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
191
193 std::stringstream _file_output_stream;
194
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
228private:
239 void mooseConsole(const std::string & message);
240
242 const std::ostringstream & _console_buffer;
243
246
249
252
255
256 friend class OutputWarehouse;
257
258private:
261
263};
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
An output object for writing to the console (screen)
Definition Console.h:19
bool _allow_changing_sysinfo_flag
A boolean for protecting _system_info_flags from being changed undesirably.
Definition Console.h:260
virtual void outputVectorPostprocessors() override
Not implemented.
Definition Console.h:127
virtual void outputPostprocessors() override
Prints the postprocessor table to the screen.
Definition Console.C:650
const bool _write_all_procs_to_files
Whether to write all processors to files.
Definition Console.h:226
TimeFormatEnum
Time formatting options.
Definition Console.h:94
unsigned int _max_rows
The max number of table rows.
Definition Console.h:175
bool _libmesh_log
Control the display libMesh performance log.
Definition Console.h:205
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
bool _write_file
Flag for controlling outputting console information to a file.
Definition Console.h:184
virtual ~Console()
Destructor.
Definition Console.C:247
bool _scientific_time
Toggle for outputting time in time and dt in scientific notation.
Definition Console.h:181
TimeFormatEnum & timeFormat()
A reference to the time format to allow callers to set a new format for this console object.
Definition Console.h:106
MultiMooseEnum & systemInfoFlags()
Return system information flags.
Definition Console.h:82
MultiMooseEnum _system_info_flags
Flags for controlling the what simulations information is shown.
Definition Console.h:254
void writeTimestepInformation(bool output_dt)
Prints the time step information for the screen output.
Definition Console.C:426
virtual void timestepSetup() override
Gets called at the beginning of the timestep before this object is asked to do its job.
Definition Console.C:320
void mooseConsole(const std::string &message)
Add a message to the output streams.
Definition Console.C:845
bool _all_variable_norms
Flag for writing all variable norms.
Definition Console.h:211
void write(std::string message, bool indent=true)
Write message to screen and/or file.
Definition Console.C:818
static InputParameters validParams()
Definition Console.C:32
unsigned int _precision
Number of significant digits.
Definition Console.h:220
std::vector< Real > _outlier_multiplier
Multipliers for coloring variable residual norms (default [2, 0.8])
Definition Console.h:217
void meshChanged() override
Performs console related printing when the mesh is changed.
Definition Console.C:779
bool _perf_log
State for all performance logging.
Definition Console.h:196
TimeFormatEnum _time_format
Time format.
Definition Console.h:223
virtual void outputInput() override
Print the input file at the beginning of the simulation.
Definition Console.C:637
virtual void outputScalarVariables() override
Prints the aux scalar variables table to the screen.
Definition Console.C:680
bool _write_screen
Flag for controlling outputting console information to screen.
Definition Console.h:187
std::stringstream _file_output_stream
Stream for storing information to be written to a file.
Definition Console.h:193
bool _verbose
Flag for writing detailed time step information.
Definition Console.h:190
bool _outlier_variable_norms
Flag for writing outlier variable norms.
Definition Console.h:214
bool _last_message_ended_in_newline
Definition Console.h:262
unsigned int _perf_log_interval
The interval at which the performance log is printed.
Definition Console.h:199
std::string formatTime(const Real t) const
A help function to format a time.
Definition Console.C:474
virtual void initialSetup() override
Initial setup function Prints the system information, this is done here so that the system informatio...
Definition Console.C:261
void writeVariableNorms()
Print the L2-norms for each variable.
Definition Console.C:534
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:619
MooseEnum _fit_mode
The FormattedTable fit mode.
Definition Console.h:178
bool _perf_header
State for the performance log header information.
Definition Console.h:208
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
virtual void outputSystemInformation() override
Print system information.
Definition Console.C:698
virtual std::string filename() override
Creates the output file name Appends the user-supplied 'file_base' input parameter with a '....
Definition Console.C:306
const std::ostringstream & _console_buffer
Reference to cached messages from calls to _console.
Definition Console.h:242
static void petscSetupOutput()
Output string for setting up PETSC output.
Definition Console.C:855
virtual void outputReporters() override
Prints the Reporter values to the screen.
Definition Console.C:665
void writeStreamToFile(bool append=true)
Write the file stream to the file.
Definition Console.C:399
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:326
bool _print_mesh_changed_info
Flag for printing mesh information when the mesh changes.
Definition Console.h:251
bool _solve_log
State for solve performance log.
Definition Console.h:202
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
const InputParameters & parameters() const
Get the parameters of the object.
Definition MooseBase.h:131
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition MooseEnum.h:55
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type.
Class for storing and utilizing output objects.
Base class for scalar variables and postprocessors output objects.
Definition TableOutput.h:29