Merge pull request #800 from blattms/parallel-verbose-only-on-master

Allow to prevent printing to std::cout.
This commit is contained in:
Atgeirr Flø Rasmussen 2015-05-13 14:42:37 +02:00
commit f24b9a1dc2
2 changed files with 33 additions and 20 deletions

View File

@ -23,12 +23,13 @@
namespace Opm namespace Opm
{ {
SimulatorReport::SimulatorReport() SimulatorReport::SimulatorReport(bool verbose)
: pressure_time(0.0), : pressure_time(0.0),
transport_time(0.0), transport_time(0.0),
total_time(0.0), total_time(0.0),
total_newton_iterations( 0 ), total_newton_iterations( 0 ),
total_linear_iterations( 0 ) total_linear_iterations( 0 ),
verbose_(verbose)
{ {
} }
@ -43,31 +44,40 @@ namespace Opm
void SimulatorReport::report(std::ostream& os) void SimulatorReport::report(std::ostream& os)
{ {
os << "Total time taken: " << total_time if ( verbose_ )
<< "\n Pressure time: " << pressure_time {
<< "\n Transport time: " << transport_time os << "Total time taken: " << total_time
<< "\n Overall Newton Iterations: " << total_newton_iterations << "\n Pressure time: " << pressure_time
<< "\n Overall Linear Iterations: " << total_linear_iterations << "\n Transport time: " << transport_time
<< std::endl; << "\n Overall Newton Iterations: " << total_newton_iterations
<< "\n Overall Linear Iterations: " << total_linear_iterations
<< std::endl;
}
} }
void SimulatorReport::reportFullyImplicit(std::ostream& os) void SimulatorReport::reportFullyImplicit(std::ostream& os)
{ {
os << "Total time taken (seconds): " << total_time if ( verbose_ )
<< "\nSolver time (seconds): " << pressure_time {
<< "\nOverall Newton Iterations: " << total_newton_iterations os << "Total time taken (seconds): " << total_time
<< "\nOverall Linear Iterations: " << total_linear_iterations << "\nSolver time (seconds): " << pressure_time
<< std::endl; << "\nOverall Newton Iterations: " << total_newton_iterations
<< "\nOverall Linear Iterations: " << total_linear_iterations
<< std::endl;
}
} }
void SimulatorReport::reportParam(std::ostream& os) void SimulatorReport::reportParam(std::ostream& os)
{ {
os << "/timing/total_time=" << total_time if ( verbose_ )
<< "\n/timing/pressure/total_time=" << pressure_time {
<< "\n/timing/transport/total_time=" << transport_time os << "/timing/total_time=" << total_time
<< "\n/timing/newton/iterations=" << total_newton_iterations << "\n/timing/pressure/total_time=" << pressure_time
<< "\n/timing/linear/iterations=" << total_linear_iterations << "\n/timing/transport/total_time=" << transport_time
<< std::endl; << "\n/timing/newton/iterations=" << total_newton_iterations
<< "\n/timing/linear/iterations=" << total_linear_iterations
<< std::endl;
}
} }

View File

@ -36,7 +36,7 @@ namespace Opm
unsigned int total_linear_iterations; unsigned int total_linear_iterations;
/// Default constructor initializing all times to 0.0. /// Default constructor initializing all times to 0.0.
SimulatorReport(); SimulatorReport(bool verbose=true);
/// Increment this report's times by those in sr. /// Increment this report's times by those in sr.
void operator+=(const SimulatorReport& sr); void operator+=(const SimulatorReport& sr);
/// Print a report to the given stream. /// Print a report to the given stream.
@ -44,6 +44,9 @@ namespace Opm
/// Print a report, leaving out the transport time. /// Print a report, leaving out the transport time.
void reportFullyImplicit(std::ostream& os); void reportFullyImplicit(std::ostream& os);
void reportParam(std::ostream& os); void reportParam(std::ostream& os);
private:
// Whether to print statistics to std::cout
bool verbose_;
}; };
} // namespace Opm } // namespace Opm