https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Console.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
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
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
42 addMultiAppFixedPointIterationEndExecFlag(params, "execute_postprocessors_on");
43 addMultiAppFixedPointIterationEndExecFlag(params, "execute_scalars_on");
44
45 // Screen and file output toggles
46 params.addParam<bool>("output_screen", true, "Output to the screen");
47 params.addParam<bool>("output_file",
48 false,
49 "Output to the file. The default behavior is to write to file only from "
50 "the head processor. If \"--keep-cout\" is passed to the executable, then "
51 "each processor will write to its own file. The same parallel behaviour "
52 "can also be achieved by passing \"--keep-cout --redirect-stdout\" to the "
53 "executable without setting this parameter to true.");
54 params.addParam<bool>(
55 "show_multiapp_name", false, "Indent multiapp output using the multiapp name");
56
57 // Table fitting options
58 params.addParam<unsigned int>("max_rows",
59 15,
60 "The maximum number of postprocessor/scalar values "
61 "displayed on screen during a timestep (set to 0 "
62 "for unlimited)");
63 params.addParam<MooseEnum>("fit_mode",
64 pps_fit_mode,
65 "Specifies the wrapping mode for post-processor tables that are "
66 "printed to the screen (ENVIRONMENT: Read \"MOOSE_PPS_WIDTH\" for "
67 "desired width (if not set, defaults to AUTO), AUTO: Attempt to "
68 "determine width automatically (serial only), <n>: Desired width");
69
70 // Verbosity
71 params.addParam<bool>("verbose", false, "Print detailed diagnostics on timestep calculation");
72
73 // Basic table output controls
74 params.addParam<bool>(
75 "scientific_time", false, "Control the printing of time and dt in scientific notation");
76 params.addParam<unsigned int>(
77 "time_precision",
78 "The number of significant digits that are printed on time related outputs");
79 MooseEnum time_format("plain=0 second=1 minute=2 hour=3 day=4 dtime=5", "plain");
80 params.addParam<MooseEnum>(
81 "time_format",
82 time_format,
83 "The format for the printed times ('dtime' means a format like 1d 01:01:0.1)");
84
85 // Performance Logging
86 params.addDeprecatedParam<bool>("perf_log",
87 false,
88 "If true, all performance logs will be printed. The "
89 "individual log settings will override this option.",
90 "Use PerfGraphOutput");
91 params.addDeprecatedParam<unsigned int>(
92 "perf_log_interval",
93 0,
94 "If set, the performance log will be printed every n time steps",
95 "Use PerfGraphOutput instead");
96 params.addParam<bool>("solve_log", "Toggles the printing of the 'Moose Test Performance' log");
97 params.addDeprecatedParam<bool>(
98 "perf_header",
99 "Print the libMesh performance log header (requires that 'perf_log = true')",
100 "Use PerfGraphOutput instead");
101
102 params.addParam<bool>(
103 "libmesh_log",
104 true,
105 "Print the libMesh performance log, requires libMesh to be configured with --enable-perflog");
106
107 // Toggle printing of mesh information on adaptivity steps
108 params.addParam<bool>("print_mesh_changed_info",
109 false,
110 "When true, each time the mesh is changed the mesh information is printed");
111
112 // Toggle for printing variable norms
113 params.addParam<bool>("outlier_variable_norms",
114 true,
115 "If true, outlier variable norms will be printed after each solve");
116 params.addParam<bool>(
117 "all_variable_norms", false, "If true, all variable norms will be printed after each solve");
118
119 // Multipliers for coloring of variable residual norms
120 std::vector<Real> multiplier;
121 multiplier.push_back(0.8);
122 multiplier.push_back(2);
123 params.addParam<std::vector<Real>>("outlier_multiplier",
124 multiplier,
125 "Multiplier utilized to determine if a residual norm is an "
126 "outlier. If the variable residual is less than "
127 "multiplier[0] times the total residual it is colored red. "
128 "If the variable residual is less than multiplier[1] times "
129 "the average residual it is colored yellow.");
130
131 // System information controls
132 MultiMooseEnum info("framework mesh aux nonlinear linear relationship execution output",
133 "framework mesh aux nonlinear linear execution");
134 params.addParam<MultiMooseEnum>("system_info",
135 info,
136 "List of information types to display "
137 "('framework', 'mesh', 'aux', 'nonlinear', 'relationship', "
138 "'execution', 'output')");
139
140 // Advanced group
141 params.addParamNamesToGroup("verbose show_multiapp_name system_info", "Advanced");
142
143 // Performance log group
144 params.addParamNamesToGroup("perf_log solve_log perf_header libmesh_log", "Perf Log");
145
146 // Variable norms group
147 params.addParamNamesToGroup("outlier_variable_norms all_variable_norms outlier_multiplier",
148 "Variable and Residual Norms");
149
150 // Number formatting
151 params.addParamNamesToGroup("scientific_time time_precision time_format",
152 "Time output formatting");
153
154 // Table of postprocessor output formatting
155 params.addParamNamesToGroup("max_rows fit_mode", "Table formatting");
156
157 /*
158 * The following modifies the default behavior from base class parameters. Notice the extra flag
159 * on
160 * the set method. This enables "quiet mode". This is done to allow for the proper detection
161 * of user-modified parameters
162 */
163 // By default set System Information to output on initial
164 params.set<ExecFlagEnum>("execute_system_information_on", /*quite_mode=*/true) = EXEC_INITIAL;
165
166 // Change the default behavior of 'execute_on' to included nonlinear iterations and failed
167 // timesteps
168 params.set<ExecFlagEnum>("execute_on", /*quiet_mode=*/true) = {EXEC_INITIAL,
174
175 // By default postprocessors and scalar are only output at the end of a timestep
176 params.set<ExecFlagEnum>("execute_postprocessors_on", /*quiet_mode=*/true) = {EXEC_INITIAL,
178 params.set<ExecFlagEnum>("execute_vector_postprocessors_on",
179 /*quiet_mode=*/true) = {EXEC_INITIAL, EXEC_TIMESTEP_END};
180 params.set<ExecFlagEnum>("execute_scalars_on", /*quiet_mode=*/true) = {EXEC_INITIAL,
182 params.set<ExecFlagEnum>("execute_reporters_on", /*quiet_mode=*/true) = {EXEC_INITIAL,
184 return params;
185}
186
188 : TableOutput(parameters),
189 _max_rows(getParam<unsigned int>("max_rows")),
190 _fit_mode(getParam<MooseEnum>("fit_mode")),
191 _scientific_time(getParam<bool>("scientific_time")),
192 _write_file(getParam<bool>("output_file")),
193 _write_screen(getParam<bool>("output_screen")),
194 _verbose(getParam<bool>("verbose")),
195 _perf_log(getParam<bool>("perf_log")),
196 _perf_log_interval(getParam<unsigned int>("perf_log_interval")),
197 _solve_log(isParamValid("solve_log") ? getParam<bool>("solve_log") : _perf_log),
198 _libmesh_log(getParam<bool>("libmesh_log")),
199 _perf_header(isParamValid("perf_header") ? getParam<bool>("perf_header") : _perf_log),
200 _all_variable_norms(getParam<bool>("all_variable_norms")),
201 _outlier_variable_norms(getParam<bool>("outlier_variable_norms")),
202 _outlier_multiplier(getParam<std::vector<Real>>("outlier_multiplier")),
203 _precision(isParamValid("time_precision") ? getParam<unsigned int>("time_precision") : 0),
204 _time_format(getParam<MooseEnum>("time_format").getEnum<TimeFormatEnum>()),
205 _write_all_procs_to_files(_app.getParam<bool>("keep_cout")),
206 _console_buffer(_app.getOutputWarehouse().consoleBuffer()),
207 _old_linear_norm(std::numeric_limits<Real>::max()),
208 _old_nonlinear_norm(std::numeric_limits<Real>::max()),
209 _print_mesh_changed_info(getParam<bool>("print_mesh_changed_info")),
210 _system_info_flags(getParam<MultiMooseEnum>("system_info")),
211 _allow_changing_sysinfo_flag(true),
212 _last_message_ended_in_newline(true)
213{
214 // Apply the special common console flags (print_...)
216 const auto actions = awh.getActions<CommonOutputAction>();
217 mooseAssert(actions.size() <= 1, "Should not be more than one CommonOutputAction");
218 const Action * common = actions.empty() ? nullptr : *actions.begin();
219
220 if (!parameters.isParamSetByUser("execute_on"))
221 {
222 // Honor the 'print_linear_residuals' option, only if 'linear' has not been set in 'execute_on'
223 // by the user
224 if (common && common->getParam<bool>("print_linear_residuals"))
226 else
227 _execute_on.eraseSetValue("linear");
228 if (common && common->getParam<bool>("print_nonlinear_residuals"))
229 _execute_on.setAdditionalValue("nonlinear");
230 else
231 _execute_on.eraseSetValue("nonlinear");
232 }
233
234 if (!_pars.isParamSetByUser("perf_log") && common && common->getParam<bool>("print_perf_log"))
235 {
236 _perf_log = true;
237 _solve_log = true;
238 }
239
240 // If --show-outputs is used, enable it
241 if (_app.getParam<bool>("show_outputs"))
243}
244
246{
247 // Write the libMesh log
248 if (_libmesh_log)
249 write(libMesh::perflog.get_perf_info(), false);
250
251 // Write the file output stream
253
254 // Disable logging so that the destructor in libMesh doesn't print
256}
257
258void
260{
261 // Only allow the main app to change the perf_log settings.
262 if (_app.name() == "main")
263 {
264 // Disable libMesh log
265 if (!_libmesh_log)
267 }
268
269 // system info flag can be changed only before console initial setup
271
272 // If execute_on = 'initial' perform the output
273 if (wantOutput("system_information", EXEC_INITIAL))
275
276 // Call the base class method
278
279 // If file output is desired, wipe out the existing file if not recovering
280 if (!_app.isRecovering())
281 writeStreamToFile(false);
282
283 // Enable verbose output if Executioner has it enabled
284 if (_app.getExecutioner()->isParamValid("verbose") &&
285 _app.getExecutioner()->getParam<bool>("verbose"))
286 _verbose = true;
287
288 // If the user explicitly set execute_on but did not set a type-specific flag,
289 // replace that type's schedule with the user's execute_on so the two are consistent.
290 if (_pars.isParamSetByUser("execute_on"))
291 {
292 if (!_pars.isParamSetByUser("execute_postprocessors_on"))
293 _advanced_execute_on["postprocessors"] = _execute_on;
294 if (!_pars.isParamSetByUser("execute_scalars_on"))
296 if (!_pars.isParamSetByUser("execute_vector_postprocessors_on"))
297 _advanced_execute_on["vector_postprocessors"] = _execute_on;
298 if (!_pars.isParamSetByUser("execute_reporters_on"))
299 _advanced_execute_on["reporters"] = _execute_on;
300 }
301}
302
303std::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
317void
319{
320 writeTimestepInformation(/*output_dt = */ true);
321}
322
323void
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)
357 _old_nonlinear_norm = std::numeric_limits<Real>::max();
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)
369 _old_linear_norm = std::numeric_limits<Real>::max();
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))
389
390 // Write the file
392
393 _console << std::flush;
394}
395
396void
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
423void
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
471std::string
472Console::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;
481 oss << std::scientific;
482
484 oss << t;
486 oss << t << "s";
488 oss << t / 60 << "m";
490 oss << t / 3600 << "h";
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;
522 oss << std::scientific;
523 oss << second;
524 }
525 else if (days == 0)
526 oss << "0s";
527 }
528 return oss.str();
529}
530
531void
533{
534 // If all_variable_norms is true, then so should outlier printing
537
538 // if we are not priting anything, let's not waste time computing the norms below and just exit
539 // this call
540 if ((_all_variable_norms == false) && (_outlier_variable_norms == false))
541 return;
542
543 // if it is an eigenvalue prolblem, we do not know to define RHS,
544 // and then we do not know how to compute variable norms
545 if (dynamic_cast<EigenProblem *>(_problem_ptr) != nullptr)
546 return;
547
548 // Flag set when header prints
549 bool header = false;
550
551 // String stream for variable norm information
552 std::ostringstream oss;
553
554 for (const auto i : make_range(_problem_ptr->numNonlinearSystems()))
555 {
556 // Get a references to the NonlinearSystem and libMesh system
558 System & sys = nl.system();
559
560 // Storage for norm outputs
561 std::map<std::string, Real> other;
562 std::map<std::string, Real> outlier;
563
564 // Average norm
565 unsigned int n_vars = sys.n_vars();
566 Real avg_norm = (nl.nonlinearNorm() * nl.nonlinearNorm()) / n_vars;
567
568 // Compute the norms for each of the variables
569 for (unsigned int i = 0; i < n_vars; i++)
570 {
571 // Compute the norm and extract the variable name
572 Real var_norm = sys.calculate_norm(nl.RHS(), i, DISCRETE_L2);
573 var_norm *= var_norm; // use the norm squared
574 std::string var_name = sys.variable_name(i);
575
576 // Outlier if the variable norm is greater than twice (default) of the average norm
577 if (_outlier_variable_norms && (var_norm > _outlier_multiplier[1] * avg_norm))
578 {
579 // Print the header
580 if (!header)
581 {
582 oss << "\nOutlier Variable Residual Norms:\n";
583 header = true;
584 }
585
586 // Set the color, RED if the variable norm is 0.8 (default) of the total norm
587 std::string color = COLOR_YELLOW;
588 if (_outlier_variable_norms && (var_norm > _outlier_multiplier[0] * avg_norm * n_vars))
589 color = COLOR_RED;
590
591 // Display the residual
592 oss << " " << var_name << ": " << std::scientific << color << std::sqrt(var_norm)
593 << COLOR_DEFAULT << '\n';
594 }
595
596 // GREEN
597 else if (_all_variable_norms)
598 {
599 // Print the header if it doesn't already exist
600 if (!header)
601 {
602 oss << "\nVariable Residual Norms:\n";
603 header = true;
604 }
605 oss << " " << var_name << ": " << std::scientific << COLOR_GREEN << std::sqrt(var_norm)
606 << COLOR_DEFAULT << '\n';
607 }
608 }
609 }
610
611 // Update the output streams
612 _console << oss.str() << std::flush;
613}
614
615// Quick helper to output the norm in color
616std::string
617Console::outputNorm(const Real & old_norm, const Real & norm, const unsigned int precision)
618{
619 std::string color = COLOR_GREEN;
620
621 // Red if the residual went up... or if the norm is nan
622 if (norm != norm || norm > old_norm)
623 color = COLOR_RED;
624 // Yellow if change is less than 5%
625 else if ((old_norm - norm) / old_norm <= 0.05)
626 color = COLOR_YELLOW;
627
628 std::stringstream oss;
629 oss << std::scientific << std::setprecision(precision) << color << norm << COLOR_DEFAULT;
630
631 return oss.str();
632}
633
634void
636{
637 if (!_write_screen && !_write_file)
638 return;
639
640 std::ostringstream oss;
641 for (const auto & filename : _app.getInputFileNames())
642 oss << "--- " << filename << "\n";
644 _console << oss.str() << std::endl;
645}
646
647void
649{
651
653 {
654 std::stringstream oss;
655 oss << "\nPostprocessor Values:\n";
658 _console << oss.str() << std::endl;
659 }
660}
661
662void
664{
666
667 if (!_reporter_table.empty())
668 {
669 std::stringstream oss;
670 oss << "\nReporter Values:\n";
673 _console << oss.str() << '\n';
674 }
675}
676
677void
679{
681
682 if (!_scalar_table.empty())
683 {
684 std::stringstream oss;
685 oss << "\nScalar Variable Values:\n";
686 if (processor_id() == 0)
687 {
690 }
691 _console << oss.str() << std::endl;
692 }
693}
694
695void
697{
698 // skip system information output for sub-apps other than the zero-th of a MultiApp
699 // because they are using the same inputs and are most likely having the same information.
700 if (_app.multiAppNumber() > 0)
701 return;
702
703 if (_system_info_flags.isValueSet("framework"))
705
706 if (_system_info_flags.isValueSet("mesh"))
708
709 if (_system_info_flags.isValueSet("nonlinear"))
710 {
711 for (const auto i : make_range(_problem_ptr->numNonlinearSystems()))
712 {
714 if (!output.empty())
715 {
716 _console << "Nonlinear System";
718 _console << " [" + _problem_ptr->getNonlinearSystemNames()[i] + "]";
719 _console << ":\n" << output;
720 }
721 }
722 }
723
724 if (_system_info_flags.isValueSet("linear"))
725 for (const auto i : make_range(_problem_ptr->numLinearSystems()))
726 {
729 if (!output.empty())
730 _console << "Linear System" +
731 (_problem_ptr->numLinearSystems() > 1 ? (" " + std::to_string(i)) : "") +
732 ":\n"
733 << output;
734 }
735
737 {
739 if (!output.empty())
740 _console << "Auxiliary System:\n" << output;
741 }
742
743 if (_system_info_flags.isValueSet("relationship"))
744 {
746 if (!output.empty())
747 _console << "Relationship Managers:\n" << output;
748 }
749
750 if (_system_info_flags.isValueSet("execution"))
752
753 if (_app.getParam<bool>("show_data_paths"))
755
756 if (_app.getParam<bool>("show_data_params"))
758
759 if (_system_info_flags.isValueSet("output"))
761
762 if (!_app.getParam<bool>("use_legacy_initial_residual_evaluation_behavior"))
763 for (const auto i : make_range(_problem_ptr->numNonlinearSystems()))
765 {
767 break;
768 }
769
770 // Output the legacy flags, these cannot be turned off so they become annoying to people.
772
773 _console << std::flush;
774}
775
776void
778{
780 {
782
783 std::string output;
784 for (const auto i : make_range(_problem_ptr->numNonlinearSystems()))
785 {
787 if (!output.empty())
788 {
789 _console << "Nonlinear System";
791 _console << " [" + _problem_ptr->getNonlinearSystemNames()[i] + "]";
792 _console << ":\n" << output;
793 }
794 }
795
796 for (const auto i : make_range(_problem_ptr->numLinearSystems()))
797 {
800 if (!output.empty())
801 _console << "Linear System" +
802 (_problem_ptr->numLinearSystems() > 1 ? (" " + std::to_string(i)) : "") +
803 ":\n"
804 << output;
805 }
806
808 if (!output.empty())
809 _console << "Auxiliary System:\n" << output;
810
811 _console << std::flush;
812 }
813}
814
815void
816Console::write(std::string message, bool indent /*=true*/)
817{
818 // Do nothing if the message is empty, writing empty strings messes with multiapp indenting
819 if (message.empty())
820 return;
821
822 // Write the message to file
823 if (_write_file)
824 _file_output_stream << message;
825
826 // The empty case gets the right behavior, even though the boolean is technically wrong
827 bool this_message_ends_in_newline = message.empty() ? true : (message.back() == '\n');
828 bool this_message_starts_with_newline = message.empty() ? true : (message.front() == '\n');
829
830 // Apply MultiApp indenting
831 if ((this_message_starts_with_newline || _last_message_ended_in_newline) && indent &&
832 _app.multiAppLevel() > 0)
834
835 // Write message to the screen
836 if (_write_screen)
837 Moose::out << message;
838
839 _last_message_ended_in_newline = this_message_ends_in_newline;
840}
841
842void
843Console::mooseConsole(const std::string & message)
844{
845 // Write the messages
846 write(message);
847
848 // Flush the stream to the screen
849 Moose::out << std::flush;
850}
851
852void
854{
855 char c[] = {
856 32, 47, 94, 92, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
857 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
858 32, 32, 32, 32, 32, 32, 32, 47, 94, 92, 13, 10, 124, 32, 32, 32, 92, 95, 47,
859 94, 92, 32, 32, 32, 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, 32, 32, 32, 47, 94, 92, 95, 47,
861 32, 32, 32, 124, 13, 10, 124, 32, 32, 32, 32, 32, 32, 32, 32, 92, 95, 47, 94,
862 92, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
863 32, 32, 32, 47, 94, 92, 95, 47, 32, 32, 32, 32, 32, 32, 32, 32, 124, 13, 10,
864 32, 92, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 92, 95, 47, 94, 92,
865 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 47, 94, 92, 95, 47, 32, 32, 32,
866 32, 32, 32, 32, 32, 32, 32, 32, 32, 47, 13, 10, 32, 32, 92, 95, 95, 32, 32,
867 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 92, 95, 95, 95, 45, 45, 45,
868 95, 95, 95, 47, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 95,
869 95, 47, 13, 10, 32, 32, 32, 32, 32, 45, 45, 45, 95, 95, 95, 32, 32, 32, 32,
870 32, 32, 32, 32, 32, 47, 32, 32, 32, 32, 32, 32, 32, 92, 32, 32, 32, 32, 32,
871 32, 32, 32, 32, 95, 95, 95, 45, 45, 45, 13, 10, 32, 32, 32, 32, 32, 32, 32,
872 32, 32, 32, 32, 45, 45, 45, 95, 95, 95, 32, 32, 124, 32, 32, 32, 32, 32, 32,
873 32, 32, 32, 124, 32, 32, 95, 95, 95, 45, 45, 45, 13, 10, 32, 32, 32, 32, 32,
874 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 45, 45, 124, 32, 32, 95, 32,
875 32, 32, 95, 32, 32, 124, 45, 45, 13, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32,
876 32, 32, 32, 32, 32, 32, 32, 32, 32, 124, 32, 32, 124, 111, 124, 32, 124, 111, 124,
877 32, 32, 124, 13, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
878 32, 32, 32, 47, 32, 32, 32, 32, 45, 32, 32, 32, 45, 32, 32, 32, 32, 92, 13,
879 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 124, 32,
880 32, 32, 32, 32, 32, 95, 95, 95, 32, 32, 32, 32, 32, 32, 124, 13, 10, 32, 32,
881 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 47, 32, 32, 32, 32, 32,
882 45, 45, 32, 32, 32, 45, 45, 32, 32, 32, 32, 32, 92, 13, 10, 32, 32, 32, 32,
883 32, 32, 32, 32, 32, 32, 32, 32, 32, 47, 32, 32, 32, 32, 32, 32, 32, 32, 32,
884 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 92, 13, 10, 32, 32, 32, 32,
885 32, 32, 32, 32, 32, 32, 32, 32, 124, 32, 32, 32, 32, 32, 32, 32, 47, 92, 32,
886 32, 32, 32, 32, 47, 92, 32, 32, 32, 32, 32, 32, 32, 124, 13, 10, 32, 32, 32,
887 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 92, 32, 32, 92, 32, 32, 32, 32, 32,
888 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 47, 32, 32, 47, 13, 10, 32, 32, 32,
889 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 47, 92, 32, 32, 92, 95, 95, 95, 95,
890 95, 95, 95, 95, 95, 95, 95, 95, 32, 47, 32, 32, 47, 92, 13, 10, 32, 32, 32,
891 32, 32, 32, 32, 32, 32, 32, 32, 32, 47, 32, 32, 92, 32, 32, 32, 32, 32, 32,
892 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 47, 32, 32, 92, 13, 10, 32, 32,
893 32, 32, 32, 32, 32, 32, 32, 32, 32, 47, 32, 32, 32, 32, 92, 32, 32, 32, 32,
894 32, 39, 95, 95, 95, 39, 32, 32, 32, 32, 32, 47, 32, 32, 32, 32, 92, 13, 10,
895 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 47, 92, 32, 32, 32, 32, 32, 92, 32,
896 45, 45, 95, 95, 45, 45, 45, 95, 95, 45, 45, 32, 47, 32, 32, 32, 32, 32, 47,
897 92, 13, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 47, 32, 32, 92, 47, 32, 32,
898 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
899 92, 47, 32, 32, 92, 13, 10, 32, 32, 32, 32, 32, 32, 32, 32, 47, 32, 32, 32,
900 47, 32, 32, 32, 32, 32, 32, 32, 77, 46, 79, 46, 79, 46, 83, 46, 69, 32, 32,
901 32, 32, 32, 32, 32, 92, 32, 32, 32, 92, 13, 10, 32, 32, 32, 32, 32, 32, 32,
902 47, 32, 32, 32, 124, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
903 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 124, 32, 32, 32, 92, 13, 10, 32,
904 32, 32, 32, 32, 32, 124, 32, 32, 32, 32, 124, 45, 45, 45, 45, 45, 45, 45, 45,
905 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 124, 32,
906 32, 32, 32, 124, 13, 10, 32, 32, 32, 32, 32, 32, 32, 92, 32, 32, 32, 32, 92,
907 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
908 32, 32, 32, 32, 47, 32, 32, 32, 32, 47, 13, 10, 32, 32, 32, 32, 32, 32, 32,
909 32, 32, 92, 92, 32, 92, 95, 92, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
910 32, 32, 32, 32, 32, 32, 32, 32, 47, 95, 47, 32, 47, 47, 13, 10, 32, 32, 32,
911 32, 32, 32, 32, 32, 32, 32, 32, 45, 45, 32, 32, 92, 32, 32, 32, 32, 32, 32,
912 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 47, 32, 32, 45, 45, 13, 10, 32,
913 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 124, 32, 32, 45,
914 45, 45, 95, 95, 95, 95, 95, 45, 45, 45, 32, 32, 124, 13, 10, 32, 32, 32, 32,
915 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 124, 32, 32, 32, 32, 32, 124,
916 32, 32, 32, 124, 32, 32, 32, 32, 32, 124, 13, 10, 32, 32, 32, 32, 32, 32, 32,
917 32, 32, 32, 32, 32, 32, 32, 32, 32, 124, 32, 32, 32, 32, 32, 124, 32, 32, 32,
918 124, 32, 32, 32, 32, 32, 124, 13, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
919 32, 32, 32, 32, 32, 47, 32, 86, 32, 32, 32, 32, 32, 92, 32, 47, 32, 32, 32,
920 32, 86, 32, 32, 92, 13, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
921 32, 32, 32, 124, 95, 124, 95, 95, 95, 95, 95, 124, 32, 124, 95, 95, 95, 95, 124,
922 95, 95, 124};
923 Moose::out << std::string(c) << std::endl << std::endl;
924}
registerMooseObject("MooseApp", Console)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
const ExecFlagType EXEC_TIMESTEP_END
Definition Moose.C:37
const ExecFlagType EXEC_TIMESTEP_BEGIN
Definition Moose.C:38
const ExecFlagType EXEC_INITIAL
Definition Moose.C:31
const ExecFlagType EXEC_LINEAR
Definition Moose.C:32
const ExecFlagType EXEC_NONLINEAR
Definition Moose.C:34
const ExecFlagType EXEC_FAILED
Definition Moose.C:51
const ExecFlagType EXEC_FINAL
Definition Moose.C:49
unsigned int n_vars
void ErrorVector unsigned int
Storage for action instances.
void printInputFile(std::ostream &out)
This method uses the Actions in the warehouse to reproduce the input file.
std::vector< const T * > getActions()
Retrieve all actions in a specific type ordered by their names.
Base class for actions.
Definition Action.h:38
static InputParameters enableOutputTypes(const std::string &names=std::string())
A method for enabling individual output type control.
bool wantOutput(const std::string &name, const ExecFlagType &type)
Handles logic for determining if a step should be output.
friend class Console
Meta-action for creating common output object parameters This action serves two purpose,...
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.
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 outputPostprocessors() override
Prints the postprocessor table to the screen.
Definition Console.C:648
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:245
bool _scientific_time
Toggle for outputting time in time and dt in scientific notation.
Definition Console.h:181
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:424
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
void mooseConsole(const std::string &message)
Add a message to the output streams.
Definition Console.C:843
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:816
static InputParameters validParams()
Definition Console.C:30
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:777
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:635
virtual void outputScalarVariables() override
Prints the aux scalar variables table to the screen.
Definition Console.C:678
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
std::string formatTime(const Real t) const
A help function to format a time.
Definition Console.C:472
virtual void initialSetup() override
Initial setup function Prints the system information, this is done here so that the system informatio...
Definition Console.C:259
void writeVariableNorms()
Print the L2-norms for each variable.
Definition Console.C:532
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:617
MooseEnum _fit_mode
The FormattedTable fit mode.
Definition Console.h:178
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:696
virtual std::string filename() override
Creates the output file name Appends the user-supplied 'file_base' input parameter with a '....
Definition Console.C:304
static void petscSetupOutput()
Output string for setting up PETSC output.
Definition Console.C:853
virtual void outputReporters() override
Prints the Reporter values to the screen.
Definition Console.C:663
void writeStreamToFile(bool append=true)
Write the file stream to the file.
Definition Console.C:397
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 _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
Problem for solving eigenvalue problems.
A MultiMooseEnum object to hold "execute_on" flags.
virtual std::size_t numLinearSystems() const override
virtual std::size_t numNonlinearSystems() const override
const std::vector< NonlinearSystemName > & getNonlinearSystemNames() const
NonlinearSystemBase & getNonlinearSystemBase(const unsigned int sys_num)
std::string _file_base
The base filename from the input paramaters.
Definition FileOutput.h:89
static MooseEnum getWidthModes()
bool empty() const
Returns a boolean value based on whether the FormattedTable contains data or not.
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.
void sortColumns()
Sorts columns alphabetically.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
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...
bool isParamSetByUser(const std::string &name) const
Method returns true if the parameter was set by the user.
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object.
void addDeprecatedParam(const std::string &name, const T &value, const std::string &doc_string, const std::string &deprecation_message)
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.
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
const std::vector< std::string > & getInputFileNames() const
Definition MooseApp.C:1524
ActionWarehouse & actionWarehouse()
Return a writable reference to the ActionWarehouse associated with this app.
Definition MooseApp.h:217
unsigned int multiAppLevel() const
The MultiApp Level.
Definition MooseApp.h:855
unsigned int multiAppNumber() const
The MultiApp number.
Definition MooseApp.h:861
Executioner * getExecutioner() const
Retrieve the Executioner for this App.
Definition MooseApp.C:2021
bool isRecovering() const
Whether or not this is a "recover" calculation.
Definition MooseApp.C:1675
const InputParameters & parameters() const
Get the parameters of the object.
Definition MooseBase.h:131
const std::string & type() const
Get the type of this class.
Definition MooseBase.h:93
const std::string & name() const
Get the name of the class.
Definition MooseBase.h:103
const InputParameters & _pars
The object's parameters.
Definition MooseBase.h:384
const T & getParam(const std::string &name) const
Retrieve a parameter for the object.
Definition MooseBase.h:406
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
Definition MooseBase.h:199
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition MooseEnum.h:55
MooseApp & _app
The MOOSE application this is associated with.
Definition MooseBase.h:375
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type.
void eraseSetValue(const std::string &names)
Un-assign, or unset a value.
void setAdditionalValue(const std::string &names)
Insert operators Operator to insert (push_back) values into the enum.
bool isValueSet(const std::string &value) const
Methods for seeing if a value is set in the MultiMooseEnum.
Nonlinear system to be solved.
Real nonlinearNorm() const
Return the last nonlinear norm.
virtual NumericVector< Number > & RHS()=0
virtual libMesh::System & system() override
Get the reference to the libMesh system.
const bool & usePreSMOResidual() const
Whether we are using pre-SMO residual in relative convergence checks.
Real & _dt_old
Old time step delta.
Definition Output.h:226
ExecFlagEnum _execute_on
The common Execution types; this is used as the default execution type for everything except system i...
Definition Output.h:203
FEProblemBase * _problem_ptr
Pointer the the FEProblemBase object for output object (use this)
Definition Output.h:185
virtual int timeStep()
Get the current time step.
Definition Output.C:387
ExecFlagType _current_execute_flag
Current execute on flag.
Definition Output.h:211
virtual Real timeOld()
Get the old output time.
Definition Output.C:360
virtual bool onInterval()
Returns true if the output interval is satisfied.
Definition Output.C:280
bool _transient
Transient flag (true = transient)
Definition Output.h:188
virtual Real dt()
Get the current time step size.
Definition Output.C:369
OutputOnWarehouse _advanced_execute_on
Storage for the individual component execute flags.
Definition Output.h:277
PetscInt _nonlinear_iter
Current non-linear iteration returned from PETSc.
Definition PetscOutput.h:84
Real _norm
Current norm returned from PETSc.
Definition PetscOutput.h:81
virtual Real getOutputTime()
Get the time that will be used for stream/file outputting.
PetscInt _linear_iter
Current linear iteration returned from PETSc.
Definition PetscOutput.h:87
virtual void initialSetup()
Gets called at the beginning of the simulation before this object is asked to do its job.
Base class for scalar variables and postprocessors output objects.
Definition TableOutput.h:29
virtual void outputScalarVariables() override
Populates the tables with scalar aux variables.
FormattedTable & _reporter_table
Table containing Real Reporter values.
static void addMultiAppFixedPointIterationEndExecFlag(InputParameters &params, const std::string &param)
Adds the exec flag MULTIAPP_FIXED_POINT_ITERATION_END to a parameter.
Definition TableOutput.C:71
FormattedTable & _scalar_table
Table containing scalar aux variables.
Definition TableOutput.h:98
virtual void outputReporters() override
Populates the tables with Reporter values.
static InputParameters validParams()
Definition TableOutput.C:26
virtual void outputPostprocessors() override
Populates the tables with postprocessor values.
FormattedTable & _postprocessor_table
Table containing postprocessor data.
Definition TableOutput.h:89
processor_id_type processor_id() const
void disable_logging()
std::string outputOutputInformation(MooseApp &app)
Output the output information.
std::string outputPreSMOResidualInformation()
Output the information about pre-SMO residual evaluation.
std::string outputLegacyInformation(MooseApp &app)
Output the legacy flag information.
std::string outputMeshInformation(FEProblemBase &problem, bool verbose=true)
Output the mesh information.
std::string outputSolverSystemInformation(FEProblemBase &problem, const unsigned int solver_sys_num)
Output a solver system information.
std::string outputAuxiliarySystemInformation(FEProblemBase &problem)
Output the Auxiliary system information.
std::string outputDataFilePaths()
Output the registered data paths for searching.
std::string outputExecutionInformation(const MooseApp &app, FEProblemBase &problem)
Output execution information.
std::string outputDataFileParams(MooseApp &app)
Output the (param path = value) pairs for each DataFileName parameter.
std::string outputRelationshipManagerInformation(const MooseApp &app)
Output action RelationshipManager information.
std::string outputFrameworkInformation(const MooseApp &app)
Outputs framework information.
std::string & removeColor(std::string &msg)
Definition MooseUtils.C:733
void indentMessage(const std::string &prefix, std::string &message, const char *color, bool indent_first_line, const std::string &post_prefix)
Definition MooseUtils.C:749
PerfLog perflog("libMesh", #ifdef LIBMESH_ENABLE_PERFORMANCE_LOGGING true #else false #endif)