www.mooseframework.org
Console.C
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 // MOOSE includes
11 #include "Console.h"
12 #include "ConsoleUtils.h"
13 #include "FEProblem.h"
14 #include "EigenProblem.h"
15 #include "Postprocessor.h"
16 #include "PetscSupport.h"
17 #include "Executioner.h"
18 #include "MooseApp.h"
19 #include "Moose.h"
20 #include "FormattedTable.h"
21 #include "NonlinearSystem.h"
22 #include "CommonOutputAction.h"
23 
24 // libMesh includes
25 #include "libmesh/enum_norm_type.h"
26 
27 registerMooseObject("MooseApp", Console);
28 
31 {
32  // Enum for selecting the fit mode for the table when printed to the screen
34 
35  // Get the parameters from the base class
37  params.addClassDescription("Object for screen output.");
38 
39  params += TableOutput::enableOutputTypes("system_information scalar postprocessor input");
40 
41  // Screen and file output toggles
42  params.addParam<bool>("output_screen", true, "Output to the screen");
43  params.addParam<bool>("output_file",
44  false,
45  "Output to the file. The default behavior is to write to file only from "
46  "the head processor. If \"--keep-cout\" is passed to the executable, then "
47  "each processor will write to its own file. The same parallel behaviour "
48  "can also be achieved by passing \"--keep-cout --redirect-stdout\" to the "
49  "executable without setting this parameter to true.");
50  params.addParam<bool>(
51  "show_multiapp_name", false, "Indent multiapp output using the multiapp name");
52 
53  // Table fitting options
54  params.addParam<unsigned int>("max_rows",
55  15,
56  "The maximum number of postprocessor/scalar values "
57  "displayed on screen during a timestep (set to 0 "
58  "for unlimited)");
59  params.addParam<MooseEnum>("fit_mode",
60  pps_fit_mode,
61  "Specifies the wrapping mode for post-processor tables that are "
62  "printed to the screen (ENVIRONMENT: Read \"MOOSE_PPS_WIDTH\" for "
63  "desired width (if not set, defaults to AUTO), AUTO: Attempt to "
64  "determine width automatically (serial only), <n>: Desired width");
65 
66  // Verbosity
67  params.addParam<bool>("verbose", false, "Print detailed diagnostics on timestep calculation");
68 
69  // Basic table output controls
70  params.addParam<bool>(
71  "scientific_time", false, "Control the printing of time and dt in scientific notation");
72  params.addParam<unsigned int>(
73  "time_precision",
74  "The number of significant digits that are printed on time related outputs");
75  MooseEnum time_format("plain=0 second=1 minute=2 hour=3 day=4 dtime=5", "plain");
76  params.addParam<MooseEnum>(
77  "time_format",
78  time_format,
79  "The format for the printed times ('dtime' means a format like 1d 01:01:0.1)");
80 
81  // Performance Logging
82  params.addDeprecatedParam<bool>("perf_log",
83  false,
84  "If true, all performance logs will be printed. The "
85  "individual log settings will override this option.",
86  "Use PerfGraphOutput");
87  params.addDeprecatedParam<unsigned int>(
88  "perf_log_interval",
89  0,
90  "If set, the performance log will be printed every n time steps",
91  "Use PerfGraphOutput instead");
92  params.addParam<bool>("solve_log", "Toggles the printing of the 'Moose Test Performance' log");
93  params.addDeprecatedParam<bool>(
94  "perf_header",
95  "Print the libMesh performance log header (requires that 'perf_log = true')",
96  "Use PerfGraphOutput instead");
97 
98  params.addParam<bool>(
99  "libmesh_log",
100  true,
101  "Print the libMesh performance log, requires libMesh to be configured with --enable-perflog");
102 
103  // Toggle printing of mesh information on adaptivity steps
104  params.addParam<bool>("print_mesh_changed_info",
105  false,
106  "When true, each time the mesh is changed the mesh information is printed");
107 
108  // Toggle for printing variable norms
109  params.addParam<bool>("outlier_variable_norms",
110  true,
111  "If true, outlier variable norms will be printed after each solve");
112  params.addParam<bool>(
113  "all_variable_norms", false, "If true, all variable norms will be printed after each solve");
114 
115  // Multipliers for coloring of variable residual norms
116  std::vector<Real> multiplier;
117  multiplier.push_back(0.8);
118  multiplier.push_back(2);
119  params.addParam<std::vector<Real>>("outlier_multiplier",
120  multiplier,
121  "Multiplier utilized to determine if a residual norm is an "
122  "outlier. If the variable residual is less than "
123  "multiplier[0] times the total residual it is colored red. "
124  "If the variable residual is less than multiplier[1] times "
125  "the average residual it is colored yellow.");
126 
127  // System information controls
128  MultiMooseEnum info("framework mesh aux nonlinear relationship execution output",
129  "framework mesh aux nonlinear execution");
130  params.addParam<MultiMooseEnum>("system_info",
131  info,
132  "List of information types to display "
133  "('framework', 'mesh', 'aux', 'nonlinear', 'relationship', "
134  "'execution', 'output')");
135 
136  // Advanced group
137  params.addParamNamesToGroup("verbose show_multiapp_name system_info", "Advanced");
138 
139  // Performance log group
140  params.addParamNamesToGroup("perf_log solve_log perf_header libmesh_log", "Perf Log");
141 
142  // Variable norms group
143  params.addParamNamesToGroup("outlier_variable_norms all_variable_norms outlier_multiplier",
144  "Variable and Residual Norms");
145 
146  // Number formatting
147  params.addParamNamesToGroup("scientific_time time_precision time_format",
148  "Time output formatting");
149 
150  // Table of postprocessor output formatting
151  params.addParamNamesToGroup("max_rows fit_mode", "Table formatting");
152 
153  /*
154  * The following modifies the default behavior from base class parameters. Notice the extra flag
155  * on
156  * the set method. This enables "quiet mode". This is done to allow for the proper detection
157  * of user-modified parameters
158  */
159  // By default set System Information to output on initial
160  params.set<ExecFlagEnum>("execute_system_information_on", /*quite_mode=*/true) = EXEC_INITIAL;
161 
162  // Change the default behavior of 'execute_on' to included nonlinear iterations and failed
163  // timesteps
164  params.set<ExecFlagEnum>("execute_on", /*quiet_mode=*/true) = {
166 
167  // By default postprocessors and scalar are only output at the end of a timestep
168  params.set<ExecFlagEnum>("execute_postprocessors_on", /*quiet_mode=*/true) = {EXEC_INITIAL,
170  params.set<ExecFlagEnum>("execute_vector_postprocessors_on",
171  /*quiet_mode=*/true) = {EXEC_INITIAL, EXEC_TIMESTEP_END};
172  params.set<ExecFlagEnum>("execute_scalars_on", /*quiet_mode=*/true) = {EXEC_INITIAL,
174  params.set<ExecFlagEnum>("execute_reporters_on", /*quiet_mode=*/true) = {EXEC_INITIAL,
176  return params;
177 }
178 
180  : TableOutput(parameters),
181  _max_rows(getParam<unsigned int>("max_rows")),
182  _fit_mode(getParam<MooseEnum>("fit_mode")),
183  _scientific_time(getParam<bool>("scientific_time")),
184  _write_file(getParam<bool>("output_file")),
185  _write_screen(getParam<bool>("output_screen")),
186  _verbose(getParam<bool>("verbose")),
187  _perf_log(getParam<bool>("perf_log")),
188  _perf_log_interval(getParam<unsigned int>("perf_log_interval")),
189  _solve_log(isParamValid("solve_log") ? getParam<bool>("solve_log") : _perf_log),
190  _libmesh_log(getParam<bool>("libmesh_log")),
191  _perf_header(isParamValid("perf_header") ? getParam<bool>("perf_header") : _perf_log),
192  _all_variable_norms(getParam<bool>("all_variable_norms")),
193  _outlier_variable_norms(getParam<bool>("outlier_variable_norms")),
194  _outlier_multiplier(getParam<std::vector<Real>>("outlier_multiplier")),
195  _precision(isParamValid("time_precision") ? getParam<unsigned int>("time_precision") : 0),
196  _time_format(getParam<MooseEnum>("time_format").getEnum<TimeFormatEnum>()),
197  _write_all_procs_to_files(_app.getParam<bool>("keep_cout")),
198  _console_buffer(_app.getOutputWarehouse().consoleBuffer()),
199  _old_linear_norm(std::numeric_limits<Real>::max()),
200  _old_nonlinear_norm(std::numeric_limits<Real>::max()),
201  _print_mesh_changed_info(getParam<bool>("print_mesh_changed_info")),
202  _system_info_flags(getParam<MultiMooseEnum>("system_info")),
203  _allow_changing_sysinfo_flag(true),
204  _last_message_ended_in_newline(true)
205 {
206  // Apply the special common console flags (print_...)
208  const auto actions = awh.getActions<CommonOutputAction>();
209  mooseAssert(actions.size() <= 1, "Should not be more than one CommonOutputAction");
210  const Action * common = actions.empty() ? nullptr : *actions.begin();
211 
212  if (!parameters.isParamSetByUser("execute_on"))
213  {
214  // Honor the 'print_linear_residuals' option, only if 'linear' has not been set in 'execute_on'
215  // by the user
216  if (common && common->getParam<bool>("print_linear_residuals"))
217  _execute_on.push_back("linear");
218  else
219  _execute_on.erase("linear");
220  if (common && common->getParam<bool>("print_nonlinear_residuals"))
221  _execute_on.push_back("nonlinear");
222  else
223  _execute_on.erase("nonlinear");
224  }
225 
226  if (!_pars.isParamSetByUser("perf_log") && common && common->getParam<bool>("print_perf_log"))
227  {
228  _perf_log = true;
229  _solve_log = true;
230  }
231 
232  // Append the common 'execute_on' to the setting for this object
233  // This is unique to the Console object, all other objects inherit from the common options
234  if (common)
235  {
236  const ExecFlagEnum & common_execute_on = common->getParam<ExecFlagEnum>("execute_on");
237  for (auto & mme : common_execute_on)
238  _execute_on.push_back(mme);
239  }
240 
241  // If --show-outputs is used, enable it
242  if (_app.getParam<bool>("show_outputs"))
243  _system_info_flags.push_back("output");
244 }
245 
247 {
248  // Write the libMesh log
249  if (_libmesh_log)
250  write(libMesh::perflog.get_perf_info(), false);
251 
252  // Write the file output stream
254 
255  // Disable logging so that the destructor in libMesh doesn't print
257 }
258 
259 void
261 {
262  // Only allow the main app to change the perf_log settings.
263  if (_app.name() == "main")
264  {
265  // Disable libMesh log
266  if (!_libmesh_log)
268  }
269 
270  // system info flag can be changed only before console initial setup
272 
273  // If execute_on = 'initial' perform the output
274  if (wantOutput("system_information", EXEC_INITIAL))
276 
277  // Call the base class method
279 
280  // If file output is desired, wipe out the existing file if not recovering
281  if (!_app.isRecovering())
282  writeStreamToFile(false);
283 
284  // Enable verbose output if Executioner has it enabled
285  if (_app.getExecutioner()->isParamValid("verbose") &&
286  _app.getExecutioner()->getParam<bool>("verbose"))
287  _verbose = true;
288 
289  // If the user adds "final" to the execute on, append this to the postprocessors, scalars, etc.,
290  // but only
291  // if the parameter (e.g., postprocessor_execute_on) has not been modified by the user.
292  if (_execute_on.contains("final"))
293  {
294  if (!_pars.isParamSetByUser("postprocessor_execute_on"))
295  _advanced_execute_on["postprocessors"].push_back("final");
296  if (!_pars.isParamSetByUser("scalars_execute_on"))
297  _advanced_execute_on["scalars"].push_back("final");
298  if (!_pars.isParamSetByUser("vector_postprocessor_execute_on"))
299  _advanced_execute_on["vector_postprocessors"].push_back("final");
300  }
301 }
302 
303 std::string
305 {
306  std::string file_name;
308  {
309  std::string pid = std::to_string(processor_id());
310  file_name = _file_base + "_" + pid + ".txt";
311  }
312  else
313  file_name = _file_base + ".txt";
314  return file_name;
315 }
316 
317 void
319 {
320  writeTimestepInformation(/*output_dt = */ true);
321 }
322 
323 void
325 {
326  const auto & type = _current_execute_flag;
327 
328  // Return if the current output is not on the desired interval
329  if (type != EXEC_FINAL && !onInterval())
330  return;
331 
332  // Output the system information first; this forces this to be the first item to write by default
333  // However, 'output_system_information_on' still operates correctly, so it may be changed by the
334  // user
335  if (wantOutput("system_information", type) && !(type == EXEC_INITIAL))
337 
338  // Write the input
339  if (wantOutput("input", type))
340  outputInput();
341 
342  // Write the timestep information ("Time Step 0 ..."), this is controlled with "execute_on"
343  // We only write the initial and final here. All of the intermediate outputs will be written
344  // through timestepSetup.
346  writeTimestepInformation(/*output_dt = */ false);
348  {
349  if (wantOutput("postprocessors", type) || wantOutput("scalars", type))
350  _console << "\nFINAL:\n";
351  }
352 
353  // Print Non-linear Residual (control with "execute_on")
355  {
356  if (_nonlinear_iter == 0)
358 
359  _console << std::right << std::setw(2) << _nonlinear_iter
360  << " Nonlinear |R| = " << outputNorm(_old_nonlinear_norm, _norm) << '\n';
361 
363  }
364 
365  // Print Linear Residual (control with "execute_on")
367  {
368  if (_linear_iter == 0)
370 
371  _console << std::right << std::setw(7) << _linear_iter
372  << " Linear |R| = " << outputNorm(_old_linear_norm, _norm) << '\n';
373 
375  }
376 
377  // Write variable norms
378  else if (type == EXEC_TIMESTEP_END)
380 
381  if (wantOutput("postprocessors", type))
383 
384  if (wantOutput("scalars", type))
386 
387  if (wantOutput("reporters", type))
388  outputReporters();
389 
390  // Write the file
392 
393  _console << std::flush;
394 }
395 
396 void
398 {
400  return;
401 
402  // Create the stream
403  std::ofstream output;
404 
405  // Open the file
406  if (append)
407  output.open(filename().c_str(), std::ios::app | std::ios::out);
408  else
409  output.open(filename().c_str(), std::ios::trunc);
410 
411  if (output.fail())
412  mooseError("Unable to open file ", filename());
413 
414  std::string s = _file_output_stream.str();
415  // Write contents of file output stream and close the file
417  output.close();
418 
419  // Clear the file output stream
420  _file_output_stream.str("");
421 }
422 
423 void
425 {
426  // Stream to build the time step information
427  std::stringstream oss;
428 
429  // Write timestep data for transient executioners
430  if (_transient)
431  {
432  // Write time step and time information
433  oss << "\nTime Step " << timeStep();
434  unsigned int time_step_digits = oss.str().length() - 11;
435 
436  // Print the time
437  oss << ", time = " << formatTime(getOutputTime());
438 
439  if (output_dt)
440  {
441  if (!_verbose)
442  // Show the time delta information
443  oss << ", dt = " << std::left << formatTime(dt());
444 
445  // Show old time information, if desired on separate lines
446  else
447  {
448  unsigned int fillsize = 19 + time_step_digits;
449  oss << '\n'
450  << std::right << std::setw(fillsize) << std::setfill(' ') << "old time = " << std::left
451  << formatTime(timeOld()) << '\n';
452 
453  // Show the time delta information
454  oss << std::right << std::setw(fillsize) << std::setfill(' ') << "dt = " << std::left
455  << formatTime(dt()) << '\n';
456 
457  // Show the old time delta information, if desired
458  if (_verbose)
459  oss << std::right << std::setw(fillsize) << std::setfill(' ')
460  << "old dt = " << formatTime(_dt_old) << '\n';
461  }
462  }
463 
464  oss << '\n';
465 
466  // Output to the screen
467  _console << oss.str() << std::flush;
468  }
469 }
470 
471 std::string
472 Console::formatTime(const Real t) const
473 {
474  std::ostringstream oss;
476  {
477  if (_precision > 0)
478  oss << std::setw(_precision) << std::setprecision(_precision) << std::setfill('0')
479  << std::showpoint;
480  if (_scientific_time)
481  oss << std::scientific;
482 
484  oss << t;
486  oss << t << "s";
488  oss << t / 60 << "m";
490  oss << t / 3600 << "h";
491  else if (_time_format == TimeFormatEnum::DAY)
492  oss << t / 86400 << "d";
493  }
494  else
495  {
496  Real abst = t;
497  if (t < 0)
498  {
499  oss << "-";
500  abst = -t;
501  }
502  int days = std::floor(abst / 24 / 3600);
503  int hours = std::floor(abst / 3600 - days * 24);
504  int mins = std::floor(abst / 60 - days * 24 * 60 - hours * 60);
505  Real second = abst - days * 24 * 3600 - hours * 3600 - mins * 60;
506 
507  if (days != 0)
508  oss << days << "d";
509  if (hours != 0 || mins != 0 || second != 0)
510  {
511  if (days != 0)
512  oss << " ";
513  oss << std::setfill('0') << std::setw(2) << hours << ":" << std::setfill('0') << std::setw(2)
514  << mins << ":";
515 
516  if (second < 10)
517  oss << "0";
518  if (_precision > 0)
519  oss << std::setw(_precision) << std::setprecision(_precision) << std::setfill('0')
520  << std::showpoint;
521  if (_scientific_time)
522  oss << std::scientific;
523  oss << second;
524  }
525  }
526  return oss.str();
527 }
528 
529 void
531 {
532  // If all_variable_norms is true, then so should outlier printing
535 
536  // if we are not priting anything, let's not waste time computing the norms below and just exit
537  // this call
538  if ((_all_variable_norms == false) && (_outlier_variable_norms == false))
539  return;
540 
541  // if it is an eigenvalue prolblem, we do not know to define RHS,
542  // and then we do not know how to compute variable norms
543  if (dynamic_cast<EigenProblem *>(_problem_ptr) != nullptr)
544  return;
545 
546  // Flag set when header prints
547  bool header = false;
548 
549  // String stream for variable norm information
550  std::ostringstream oss;
551 
552  for (const auto i : make_range(_problem_ptr->numNonlinearSystems()))
553  {
554  // Get a references to the NonlinearSystem and libMesh system
556  System & sys = nl.system();
557 
558  // Storage for norm outputs
559  std::map<std::string, Real> other;
560  std::map<std::string, Real> outlier;
561 
562  // Average norm
563  unsigned int n_vars = sys.n_vars();
564  Real avg_norm = (nl.nonlinearNorm() * nl.nonlinearNorm()) / n_vars;
565 
566  // Compute the norms for each of the variables
567  for (unsigned int i = 0; i < n_vars; i++)
568  {
569  // Compute the norm and extract the variable name
570  Real var_norm = sys.calculate_norm(nl.RHS(), i, DISCRETE_L2);
571  var_norm *= var_norm; // use the norm squared
572  std::string var_name = sys.variable_name(i);
573 
574  // Outlier if the variable norm is greater than twice (default) of the average norm
575  if (_outlier_variable_norms && (var_norm > _outlier_multiplier[1] * avg_norm))
576  {
577  // Print the header
578  if (!header)
579  {
580  oss << "\nOutlier Variable Residual Norms:\n";
581  header = true;
582  }
583 
584  // Set the color, RED if the variable norm is 0.8 (default) of the total norm
585  std::string color = COLOR_YELLOW;
586  if (_outlier_variable_norms && (var_norm > _outlier_multiplier[0] * avg_norm * n_vars))
587  color = COLOR_RED;
588 
589  // Display the residual
590  oss << " " << var_name << ": " << std::scientific << color << std::sqrt(var_norm)
591  << COLOR_DEFAULT << '\n';
592  }
593 
594  // GREEN
595  else if (_all_variable_norms)
596  {
597  // Print the header if it doesn't already exist
598  if (!header)
599  {
600  oss << "\nVariable Residual Norms:\n";
601  header = true;
602  }
603  oss << " " << var_name << ": " << std::scientific << COLOR_GREEN << std::sqrt(var_norm)
604  << COLOR_DEFAULT << '\n';
605  }
606  }
607  }
608 
609  // Update the output streams
610  _console << oss.str() << std::flush;
611 }
612 
613 // Quick helper to output the norm in color
614 std::string
615 Console::outputNorm(const Real & old_norm, const Real & norm, const unsigned int precision)
616 {
617  std::string color = COLOR_GREEN;
618 
619  // Red if the residual went up... or if the norm is nan
620  if (norm != norm || norm > old_norm)
621  color = COLOR_RED;
622  // Yellow if change is less than 5%
623  else if ((old_norm - norm) / old_norm <= 0.05)
624  color = COLOR_YELLOW;
625 
626  std::stringstream oss;
627  oss << std::scientific << std::setprecision(precision) << color << norm << COLOR_DEFAULT;
628 
629  return oss.str();
630 }
631 
632 void
634 {
635  if (!_write_screen && !_write_file)
636  return;
637 
638  std::ostringstream oss;
639  for (const auto & filename : _app.getInputFileNames())
640  oss << "--- " << filename << "\n";
642  _console << oss.str() << std::endl;
643 }
644 
645 void
647 {
649 
651  {
652  std::stringstream oss;
653  oss << "\nPostprocessor Values:\n";
656  _console << oss.str() << std::endl;
657  }
658 }
659 
660 void
662 {
664 
665  if (!_reporter_table.empty())
666  {
667  std::stringstream oss;
668  oss << "\nReporter Values:\n";
671  _console << oss.str() << '\n';
672  }
673 }
674 
675 void
677 {
679 
680  if (!_scalar_table.empty())
681  {
682  std::stringstream oss;
683  oss << "\nScalar Variable Values:\n";
684  if (processor_id() == 0)
685  {
688  }
689  _console << oss.str() << std::endl;
690  }
691 }
692 
693 void
695 {
696  // skip system information output for sub-apps other than the zero-th of a MultiApp
697  // because they are using the same inputs and are most likely having the same information.
698  if (_app.multiAppNumber() > 0)
699  return;
700 
701  if (_system_info_flags.contains("framework"))
703 
704  if (_system_info_flags.contains("mesh"))
706 
707  if (_system_info_flags.contains("nonlinear"))
708  {
709  for (const auto i : make_range(_problem_ptr->numNonlinearSystems()))
710  {
712  if (!output.empty())
713  _console << "Nonlinear System" +
714  (_problem_ptr->numNonlinearSystems() > 1 ? (" " + std::to_string(i)) : "") +
715  ":\n"
716  << output;
717  }
718  }
719 
720  if (_system_info_flags.contains("aux"))
721  {
723  if (!output.empty())
724  _console << "Auxiliary System:\n" << output;
725  }
726 
727  if (_system_info_flags.contains("relationship"))
728  {
730  if (!output.empty())
731  _console << "Relationship Managers:\n" << output;
732  }
733 
734  if (_system_info_flags.contains("execution"))
736 
737  if (_system_info_flags.contains("output"))
739 
740  // Output the legacy flags, these cannot be turned off so they become annoying to people.
742 
743  _console << std::flush;
744 }
745 
746 void
748 {
750  {
751  _console << ConsoleUtils::outputMeshInformation(*_problem_ptr, /*verbose = */ false);
752 
753  std::string output;
754  for (const auto i : make_range(_problem_ptr->numNonlinearSystems()))
755  {
757  if (!output.empty())
758  _console << "Nonlinear System" +
759  (_problem_ptr->numNonlinearSystems() > 1 ? (" " + std::to_string(i)) : "") +
760  ":\n"
761  << output;
762  }
763 
765  if (!output.empty())
766  _console << "Auxiliary System:\n" << output;
767 
768  _console << std::flush;
769  }
770 }
771 
772 void
773 Console::write(std::string message, bool indent /*=true*/)
774 {
775  // Do nothing if the message is empty, writing empty strings messes with multiapp indenting
776  if (message.empty())
777  return;
778 
779  // Write the message to file
780  if (_write_file)
781  _file_output_stream << message;
782 
783  // The empty case gets the right behavior, even though the boolean is technically wrong
784  bool this_message_ends_in_newline = message.empty() ? true : (message.back() == '\n');
785  bool this_message_starts_with_newline = message.empty() ? true : (message.front() == '\n');
786 
787  // Apply MultiApp indenting
788  if ((this_message_starts_with_newline || _last_message_ended_in_newline) && indent &&
789  _app.multiAppLevel() > 0)
790  MooseUtils::indentMessage(_app.name(), message);
791 
792  // Write message to the screen
793  if (_write_screen)
794  Moose::out << message;
795 
796  _last_message_ended_in_newline = this_message_ends_in_newline;
797 }
798 
799 void
800 Console::mooseConsole(const std::string & message)
801 {
802  // Write the messages
803  write(message);
804 
805  // Flush the stream to the screen
806  Moose::out << std::flush;
807 }
808 
809 void
811 {
812  char c[] = {
813  32, 47, 94, 92, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
814  32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
815  32, 32, 32, 32, 32, 32, 32, 47, 94, 92, 13, 10, 124, 32, 32, 32, 92, 95, 47,
816  94, 92, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
817  32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 47, 94, 92, 95, 47,
818  32, 32, 32, 124, 13, 10, 124, 32, 32, 32, 32, 32, 32, 32, 32, 92, 95, 47, 94,
819  92, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
820  32, 32, 32, 47, 94, 92, 95, 47, 32, 32, 32, 32, 32, 32, 32, 32, 124, 13, 10,
821  32, 92, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 92, 95, 47, 94, 92,
822  32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 47, 94, 92, 95, 47, 32, 32, 32,
823  32, 32, 32, 32, 32, 32, 32, 32, 32, 47, 13, 10, 32, 32, 92, 95, 95, 32, 32,
824  32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 92, 95, 95, 95, 45, 45, 45,
825  95, 95, 95, 47, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 95,
826  95, 47, 13, 10, 32, 32, 32, 32, 32, 45, 45, 45, 95, 95, 95, 32, 32, 32, 32,
827  32, 32, 32, 32, 32, 47, 32, 32, 32, 32, 32, 32, 32, 92, 32, 32, 32, 32, 32,
828  32, 32, 32, 32, 95, 95, 95, 45, 45, 45, 13, 10, 32, 32, 32, 32, 32, 32, 32,
829  32, 32, 32, 32, 45, 45, 45, 95, 95, 95, 32, 32, 124, 32, 32, 32, 32, 32, 32,
830  32, 32, 32, 124, 32, 32, 95, 95, 95, 45, 45, 45, 13, 10, 32, 32, 32, 32, 32,
831  32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 45, 45, 124, 32, 32, 95, 32,
832  32, 32, 95, 32, 32, 124, 45, 45, 13, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32,
833  32, 32, 32, 32, 32, 32, 32, 32, 32, 124, 32, 32, 124, 111, 124, 32, 124, 111, 124,
834  32, 32, 124, 13, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
835  32, 32, 32, 47, 32, 32, 32, 32, 45, 32, 32, 32, 45, 32, 32, 32, 32, 92, 13,
836  10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 124, 32,
837  32, 32, 32, 32, 32, 95, 95, 95, 32, 32, 32, 32, 32, 32, 124, 13, 10, 32, 32,
838  32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 47, 32, 32, 32, 32, 32,
839  45, 45, 32, 32, 32, 45, 45, 32, 32, 32, 32, 32, 92, 13, 10, 32, 32, 32, 32,
840  32, 32, 32, 32, 32, 32, 32, 32, 32, 47, 32, 32, 32, 32, 32, 32, 32, 32, 32,
841  32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 92, 13, 10, 32, 32, 32, 32,
842  32, 32, 32, 32, 32, 32, 32, 32, 124, 32, 32, 32, 32, 32, 32, 32, 47, 92, 32,
843  32, 32, 32, 32, 47, 92, 32, 32, 32, 32, 32, 32, 32, 124, 13, 10, 32, 32, 32,
844  32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 92, 32, 32, 92, 32, 32, 32, 32, 32,
845  32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 47, 32, 32, 47, 13, 10, 32, 32, 32,
846  32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 47, 92, 32, 32, 92, 95, 95, 95, 95,
847  95, 95, 95, 95, 95, 95, 95, 95, 32, 47, 32, 32, 47, 92, 13, 10, 32, 32, 32,
848  32, 32, 32, 32, 32, 32, 32, 32, 32, 47, 32, 32, 92, 32, 32, 32, 32, 32, 32,
849  32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 47, 32, 32, 92, 13, 10, 32, 32,
850  32, 32, 32, 32, 32, 32, 32, 32, 32, 47, 32, 32, 32, 32, 92, 32, 32, 32, 32,
851  32, 39, 95, 95, 95, 39, 32, 32, 32, 32, 32, 47, 32, 32, 32, 32, 92, 13, 10,
852  32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 47, 92, 32, 32, 32, 32, 32, 92, 32,
853  45, 45, 95, 95, 45, 45, 45, 95, 95, 45, 45, 32, 47, 32, 32, 32, 32, 32, 47,
854  92, 13, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 47, 32, 32, 92, 47, 32, 32,
855  32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
856  92, 47, 32, 32, 92, 13, 10, 32, 32, 32, 32, 32, 32, 32, 32, 47, 32, 32, 32,
857  47, 32, 32, 32, 32, 32, 32, 32, 77, 46, 79, 46, 79, 46, 83, 46, 69, 32, 32,
858  32, 32, 32, 32, 32, 92, 32, 32, 32, 92, 13, 10, 32, 32, 32, 32, 32, 32, 32,
859  47, 32, 32, 32, 124, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
860  32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 124, 32, 32, 32, 92, 13, 10, 32,
861  32, 32, 32, 32, 32, 124, 32, 32, 32, 32, 124, 45, 45, 45, 45, 45, 45, 45, 45,
862  45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 124, 32,
863  32, 32, 32, 124, 13, 10, 32, 32, 32, 32, 32, 32, 32, 92, 32, 32, 32, 32, 92,
864  32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
865  32, 32, 32, 32, 47, 32, 32, 32, 32, 47, 13, 10, 32, 32, 32, 32, 32, 32, 32,
866  32, 32, 92, 92, 32, 92, 95, 92, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
867  32, 32, 32, 32, 32, 32, 32, 32, 47, 95, 47, 32, 47, 47, 13, 10, 32, 32, 32,
868  32, 32, 32, 32, 32, 32, 32, 32, 45, 45, 32, 32, 92, 32, 32, 32, 32, 32, 32,
869  32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 47, 32, 32, 45, 45, 13, 10, 32,
870  32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 124, 32, 32, 45,
871  45, 45, 95, 95, 95, 95, 95, 45, 45, 45, 32, 32, 124, 13, 10, 32, 32, 32, 32,
872  32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 124, 32, 32, 32, 32, 32, 124,
873  32, 32, 32, 124, 32, 32, 32, 32, 32, 124, 13, 10, 32, 32, 32, 32, 32, 32, 32,
874  32, 32, 32, 32, 32, 32, 32, 32, 32, 124, 32, 32, 32, 32, 32, 124, 32, 32, 32,
875  124, 32, 32, 32, 32, 32, 124, 13, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
876  32, 32, 32, 32, 32, 47, 32, 86, 32, 32, 32, 32, 32, 92, 32, 47, 32, 32, 32,
877  32, 86, 32, 32, 92, 13, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
878  32, 32, 32, 124, 95, 124, 95, 95, 95, 95, 95, 124, 32, 124, 95, 95, 95, 95, 124,
879  95, 95, 124};
880  Moose::out << std::string(c) << std::endl << std::endl;
881 }
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
const std::string & name() const
Get the name of the object.
Definition: MooseApp.h:106
const ExecFlagType EXEC_FAILED
Definition: Moose.C:40
A MultiMooseEnum object to hold "execute_on" flags.
Definition: ExecFlagEnum.h:21
ExecFlagEnum _execute_on
The common Execution types; this is used as the default execution type for everything except system i...
Definition: Output.h:197
unsigned int _precision
Number of significant digits.
Definition: Console.h:220
void addDeprecatedParam(const std::string &name, const T &value, const std::string &doc_string, const std::string &deprecation_message)
static void petscSetupOutput()
Output string for setting up PETSC output.
Definition: Console.C:810
TimeFormatEnum _time_format
Time format.
Definition: Console.h:223
virtual std::size_t numNonlinearSystems() const override
std::string outputExecutionInformation(const MooseApp &app, FEProblemBase &problem)
Output execution information.
Definition: ConsoleUtils.C:316
MPI_Info info
OutputOnWarehouse _advanced_execute_on
Storage for the individual component execute flags.
Definition: Output.h:274
virtual bool onInterval()
Returns true if the output interval is satisfied.
Definition: Output.C:286
registerMooseObject("MooseApp", Console)
std::string outputAuxiliarySystemInformation(FEProblemBase &problem)
Output the Auxiliary system information.
Definition: ConsoleUtils.C:142
virtual Real dt()
Get the current time step size.
Definition: Output.C:369
DISCRETE_L2
Real & _dt_old
Old time step delta.
Definition: Output.h:220
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
FormattedTable & _postprocessor_table
Table containing postprocessor data.
Definition: TableOutput.h:70
bool _verbose
Flag for writing detailed time step information.
Definition: Console.h:190
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
unsigned int multiAppLevel() const
The MultiApp Level.
Definition: MooseApp.h:812
bool _write_screen
Flag for controlling outputting console information to screen.
Definition: Console.h:187
Storage for action instances.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
std::string _file_base
The base filename from the input paramaters.
Definition: FileOutput.h:89
bool _transient
Transient flag (true = transient)
Definition: Output.h:182
void printInputFile(std::ostream &out)
This method uses the Actions in the warehouse to reproduce the input file.
const ExecFlagType EXEC_TIMESTEP_END
Definition: Moose.C:32
ADRealEigenVector< T, D, asd > sqrt(const ADRealEigenVector< T, D, asd > &)
bool empty() const
Returns a boolean value based on whether the FormattedTable contains data or not. ...
unsigned int multiAppNumber() const
The MultiApp number.
Definition: MooseApp.h:818
std::string outputOutputInformation(MooseApp &app)
Output the output information.
Definition: ConsoleUtils.C:361
bool _allow_changing_sysinfo_flag
A boolean for protecting _system_info_flags from being changed undesirably.
Definition: Console.h:260
PerfLog perflog("libMesh", #ifdef LIBMESH_ENABLE_PERFORMANCE_LOGGING true #else false #endif)
Base class for actions.
Definition: Action.h:38
auto max(const L &left, const R &right)
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
std::string outputMeshInformation(FEProblemBase &problem, bool verbose=true)
Output the mesh information.
Definition: ConsoleUtils.C:55
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
bool _outlier_variable_norms
Flag for writing outlier variable norms.
Definition: Console.h:214
Nonlinear system to be solved.
static MooseEnum getWidthModes()
bool contains(const std::string &value) const
Contains methods for seeing if a value is in the MultiMooseEnum.
const bool _write_all_procs_to_files
Whether to write all processors to files.
Definition: Console.h:226
virtual Real timeOld()
Get the old output time.
Definition: Output.C:360
PetscInt _linear_iter
Current linear iteration returned from PETSc.
Definition: PetscOutput.h:87
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
void indentMessage(const std::string &prefix, std::string &message, const char *color=COLOR_CYAN, bool dont_indent_first_line=true, const std::string &post_prefix=": ")
Indents the supplied message given the prefix and color.
Definition: MooseUtils.C:721
virtual void outputPostprocessors() override
Prints the postprocessor table to the screen.
Definition: Console.C:646
unsigned int n_vars
bool _solve_log
State for solve performance log.
Definition: Console.h:202
FormattedTable & _scalar_table
Table containing scalar aux variables.
Definition: TableOutput.h:79
const ExecFlagType EXEC_TIMESTEP_BEGIN
Definition: Moose.C:33
ExecFlagType _current_execute_flag
Current execute on flag.
Definition: Output.h:205
std::stringstream _file_output_stream
Stream for storing information to be written to a file.
Definition: Console.h:193
void write(std::string message, bool indent=true)
Write message to screen and/or file.
Definition: Console.C:773
virtual void initialSetup() override
Initial setup function Prints the system information, this is done here so that the system informatio...
Definition: Console.C:260
FEProblemBase * _problem_ptr
Pointer the the FEProblemBase object for output object (use this)
Definition: Output.h:179
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
const std::string & type() const
Get the type of this class.
Definition: MooseBase.h:50
const T & getParam(const std::string &name) const
Retrieve a parameter for the object.
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 outputReporters() override
Populates the tables with Reporter values.
Definition: TableOutput.C:111
ActionWarehouse & actionWarehouse()
Return a writable reference to the ActionWarehouse associated with this app.
Definition: MooseApp.h:206
virtual void outputInput() override
Print the input file at the beginning of the simulation.
Definition: Console.C:633
std::string & removeColor(std::string &msg)
remove ANSI escape sequences for terminal color from msg
Definition: MooseUtils.C:705
NonlinearSystemBase & getNonlinearSystemBase(const unsigned int sys_num)
MooseApp & _app
The MOOSE application this is associated with.
Definition: MooseBase.h:69
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
void erase(const std::string &names)
Un-assign a value.
static InputParameters enableOutputTypes(const std::string &names=std::string())
A method for enabling individual output type control.
auto norm(const T &a) -> decltype(std::abs(a))
unsigned int _max_rows
The max number of table rows.
Definition: Console.h:175
const ExecFlagType EXEC_LINEAR
Definition: Moose.C:29
std::string outputFrameworkInformation(const MooseApp &app)
Outputs framework information.
Definition: ConsoleUtils.C:37
Real _norm
Current norm returned from PETSc.
Definition: PetscOutput.h:81
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
Executioner * getExecutioner() const
Retrieve the Executioner for this App.
Definition: MooseApp.C:1482
TimeFormatEnum
Time formatting options.
Definition: Console.h:93
virtual ~Console()
Destructor.
Definition: Console.C:246
virtual void outputPostprocessors() override
Populates the tables with postprocessor values.
Definition: TableOutput.C:86
bool _perf_log
State for all performance logging.
Definition: Console.h:196
bool wantOutput(const std::string &name, const ExecFlagType &type)
Handles logic for determining if a step should be output.
void writeStreamToFile(bool append=true)
Write the file stream to the file.
Definition: Console.C:397
const ExecFlagType EXEC_NONLINEAR
Definition: Moose.C:30
bool isParamSetByUser(const std::string &name) const
Method returns true if the parameter was by the user.
virtual NumericVector< Number > & RHS()=0
std::vector< Real > _outlier_multiplier
Multipliers for coloring variable residual norms (default [2, 0.8])
Definition: Console.h:217
const T & getParam(const std::string &name)
Retrieve a parameter for the object.
Definition: MooseApp.h:1474
void printTable(std::ostream &out, unsigned int last_n_entries=0)
Methods for dumping the table to the stream - either by filename or by stream handle.
virtual void initialSetup()
Call init() method on setup.
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
virtual System & system() override
Get the reference to the libMesh system.
static InputParameters validParams()
Definition: Console.C:30
void push_back(const std::string &names)
Insert operators Operator to insert (push_back) values into the enum.
Real nonlinearNorm() const
Return the last nonlinear norm.
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
IntRange< T > make_range(T beg, T end)
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 & _pars
Parameters of this object, references the InputParameters stored in the InputParametersWarehouse.
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump...
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
FormattedTable & _reporter_table
Table containing Real Reporter values.
Definition: TableOutput.h:82
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an option parameter and a documentation string to the InputParameters object...
const std::vector< std::string > & getInputFileNames() const
Definition: MooseApp.C:1058
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
void sortColumns()
Sorts columns alphabetically.
std::string outputLegacyInformation(MooseApp &app)
Output the legacy flag information.
Definition: ConsoleUtils.C:390
virtual int timeStep()
Get the current time step.
Definition: Output.C:387
std::vector< const T * > getActions()
Retrieve all actions in a specific type ordered by their names.
processor_id_type processor_id() const
std::string outputRelationshipManagerInformation(const MooseApp &app)
Output action RelationshipManager information.
Definition: ConsoleUtils.C:296
void writeTimestepInformation(bool output_dt)
Prints the time step information for the screen output.
Definition: Console.C:424
bool isRecovering() const
Whether or not this is a "recover" calculation.
Definition: MooseApp.C:1167
bool _print_mesh_changed_info
Flag for printing mesh information when the mesh changes.
Definition: Console.h:251
const ExecFlagType EXEC_FINAL
Definition: Moose.C:38
virtual Real getOutputTime()
Get the time that will be used for stream/file outputting.
Definition: PetscOutput.C:265
void ErrorVector unsigned int
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
Meta-action for creating common output object parameters This action serves two purpose, first it adds common output object parameters.
virtual void outputScalarVariables() override
Populates the tables with scalar aux variables.
Definition: TableOutput.C:173
void disable_logging()
PetscInt _nonlinear_iter
Current non-linear iteration returned from PETSc.
Definition: PetscOutput.h:84
void addParamNamesToGroup(const std::string &space_delim_names, const std::string group_name)
This method takes a space delimited list of parameter names and adds them to the specified group name...
std::string outputNonlinearSystemInformation(FEProblemBase &problem, const unsigned int nl_sys_num)
Output the Nonlinear system information.
Definition: ConsoleUtils.C:279
Console(const InputParameters &parameters)
Class constructor.
Definition: Console.C:179
const ExecFlagType EXEC_INITIAL
Definition: Moose.C:28
static InputParameters validParams()
Definition: TableOutput.C:26