mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
added writing of detailed performance report
This commit is contained in:
parent
9476dfc35a
commit
0f33835e67
@ -229,12 +229,12 @@ namespace Opm {
|
|||||||
/// \param[in, out] reservoir_state reservoir state variables
|
/// \param[in, out] reservoir_state reservoir state variables
|
||||||
/// \param[in, out] well_state well state variables
|
/// \param[in, out] well_state well state variables
|
||||||
template <class NonlinearSolverType>
|
template <class NonlinearSolverType>
|
||||||
SimulatorReport nonlinearIteration(const int iteration,
|
SimulatorReportBase nonlinearIteration(const int iteration,
|
||||||
const SimulatorTimerInterface& timer,
|
const SimulatorTimerInterface& timer,
|
||||||
NonlinearSolverType& nonlinear_solver)
|
NonlinearSolverType& nonlinear_solver)
|
||||||
{
|
{
|
||||||
SimulatorReport report;
|
SimulatorReportBase report;
|
||||||
failureReport_ = SimulatorReport();
|
failureReport_ = SimulatorReportBase();
|
||||||
Dune::Timer perfTimer;
|
Dune::Timer perfTimer;
|
||||||
|
|
||||||
perfTimer.start();
|
perfTimer.start();
|
||||||
@ -854,7 +854,7 @@ namespace Opm {
|
|||||||
{ return ebosSimulator_; }
|
{ return ebosSimulator_; }
|
||||||
|
|
||||||
/// return the statistics if the nonlinearIteration() method failed
|
/// return the statistics if the nonlinearIteration() method failed
|
||||||
const SimulatorReport& failureReport() const
|
const SimulatorReportBase& failureReport() const
|
||||||
{ return failureReport_; }
|
{ return failureReport_; }
|
||||||
|
|
||||||
struct StepReport
|
struct StepReport
|
||||||
@ -885,7 +885,7 @@ namespace Opm {
|
|||||||
const bool has_brine_;
|
const bool has_brine_;
|
||||||
|
|
||||||
ModelParameters param_;
|
ModelParameters param_;
|
||||||
SimulatorReport failureReport_;
|
SimulatorReportBase failureReport_;
|
||||||
|
|
||||||
// Well Model
|
// Well Model
|
||||||
BlackoilWellModel<TypeTag>& well_model_;
|
BlackoilWellModel<TypeTag>& well_model_;
|
||||||
|
@ -518,8 +518,21 @@ namespace Opm
|
|||||||
ss << "Threads per MPI process: " << std::setw(5) << threads << "\n";
|
ss << "Threads per MPI process: " << std::setw(5) << threads << "\n";
|
||||||
successReport.reportFullyImplicit(ss, &failureReport);
|
successReport.reportFullyImplicit(ss, &failureReport);
|
||||||
OpmLog::info(ss.str());
|
OpmLog::info(ss.str());
|
||||||
|
const std::string dir = eclState().getIOConfig().getOutputDir();
|
||||||
|
namespace fs = Opm::filesystem;
|
||||||
|
fs::path output_dir(dir);
|
||||||
|
{
|
||||||
|
fs::path fullpath = output_dir / "successreports.txt";
|
||||||
|
std::ofstream os(fullpath.string());
|
||||||
|
successReport.fullReports(os);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
fs::path fullpath = output_dir / "failedreports.txt";
|
||||||
|
std::ofstream os(fullpath.string());
|
||||||
|
failureReport.fullReports(os);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return successReport.exit_status;
|
return successReport.exit_status;
|
||||||
} else {
|
} else {
|
||||||
if (output_cout) {
|
if (output_cout) {
|
||||||
std::cout << "\n\n================ Simulation turned off ===============\n" << std::flush;
|
std::cout << "\n\n================ Simulation turned off ===============\n" << std::flush;
|
||||||
|
@ -151,10 +151,11 @@ namespace Opm {
|
|||||||
|
|
||||||
SimulatorReport step(const SimulatorTimerInterface& timer)
|
SimulatorReport step(const SimulatorTimerInterface& timer)
|
||||||
{
|
{
|
||||||
SimulatorReport iterReport;
|
SimulatorReportBase iterReport;
|
||||||
SimulatorReport report;
|
SimulatorReportBase report;
|
||||||
|
report.global_time = timer.simulationTimeElapsed();
|
||||||
failureReport_ = SimulatorReport();
|
failureReport_ = SimulatorReport();
|
||||||
|
failureReport_.global_time = timer.simulationTimeElapsed();
|
||||||
// Do model-specific once-per-step calculations.
|
// Do model-specific once-per-step calculations.
|
||||||
model_->prepareStep(timer);
|
model_->prepareStep(timer);
|
||||||
|
|
||||||
@ -172,7 +173,7 @@ namespace Opm {
|
|||||||
// model will usually do an early return without an expensive
|
// model will usually do an early return without an expensive
|
||||||
// solve, unless the minIter() count has not been reached yet.
|
// solve, unless the minIter() count has not been reached yet.
|
||||||
iterReport = model_->nonlinearIteration(iteration, timer, *this);
|
iterReport = model_->nonlinearIteration(iteration, timer, *this);
|
||||||
|
iterReport.global_time = timer.simulationTimeElapsed();
|
||||||
report += iterReport;
|
report += iterReport;
|
||||||
report.converged = iterReport.converged;
|
report.converged = iterReport.converged;
|
||||||
|
|
||||||
@ -199,8 +200,10 @@ namespace Opm {
|
|||||||
// Do model-specific post-step actions.
|
// Do model-specific post-step actions.
|
||||||
model_->afterStep(timer);
|
model_->afterStep(timer);
|
||||||
report.converged = true;
|
report.converged = true;
|
||||||
|
SimulatorReport report_step;
|
||||||
return report;
|
report_step += report;
|
||||||
|
report_step.converged = true;
|
||||||
|
return report_step;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// return the statistics if the step() method failed
|
/// return the statistics if the step() method failed
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
namespace Opm
|
namespace Opm
|
||||||
{
|
{
|
||||||
SimulatorReport::SimulatorReport(bool verbose)
|
SimulatorReportBase::SimulatorReportBase(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),
|
||||||
@ -43,11 +43,12 @@ namespace Opm
|
|||||||
total_linear_iterations( 0 ),
|
total_linear_iterations( 0 ),
|
||||||
converged(false),
|
converged(false),
|
||||||
exit_status(EXIT_SUCCESS),
|
exit_status(EXIT_SUCCESS),
|
||||||
|
global_time(0),
|
||||||
verbose_(verbose)
|
verbose_(verbose)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimulatorReport::operator+=(const SimulatorReport& sr)
|
void SimulatorReportBase::operator+=(const SimulatorReportBase& sr)
|
||||||
{
|
{
|
||||||
pressure_time += sr.pressure_time;
|
pressure_time += sr.pressure_time;
|
||||||
transport_time += sr.transport_time;
|
transport_time += sr.transport_time;
|
||||||
@ -62,9 +63,10 @@ namespace Opm
|
|||||||
total_linearizations += sr.total_linearizations;
|
total_linearizations += sr.total_linearizations;
|
||||||
total_newton_iterations += sr.total_newton_iterations;
|
total_newton_iterations += sr.total_newton_iterations;
|
||||||
total_linear_iterations += sr.total_linear_iterations;
|
total_linear_iterations += sr.total_linear_iterations;
|
||||||
|
global_time = sr.global_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimulatorReport::report(std::ostream& os)
|
void SimulatorReportBase::report(std::ostream& os)
|
||||||
{
|
{
|
||||||
if ( verbose_ )
|
if ( verbose_ )
|
||||||
{
|
{
|
||||||
@ -77,7 +79,7 @@ namespace Opm
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimulatorReport::reportStep(std::ostringstream& ss)
|
void SimulatorReportBase::reportStep(std::ostringstream& ss)
|
||||||
{
|
{
|
||||||
if ( verbose_ )
|
if ( verbose_ )
|
||||||
{
|
{
|
||||||
@ -93,7 +95,7 @@ namespace Opm
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimulatorReport::reportFullyImplicit(std::ostream& os, const SimulatorReport* failureReport)
|
void SimulatorReportBase::reportFullyImplicit(std::ostream& os, const SimulatorReportBase* failureReport)
|
||||||
{
|
{
|
||||||
if ( verbose_ )
|
if ( verbose_ )
|
||||||
{
|
{
|
||||||
@ -178,7 +180,7 @@ namespace Opm
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimulatorReport::reportParam(std::ostream& os)
|
void SimulatorReportBase::reportParam(std::ostream& os)
|
||||||
{
|
{
|
||||||
if ( verbose_ )
|
if ( verbose_ )
|
||||||
{
|
{
|
||||||
@ -190,6 +192,32 @@ namespace Opm
|
|||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void SimulatorReport::fullReports(std::ostream& os){
|
||||||
|
SimulatorReportBase all;
|
||||||
|
for(size_t i=0; i < stepreports.size(); ++i){
|
||||||
|
SimulatorReportBase& sr = stepreports[i];
|
||||||
|
all += sr;
|
||||||
|
os << sr.global_time<< " ";
|
||||||
|
//os << sr.pressure_time<< " ";
|
||||||
|
//os << sr.transport_time<< " ";
|
||||||
|
//os << sr.total_time<< " ";
|
||||||
|
//os << sr.solver_time<< " ";
|
||||||
|
os << sr.assemble_time<< " ";
|
||||||
|
os << sr.linear_solve_setup_time<< " ";
|
||||||
|
os << sr.linear_solve_time<< " ";
|
||||||
|
os << sr.update_time<< " ";
|
||||||
|
os << sr.output_write_time<< " ";
|
||||||
|
os<< sr.total_well_iterations<< " ";
|
||||||
|
os << sr.total_linearizations<< " ";
|
||||||
|
os << sr.total_newton_iterations<< " ";
|
||||||
|
os << sr.total_linear_iterations<< " ";
|
||||||
|
os << sr.converged<< " ";
|
||||||
|
os << sr.exit_status<< " ";
|
||||||
|
os << std::endl;
|
||||||
|
}
|
||||||
|
if(not(this->linear_solve_time == all.linear_solve_time)){
|
||||||
|
Opm::debug("Inconsistency between timestep report and total report");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Opm
|
} // namespace Opm
|
||||||
|
@ -19,14 +19,15 @@
|
|||||||
|
|
||||||
#ifndef OPM_SIMULATORREPORT_HEADER_INCLUDED
|
#ifndef OPM_SIMULATORREPORT_HEADER_INCLUDED
|
||||||
#define OPM_SIMULATORREPORT_HEADER_INCLUDED
|
#define OPM_SIMULATORREPORT_HEADER_INCLUDED
|
||||||
|
#include <cassert>
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace Opm
|
namespace Opm
|
||||||
{
|
{
|
||||||
|
|
||||||
/// A struct for returning timing data from a simulator to its caller.
|
/// A struct for returning timing data from a simulator to its caller.
|
||||||
struct SimulatorReport
|
struct SimulatorReportBase
|
||||||
{
|
{
|
||||||
double pressure_time;
|
double pressure_time;
|
||||||
double transport_time;
|
double transport_time;
|
||||||
@ -46,22 +47,51 @@ namespace Opm
|
|||||||
bool converged;
|
bool converged;
|
||||||
int exit_status;
|
int exit_status;
|
||||||
|
|
||||||
|
double global_time;
|
||||||
/// Default constructor initializing all times to 0.0.
|
/// Default constructor initializing all times to 0.0.
|
||||||
explicit SimulatorReport(bool verbose=true);
|
explicit SimulatorReportBase(bool verbose=true);
|
||||||
/// Copy constructor
|
/// Copy constructor
|
||||||
SimulatorReport(const SimulatorReport&) = default;
|
SimulatorReportBase(const SimulatorReportBase&) = default;
|
||||||
/// 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 SimulatorReportBase& sr);
|
||||||
/// Print a report to the given stream.
|
/// Print a report to the given stream.
|
||||||
void report(std::ostream& os);
|
void report(std::ostream& os);
|
||||||
void reportStep(std::ostringstream& os);
|
void reportStep(std::ostringstream& os);
|
||||||
/// Print a report, leaving out the transport time.
|
/// Print a report, leaving out the transport time.
|
||||||
void reportFullyImplicit(std::ostream& os, const SimulatorReport* failedReport = nullptr);
|
void reportFullyImplicit(std::ostream& os, const SimulatorReportBase* failedReport = nullptr);
|
||||||
void reportParam(std::ostream& os);
|
void reportParam(std::ostream& os);
|
||||||
private:
|
private:
|
||||||
// Whether to print statistics to std::cout
|
// Whether to print statistics to std::cout
|
||||||
bool verbose_;
|
bool verbose_;
|
||||||
};
|
};
|
||||||
|
struct SimulatorReport: public SimulatorReportBase{
|
||||||
|
std::vector<SimulatorReportBase> stepreports;
|
||||||
|
explicit SimulatorReport(bool verbose=true) :
|
||||||
|
SimulatorReportBase(verbose),
|
||||||
|
stepreports()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
void operator+=(const SimulatorReportBase& sr){
|
||||||
|
SimulatorReportBase::operator+=(sr);
|
||||||
|
// if(stepreports.size()>0){
|
||||||
|
// assert(stepreports.back().global_time != sr.global_time);
|
||||||
|
// }
|
||||||
|
stepreports.push_back(sr);
|
||||||
|
}
|
||||||
|
void operator+=(const SimulatorReport& sr){
|
||||||
|
SimulatorReportBase::operator+=(sr);
|
||||||
|
// if(stepreports.size()>0){
|
||||||
|
// assert(stepreports.back().global_time != sr.global_time);
|
||||||
|
// }
|
||||||
|
if(sr.stepreports.size()>0){
|
||||||
|
stepreports.insert(stepreports.end(),sr.stepreports.begin(),sr.stepreports.end());
|
||||||
|
}else{
|
||||||
|
stepreports.push_back(sr);
|
||||||
|
}
|
||||||
|
//stepreports.push_back(sr);
|
||||||
|
}
|
||||||
|
void fullReports(std::ostream& os);
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace Opm
|
} // namespace Opm
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user