deltaFlow
MsgFileWriter Class Referencefinal

Writes the message file (.msg) with iteration history. More...

#include <MsgFileWriter.H>

Public Member Functions

bool write (const std::string &jobName, const std::string &solverName, const std::vector< std::pair< int, double > > &iterationHistory, double tolerance, bool converged) const
 Writes the message file (.msg) with iteration history.
 

Detailed Description

Writes the message file (.msg) with iteration history.

Definition at line 40 of file MsgFileWriter.H.

Member Function Documentation

◆ write()

bool MsgFileWriter::write ( const std::string &  jobName,
const std::string &  solverName,
const std::vector< std::pair< int, double > > &  iterationHistory,
double  tolerance,
bool  converged 
) const

Writes the message file (.msg) with iteration history.

Parameters
jobNameJob name (used as output filename stem).
solverNameName of the solver method used.
iterationHistoryVector of (iteration, error) pairs.
toleranceConvergence tolerance.
convergedWhether the solver converged.
Returns
true on success, false if file could not be opened.

Definition at line 31 of file MsgFileWriter.C.

37 {
38 std::string msgFile = jobName + ".msg";
39 std::ofstream out(msgFile);
40 if (!out.is_open()) return false;
41
42 out << Display::fileBanner();
43
44 out << fmt::format("\n deltaFlow v{:<32s}Date {:>14s} Time {:>8s}\n",
46 out << "\n";
47
48 out << Display::sectionHeader("I T E R A T I O N H I S T O R Y");
49
50 out << fmt::format(" {:>6s} {:>16s} {:>12s} {:>8s}\n",
51 "Iter", "Max Mismatch", "Tolerance", "Status");
52 out << " " << std::string(Display::pageWidth - 4, '-') << "\n";
53
54 for (const auto& [iter, error] : iterationHistory) {
55 std::string status = (error < tolerance) ? "CONV" : "";
56 out << fmt::format(" {:>6d} {:>16.6e} {:>12.6e} {:>8s}\n",
57 iter, error, tolerance, status);
58 }
59
60 out << " " << std::string(Display::pageWidth - 4, '-') << "\n";
61 out << "\n";
62
63 if (converged) {
64 out << " " << solverName << " CONVERGED\n";
65 } else {
66 out << " *** WARNING: " << solverName << " DID NOT CONVERGE\n";
67 }
68
69 out << "\n";
70 out.close();
71 return true;
72}
constexpr int pageWidth
Standard output page width.
Definition Display.H:51
std::string sectionHeader(const std::string &title)
Returns a section header for output files.
Definition Display.H:226
std::string fileBanner()
Returns a full plain-text banner for output/log files.
Definition Display.H:217
std::string dateStr()
Returns the current date string.
std::string timeStr()
Returns the current time string.

References OutputFileCommon::dateStr(), Display::fileBanner(), Display::pageWidth, Display::sectionHeader(), and OutputFileCommon::timeStr().

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following files: