Converted to fmt formatting

This commit is contained in:
Alf Birger Rustad
2020-10-02 12:46:45 +02:00
parent 845eb17d28
commit e68db6dbda
2 changed files with 68 additions and 57 deletions

View File

@@ -107,10 +107,10 @@ public:
if (!EWOMS_GET_PARAM(TypeTag, bool, EnableTracerModel)) { if (!EWOMS_GET_PARAM(TypeTag, bool, EnableTracerModel)) {
if (simulator_.gridView().comm().rank() == 0) { if (simulator_.gridView().comm().rank() == 0) {
OpmLog::warning("Warning: Keyword TRACERS has only experimental support, and is hence ignored.\n" OpmLog::warning("Keyword TRACERS has only experimental support, and is hence ignored.\n"
+ std::string("The experimental tracer model can still be used, but must be set explicitely.\n") "The experimental tracer model can still be used, but must be set explicitely.\n"
+ std::string("To use tracers, set the command line option: --enable-tracer-model=true\n") "To use tracers, set the command line option: --enable-tracer-model=true"
+ "\n"); "\n");
} }
return; // Tracer transport must be enabled by the user return; // Tracer transport must be enabled by the user
} }

View File

@@ -26,6 +26,7 @@
#include <iomanip> #include <iomanip>
#include <ostream> #include <ostream>
#include <sstream> #include <sstream>
#include <fmt/format.h>
namespace Opm namespace Opm
{ {
@@ -74,101 +75,111 @@ namespace Opm
void SimulatorReportSingle::reportStep(std::ostringstream& ss) const void SimulatorReportSingle::reportStep(std::ostringstream& ss) const
{ {
if (total_well_iterations != 0) { if (total_well_iterations != 0) {
ss << "Well its=" << std::setw(2) << total_well_iterations << ", "; ss << fmt::format("Well its={:2}", total_well_iterations);
} }
ss << "Newton its=" << std::setw(2) << total_newton_iterations << ", " ss << fmt::format(" Newton its={:2}, lineraizations={:2} ({:2.1f}sec), linear its={:3} ({:2.1f}sec)",
<< "linearizations=" << std::setw(2) << total_linearizations total_newton_iterations,
<< " (" << std::fixed << std::setprecision(1) << std::setw(2) << assemble_time << "sec), " total_linearizations,
<< "linear its=" << std::setw(3) << total_linear_iterations assemble_time,
<< " (" << std::fixed << std::setprecision(1) << std::setw(2) << linear_solve_time << "sec)"; total_linear_iterations,
linear_solve_time);
} }
void SimulatorReportSingle::reportFullyImplicit(std::ostream& os, const SimulatorReportSingle* failureReport) const void SimulatorReportSingle::reportFullyImplicit(std::ostream& os, const SimulatorReportSingle* failureReport) const
{ {
double t = total_time; os << fmt::format("Total time (seconds): {:2.1f} \n", total_time);
os << "Total time (seconds): " << std::fixed << std::setprecision(1) << t;
os << std::endl;
t = solver_time + (failureReport ? failureReport->solver_time : 0.0); os << fmt::format("Solver time (seconds): {:2.1f} \n",
os << "Solver time (seconds): " << std::fixed << std::setprecision(1) << t; solver_time + (failureReport ? failureReport->solver_time : 0.0));
os << std::endl;
if (assemble_time > 0.0 || linear_solve_time > 0.0) { if (assemble_time > 0.0 || linear_solve_time > 0.0) {
t = assemble_time + (failureReport ? failureReport->assemble_time : 0.0);
os << " Assembly time (seconds): " << std::fixed << std::setprecision(1) << t; double t = assemble_time + (failureReport ? failureReport->assemble_time : 0.0);
os << fmt::format(" Assembly time (seconds): {:2.1f}", t);
if (failureReport) { if (failureReport) {
os << " (Failed: " << failureReport->assemble_time << "; " os << fmt::format(" (Failed: {:2.1f}; {:2.1f}%)",
<< 100*failureReport->assemble_time/t << "%)"; failureReport->assemble_time,
100*failureReport->assemble_time/t);
}
os << std::endl;
t = assemble_time_well + (failureReport ? failureReport->assemble_time_well : 0.0);
os << fmt::format(" Well assembly (seconds): {:2.1f}", t);
if (failureReport) {
os << fmt::format(" (Failed: {:2.1f}; {:2.1f}%)",
failureReport->assemble_time_well,
100*failureReport->assemble_time_well/t);
} }
os << std::endl; os << std::endl;
t = assemble_time_well + (failureReport ? failureReport->assemble_time_well : 0.0); t = linear_solve_time + (failureReport ? failureReport->linear_solve_time : 0.0);
os << " Well assembly time (seconds): " << std::fixed << std::setprecision(1) << t; os << fmt::format(" Linear solve time (seconds): {:2.1f}", t);
if (failureReport) { if (failureReport) {
os << " (Failed: " << failureReport->assemble_time_well << "; " os << fmt::format(" (Failed: {:2.1f}; {:2.1f}%)",
<< 100*failureReport->assemble_time_well/t << "%)"; failureReport->linear_solve_time,
100*failureReport->linear_solve_time/t);
} }
os << std::endl; os << std::endl;
t = linear_solve_time + (failureReport ? failureReport->linear_solve_time : 0.0); t = linear_solve_setup_time + (failureReport ? failureReport->linear_solve_setup_time : 0.0);
os << " Linear solve time (seconds): " << std::fixed << std::setprecision(1) << t; os << fmt::format(" Linear setup (seconds): {:2.1f}", t);
if (failureReport) { if (failureReport) {
os << " (Failed: " << failureReport->linear_solve_time << "; " os << fmt::format(" (Failed: {:2.1f}; {:2.1f}%)",
<< 100*failureReport->linear_solve_time/t << "%)"; failureReport->linear_solve_setup_time,
100*failureReport->linear_solve_setup_time/t);
} }
os << std::endl; os << std::endl;
t = linear_solve_setup_time + (failureReport ? failureReport->linear_solve_setup_time : 0.0);
os << " Linear solve setup time (seconds): " << std::fixed << std::setprecision(1) << t;
if (failureReport) {
os << " (Failed: " << failureReport->linear_solve_setup_time << "; "
<< 100*failureReport->linear_solve_setup_time/t << "%)";
}
os << std::endl;
t = update_time + (failureReport ? failureReport->update_time : 0.0); t = update_time + (failureReport ? failureReport->update_time : 0.0);
os << " Update time (seconds): " << std::fixed << std::setprecision(1) << t; os << fmt::format(" Update time (seconds): {:2.1f}", t);
if (failureReport) { if (failureReport) {
os << " (Failed: " << failureReport->update_time << "; " os << fmt::format(" (Failed: {:2.1f}; {:2.1f}%)",
<< 100*failureReport->update_time/t << "%)"; failureReport->update_time,
100*failureReport->update_time/t);
} }
os << std::endl; os << std::endl;
t = output_write_time + (failureReport ? failureReport->output_write_time : 0.0); os << fmt::format(" Output write time (seconds): {:2.1f}",
os << " Output write time (seconds): " << std::fixed << std::setprecision(1) << t; output_write_time + (failureReport ? failureReport->output_write_time : 0.0));
os << std::endl; os << std::endl;
} }
int n = total_well_iterations + (failureReport ? failureReport->total_well_iterations : 0); int n = total_well_iterations + (failureReport ? failureReport->total_well_iterations : 0);
os << "Overall Well Iterations: " << n;
os << fmt::format("Overall Well Iterations: {:2}", n);
if (failureReport) { if (failureReport) {
os << " (Failed: " << failureReport->total_well_iterations << "; " os << fmt::format(" (Failed: {:2}; {:2.1f}%)",
<< 100.0*failureReport->total_well_iterations/n << "%)"; failureReport->total_well_iterations,
100.0*failureReport->total_well_iterations/n);
} }
os << std::endl; os << std::endl;
n = total_linearizations + (failureReport ? failureReport->total_linearizations : 0); n = total_linearizations + (failureReport ? failureReport->total_linearizations : 0);
os << "Overall Linearizations: " << n; os << fmt::format("Overall Linearizations: {:2}", n);
if (failureReport) { if (failureReport) {
os << " (Failed: " << failureReport->total_linearizations << "; " os << fmt::format(" (Failed: {:2}; {:2.1f}%",
<< 100.0*failureReport->total_linearizations/n << "%)"; failureReport->total_linearizations,
100.0*failureReport->total_linearizations/n);
} }
os << std::endl; os << std::endl;
n = total_newton_iterations + (failureReport ? failureReport->total_newton_iterations : 0); n = total_newton_iterations + (failureReport ? failureReport->total_newton_iterations : 0);
os << "Overall Newton Iterations: " << n; os << fmt::format("Overall Newton Iterations: {:2}", n);
if (failureReport) { if (failureReport) {
os << " (Failed: " << failureReport->total_newton_iterations << "; " os << fmt::format(" (Failed: {:2}; {:2.1f}%",
<< 100.0*failureReport->total_newton_iterations/n << "%)"; failureReport->total_newton_iterations,
100.0*failureReport->total_newton_iterations/n);
} }
os << std::endl; os << std::endl;
n = total_linear_iterations + (failureReport ? failureReport->total_linear_iterations : 0); n = total_linear_iterations + (failureReport ? failureReport->total_linear_iterations : 0);
os << "Overall Linear Iterations: " << n; os << fmt::format("Overall Linear Iterations: {:2}", n);
if (failureReport) { if (failureReport) {
os << " (Failed: " << failureReport->total_linear_iterations << "; " os << fmt::format(" (Failed: {:2}; {:2.1f}%",
<< 100.0*failureReport->total_linear_iterations/n << "%)"; failureReport->total_linear_iterations,
100.0*failureReport->total_linear_iterations/n);
} }
os << std::endl; os << std::endl;
} }