LCOV - code coverage report
Current view: top level - include/outputs - Console.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 0 2 0.0 %
Date: 2025-07-17 01:28:37 Functions: 0 1 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : 
      15             : /**
      16             :  * An output object for writing to the console (screen)
      17             :  */
      18             : class Console : public TableOutput
      19             : {
      20             : public:
      21             :   static InputParameters validParams();
      22             : 
      23             :   /**
      24             :    * Class constructor
      25             :    */
      26             :   Console(const InputParameters & parameters);
      27             : 
      28             :   /**
      29             :    * Destructor
      30             :    */
      31             :   virtual ~Console();
      32             : 
      33             :   /**
      34             :    * Initial setup function
      35             :    * Prints the system information, this is done here so that the system information
      36             :    * is printed prior to any PETSc solve information
      37             :    */
      38             :   virtual void initialSetup() override;
      39             : 
      40             :   virtual void timestepSetup() override;
      41             : 
      42             :   /**
      43             :    * Customizes the order of output for the various components as well as adds additional
      44             :    * output such as timestep information and nonlinear/linear residual information
      45             :    *
      46             :    * This method explicitly re-implements portions of AdvancedOutput::output, which is generally not
      47             :    * recommended. This is done here to get the output ordering desired. If additional output types
      48             :    * (e.g., elemental or nodal) are required in the future this calls will need to be explicitly
      49             :    * added
      50             :    * as well.
      51             :    */
      52             :   virtual void output() override;
      53             : 
      54             :   /**
      55             :    * Creates the output file name
      56             :    * Appends the user-supplied 'file_base' input parameter with a '.txt' extension
      57             :    * @return A string containing the output filename
      58             :    */
      59             :   virtual std::string filename() override;
      60             : 
      61             :   /**
      62             :    * Output string for setting up PETSC output
      63             :    */
      64             :   static void petscSetupOutput();
      65             : 
      66             :   /**
      67             :    * Performs console related printing when the mesh is changed
      68             :    */
      69             :   void meshChanged() override;
      70             : 
      71             :   /**
      72             :    * A helper function for outputting norms in color
      73             :    * @param old_norm The old residual norm to compare against
      74             :    * @param norm The current residual norm
      75             :    */
      76             :   static std::string
      77             :   outputNorm(const Real & old_norm, const Real & norm, const unsigned int precision = 6);
      78             : 
      79             :   /**
      80             :    * Return system information flags
      81             :    */
      82             :   MultiMooseEnum & systemInfoFlags()
      83             :   {
      84             :     if (!_allow_changing_sysinfo_flag)
      85             :       mooseError(
      86             :           "accessing console system information flags is not allowed after console initial setup");
      87             :     return _system_info_flags;
      88             :   }
      89             : 
      90             :   /**
      91             :    * Time formatting options
      92             :    */
      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             : 
     103             :   /**
     104             :    * A reference to the time format to allow callers to set a new format for this console object
     105             :    */
     106             :   TimeFormatEnum & timeFormat() { return _time_format; }
     107             : 
     108             : protected:
     109             :   /**
     110             :    * Print the input file at the beginning of the simulation
     111             :    */
     112             :   virtual void outputInput() override;
     113             : 
     114             :   /**
     115             :    * Prints the aux scalar variables table to the screen
     116             :    */
     117             :   virtual void outputScalarVariables() override;
     118             : 
     119             :   /**
     120             :    * Prints the postprocessor table to the screen
     121             :    */
     122             :   virtual void outputPostprocessors() override;
     123             : 
     124             :   /**
     125             :    * Not implemented.
     126             :    */
     127           0 :   virtual void outputVectorPostprocessors() override
     128             :   {
     129           0 :     mooseError("Can't currently output VectorPostprocessors to the screen");
     130             :   };
     131             : 
     132             :   /**
     133             :    * Prints the Reporter values to the screen
     134             :    */
     135             :   virtual void outputReporters() override;
     136             : 
     137             :   /**
     138             :    * Print system information
     139             :    */
     140             :   virtual void outputSystemInformation() override;
     141             : 
     142             :   /**
     143             :    * Prints the time step information for the screen output. The Boolean controls whether the dt is
     144             :    * output. It doesn't really make sense to output this quantity the first time since it's a delta
     145             :    * quantity indicating the step size from the previous step.
     146             :    */
     147             :   void writeTimestepInformation(bool output_dt);
     148             : 
     149             :   /**
     150             :    * Write message to screen and/or file
     151             :    * @param message The desired message
     152             :    * @param indent True if multiapp indenting is desired
     153             :    */
     154             :   void write(std::string message, bool indent = true);
     155             : 
     156             :   /**
     157             :    * Write the file stream to the file
     158             :    * @param append Toggle for appending the file
     159             :    *
     160             :    * This helper function writes the _file_output_stream to the file and clears the
     161             :    * stream, by default the file is appended. This does nothing if 'output_file' is
     162             :    * false.
     163             :    */
     164             :   void writeStreamToFile(bool append = true);
     165             : 
     166             :   /**
     167             :    * Print the L2-norms for each variable
     168             :    */
     169             :   void writeVariableNorms();
     170             : 
     171             :   /// A help function to format a time
     172             :   std::string formatTime(const Real t) const;
     173             : 
     174             :   /// The max number of table rows
     175             :   unsigned int _max_rows;
     176             : 
     177             :   /// The FormattedTable fit mode
     178             :   MooseEnum _fit_mode;
     179             : 
     180             :   /// Toggle for outputting time in time and dt in scientific notation
     181             :   bool _scientific_time;
     182             : 
     183             :   /// Flag for controlling outputting console information to a file
     184             :   bool _write_file;
     185             : 
     186             :   /// Flag for controlling outputting console information to screen
     187             :   bool _write_screen;
     188             : 
     189             :   /// Flag for writing detailed time step information
     190             :   bool _verbose;
     191             : 
     192             :   /// Stream for storing information to be written to a file
     193             :   std::stringstream _file_output_stream;
     194             : 
     195             :   /// State for all performance logging
     196             :   bool _perf_log;
     197             : 
     198             :   /// The interval at which the performance log is printed
     199             :   unsigned int _perf_log_interval;
     200             : 
     201             :   /// State for solve performance log
     202             :   bool _solve_log;
     203             : 
     204             :   /// Control the display libMesh performance log
     205             :   bool _libmesh_log;
     206             : 
     207             :   /// State for the performance log header information
     208             :   bool _perf_header;
     209             : 
     210             :   /// Flag for writing all variable norms
     211             :   bool _all_variable_norms;
     212             : 
     213             :   /// Flag for writing outlier variable norms
     214             :   bool _outlier_variable_norms;
     215             : 
     216             :   /// Multipliers for coloring variable residual norms (default [2, 0.8])
     217             :   std::vector<Real> _outlier_multiplier;
     218             : 
     219             :   /// Number of significant digits
     220             :   unsigned int _precision;
     221             : 
     222             :   /// Time format
     223             :   TimeFormatEnum _time_format;
     224             : 
     225             :   /// Whether to write all processors to files
     226             :   const bool _write_all_procs_to_files;
     227             : 
     228             : private:
     229             :   /**
     230             :    * Add a message to the output streams
     231             :    * @param message The message to add to the output streams
     232             :    *
     233             :    * Any call to this method will write the supplied message to the screen and/or file,
     234             :    * following the same restrictions as outputStep.
     235             :    *
     236             :    * Calls to this method should be made via OutputWarehouse::mooseConsole so that the
     237             :    * output stream buffer is cleaned up correctly. Thus, it is a private method.
     238             :    */
     239             :   void mooseConsole(const std::string & message);
     240             : 
     241             :   /// Reference to cached messages from calls to _console
     242             :   const std::ostringstream & _console_buffer;
     243             : 
     244             :   /// Storage for the old linear residual (needed for color output and only when used when printing to the screen)
     245             :   Real _old_linear_norm;
     246             : 
     247             :   /// Storage for the old non linear residual (needed for color output and only when used when printing to the screen)
     248             :   Real _old_nonlinear_norm;
     249             : 
     250             :   /// Flag for printing mesh information when the mesh changes
     251             :   bool _print_mesh_changed_info;
     252             : 
     253             :   /// Flags for controlling the what simulations information is shown
     254             :   MultiMooseEnum _system_info_flags;
     255             : 
     256             :   friend class OutputWarehouse;
     257             : 
     258             : private:
     259             :   /// A boolean for protecting _system_info_flags from being changed undesirably
     260             :   bool _allow_changing_sysinfo_flag;
     261             : 
     262             :   bool _last_message_ended_in_newline;
     263             : };

Generated by: LCOV version 1.14