deltaFlow
StaFileWriter Class Referencefinal

Writes the status file (.sta) with a compact solver summary. More...

#include <StaFileWriter.H>

Public Member Functions

bool write (const std::string &jobName, const std::string &inputFile, const std::string &solverName, const std::string &formatName, int nBus, int nBranch, int iterations, double finalError, double tolerance, bool converged, double elapsedSec) const
 Writes the status file (.sta) with a compact solver summary.
 

Detailed Description

Writes the status file (.sta) with a compact solver summary.

Definition at line 38 of file StaFileWriter.H.

Member Function Documentation

◆ write()

bool StaFileWriter::write ( const std::string &  jobName,
const std::string &  inputFile,
const std::string &  solverName,
const std::string &  formatName,
int  nBus,
int  nBranch,
int  iterations,
double  finalError,
double  tolerance,
bool  converged,
double  elapsedSec 
) const

Writes the status file (.sta) with a compact solver summary.

Parameters
jobNameJob name (used as output filename stem).
inputFilePath to the input data file.
solverNameName of the solver method used.
formatNameName of the input file format.
nBusNumber of buses.
nBranchNumber of branches.
iterationsNumber of solver iterations performed.
finalErrorFinal convergence error.
toleranceConvergence tolerance.
convergedWhether the solver converged.
elapsedSecWall-clock time in seconds.
Returns
true on success, false if file could not be opened.

Definition at line 30 of file StaFileWriter.C.

42 {
43 std::string staFile = jobName + ".sta";
44 std::ofstream out(staFile);
45 if (!out.is_open()) return false;
46
47 out << fmt::format("deltaFlow v{:<36s}Date {:>14s} Time {:>8s}\n",
49
50 out << " SUMMARY OF JOB INFORMATION:\n";
51 out << fmt::format(" {:>6s} {:>6s} {:>10s} {:>12s} {:>12s} {:>8s}\n",
52 "ITER", "STATUS", "ERROR", "TOLERANCE", "ELAPSED", "RESULT");
53
54 out << fmt::format(" {:>6d} {:>6s} {:>10.3e} {:>12.3e} {:>12.3f} {:>8s}\n",
55 iterations,
56 converged ? "CONV" : "FAIL",
57 finalError,
58 tolerance,
59 elapsedSec,
60 converged ? "OK" : "FAILED");
61
62 out << "\n";
63 if (converged) {
64 out << " THE ANALYSIS HAS COMPLETED SUCCESSFULLY\n";
65 } else {
66 out << " THE ANALYSIS HAS FAILED TO CONVERGE\n";
67 }
68
69 out << "\n";
70 out << "Jobinfo File:\n";
71 out << fmt::format("Inputfile: {}\n", inputFile);
72 out << fmt::format("Solver: {}\n", solverName);
73 out << fmt::format("Format: {}\n", formatName);
74 out << fmt::format("Hostname: {}\n", OutputFileCommon::hostname());
75 out << "\n";
76
77 out << "solver and hardware info\n";
78 out << "------------------------\n";
79 out << fmt::format("version : {}\n", deltaFlow_VERSION);
80 out << fmt::format("compiler : GCC {}\n", gcc_VERSION);
81 out << fmt::format("cmake : {}\n", CMake_VERSION);
82 out << fmt::format("hostname : {}\n", OutputFileCommon::hostname());
83 out << "\n";
84
85 out << "model info\n";
86 out << "----------\n";
87 out << fmt::format(" # of buses : {}\n", nBus);
88 out << fmt::format(" # of branches : {}\n", nBranch);
89 out << "\n";
90
91 out << "run and timing info\n";
92 out << "-------------------\n";
93 out << fmt::format("simulation end : {}\n", OutputFileCommon::timestamp());
94 out << fmt::format("elapsed time : {:.3f} seconds\n", elapsedSec);
95 out << fmt::format("iterations : {}\n", iterations);
96 out << fmt::format("final error : {:.6e}\n", finalError);
97 out << fmt::format("termination status: {}\n", converged ? "normal" : "failed");
98 out << "\n";
99
100 out.close();
101 return true;
102}
std::string timestamp()
Returns the current timestamp string.
std::string hostname()
Returns the current hostname.
std::string dateStr()
Returns the current date string.
std::string timeStr()
Returns the current time string.

References OutputFileCommon::dateStr(), OutputFileCommon::hostname(), OutputFileCommon::timestamp(), 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: