Skip to content

Console Output

ConsoleOutput is the formatting layer used by every module for progress messages, warnings, and time-step summaries. It provides a consistent column-aligned presentation with configurable verbosity, a line-drawing toolkit, and log-file mirroring for long runs.

Key Classes and Concepts

  • ConsoleOutput: a header-only class of static helpers; it never holds per-simulation state.
  • VerbosityLevels: enum that gates messages. The current level is the static member ConsoleOutput::OutputVerbosity.
  • Standard layout constants: StandardColumnWidth = 40, LineLength = 80, StandardPrecision = 6, StandardNotation = floatfield::Default.

Commonly used helpers

Signatures are template-typed; these are the entry points modules actually call:

cpp
static void Write(const std::string message);
static void Write(const std::string name, const T value, ...);
static void WriteWithLog(std::array<std::stringstream,2>& line,
                         const int tStep,
                         const std::string name, const T value, ...);
static void WriteLineToLogfile(std::fstream& log, ...);

static std::string StandardLHS(std::string Left,
                               const size_t ColumnWidth);
static std::string StandardFloat(const T value, ...);
static std::string StandardIntegral(const T value, ...);
static std::string StandardMatrix(const T value, ...);
static std::string StandardVector(const T value, ...);
static std::string GetStandard(const std::string& Left,
                               const T Right,
                               const size_t ColumnWidth = StandardColumnWidth);
static std::string GetStandardNarrow(const std::string& Left,
                                     const T Right, ...);

WriteLine, WriteLineInsert, WriteBlankLine, WriteTimeStep, WriteWarning, WriteExit are the most common message-framing calls — every module's ReadInput uses them.

Usage

Input

ConsoleOutput has no .opi block of its own. Its verbosity follows the OutputVerbosity static variable; set it at simulation start if a run needs quieter output.

Output

  • Messages go to stdout (and optionally a log file via WriteWithLog / WriteLineToLogfile).
  • Log-file cadence is driven by the $LogScreen/$LogScreenF keys of RunTimeControl.

Example

Used throughout module examples. The canonical per-step printout seen in the Phase Field walkthrough:

cpp
if (RTC.WriteToScreen())
{
    double I_En = DO.AverageEnergyDensity(Phi, IP);
    std::string message = ConsoleOutput::GetStandard("Interface energy density", I_En);
    ConsoleOutput::WriteTimeStep(RTC, message);
}

Dependencies

  • RunTimeControl — gates when messages are emitted via WriteToScreen().
  • Used by every module's ReadInput and by every writer / solver that emits runtime messages.

Released under the GNU GPLv3 License.