Added reporting of time usage to interface, similar to SimulatorTwophase.

This commit is contained in:
Atgeirr Flø Rasmussen 2012-06-14 13:24:38 +02:00
parent d9ea18dc9d
commit eb845fd45a
2 changed files with 36 additions and 23 deletions

View File

@ -90,9 +90,9 @@ namespace Opm
LinearSolverInterface& linsolver,
const double* gravity);
void run(SimulatorTimer& timer,
PolymerState& state,
WellState& well_state);
SimulatorReport run(SimulatorTimer& timer,
PolymerState& state,
WellState& well_state);
private:
// Data.
@ -144,12 +144,12 @@ namespace Opm
void SimulatorPolymer::run(SimulatorTimer& timer,
PolymerState& state,
WellState& well_state)
SimulatorPolymer::SimulatorReport
SimulatorPolymer::run(SimulatorTimer& timer,
PolymerState& state,
WellState& well_state)
{
pimpl_->run(timer, state, well_state);
return pimpl_->run(timer, state, well_state);
}
@ -177,7 +177,7 @@ namespace Opm
linsolver_(linsolver),
gravity_(gravity),
psolver_(grid, props, rock_comp_props, poly_props, linsolver,
param.getDefault("nl_pressure_residual_tolerance", 1e-8),
param.getDefault("nl_pressure_residual_tolerance", 0.0),
param.getDefault("nl_pressure_change_tolerance", 1.0),
param.getDefault("nl_pressure_maxiter", 10),
gravity, wells, src, bcs),
@ -231,10 +231,10 @@ namespace Opm
void SimulatorPolymer::Impl::run(SimulatorTimer& timer,
PolymerState& state,
WellState& well_state)
SimulatorPolymer::SimulatorReport
SimulatorPolymer::Impl::run(SimulatorTimer& timer,
PolymerState& state,
WellState& well_state)
{
std::vector<double> transport_src;
@ -255,7 +255,6 @@ namespace Opm
double ttime = 0.0;
Opm::time::StopWatch total_timer;
total_timer.start();
std::cout << "\n\n================ Starting main simulation loop ===============" << std::endl;
double init_satvol[2] = { 0.0 };
double init_polymass = 0.0;
double satvol[2] = { 0.0 };
@ -393,12 +392,6 @@ namespace Opm
well_state.bhp(), well_state.perfRates());
}
}
total_timer.stop();
std::cout << "\n\n================ End of simulation ===============\n"
<< "Total time taken: " << total_timer.secsSinceStart()
<< "\n Pressure time: " << ptime
<< "\n Transport time: " << ttime << std::endl;
if (output_) {
outputState(grid_, state, timer.currentStepNum(), output_dir_);
@ -407,6 +400,14 @@ namespace Opm
outputWellReport(wellreport, output_dir_);
}
}
total_timer.stop();
SimulatorReport report;
report.pressure_time = ptime;
report.transport_time = ttime;
report.total_time = total_timer.secsSinceStart();
return report;
}

View File

@ -77,15 +77,27 @@ namespace Opm
LinearSolverInterface& linsolver,
const double* gravity);
/// A struct for returning timing data to the client.
struct SimulatorReport
{
double pressure_time;
double transport_time;
double total_time;
SimulatorReport();
void operator+=(const SimulatorReport& sr);
void report(std::ostream& os);
};
/// Run the simulation.
/// This will run succesive timesteps until timer.done() is true. It will
/// modify the reservoir and well states.
/// \param[in,out] timer governs the requested reporting timesteps
/// \param[in,out] state state of reservoir: pressure, fluxes
/// \param[in,out] well_state state of wells: bhp, perforation rates
void run(SimulatorTimer& timer,
PolymerState& state,
WellState& well_state);
/// \return simulation report, with timing data
SimulatorReport run(SimulatorTimer& timer,
PolymerState& state,
WellState& well_state);
private:
class Impl;