extend and clean up the SimulatorReport

This commit is contained in:
Andreas Lauser
2016-11-23 21:44:33 +01:00
parent 0429c756ba
commit 8c5f92dbc4
18 changed files with 244 additions and 198 deletions

View File

@@ -161,7 +161,6 @@ public:
// Create timers and file for writing timing info.
Opm::time::StopWatch solver_timer;
double stime = 0.0;
Opm::time::StopWatch step_timer;
Opm::time::StopWatch total_timer;
total_timer.start();
@@ -188,12 +187,11 @@ public:
// desiredRestoreStep );
}
unsigned int totalLinearizations = 0;
unsigned int totalNonlinearIterations = 0;
unsigned int totalLinearIterations = 0;
bool is_well_potentials_computed = param_.getDefault("compute_well_potentials", false );
std::vector<double> well_potentials;
DynamicListEconLimited dynamic_list_econ_limited;
SimulatorReport report;
SimulatorReport stepReport;
bool ooip_computed = false;
std::vector<int> fipnum_global = eclState().get3DProperties().getIntGridProperty("FIPNUM").getData();
@@ -253,22 +251,25 @@ public:
// write the inital state at the report stage
if (timer.initialStep()) {
Dune::Timer perfTimer;
perfTimer.start();
// calculate Intensive Quantities
// make sure that the Intensive Quantities cache is up to date
const auto& gridManager = ebosSimulator_.gridManager();
const auto& gridView = gridManager.gridView();
auto elemIt = gridView.template begin<0>();
auto elemEndIt = gridView.template end<0>();
ElementContext elemCtx(ebosSimulator_);
for (; elemIt != elemEndIt; ++ elemIt) {
// this is convenient, but slightly inefficient: one only needs to update
// the primary intensive quantities
elemCtx.updateAll(*elemIt);
elemCtx.updatePrimaryStencil(*elemIt);
elemCtx.updatePrimaryIntensiveQuantities(/*timeIdx=*/0);
}
// No per cell data is written for initial step, but will be
// for subsequent steps, when we have started simulating
output_writer_.writeTimeStepWithoutCellProperties( timer, state, well_state );
report.output_write_time += perfTimer.stop();
}
// Compute orignal FIP;
@@ -283,11 +284,12 @@ public:
std::ostringstream step_msg;
boost::posix_time::time_facet* facet = new boost::posix_time::time_facet("%d-%b-%Y");
step_msg.imbue(std::locale(std::locale::classic(), facet));
step_msg << "\nTime step " << std::setw(4) <<timer.currentStepNum()
step_msg << "\n"
<< "Time step " << std::setw(4) <<timer.currentStepNum()
<< " at day " << (double)unit::convert::to(timer.simulationTimeElapsed(), unit::day)
<< "/" << (double)unit::convert::to(timer.totalTime(), unit::day)
<< ", date = " << timer.currentDateTime()
<< "\n";
<< ", size = " << (double)unit::convert::to(timer.currentStepLength(), unit::day) << " days";
OpmLog::info(step_msg.str());
}
@@ -299,14 +301,16 @@ public:
// \Note: The report steps are met in any case
// \Note: The sub stepping will require a copy of the state variables
if( adaptiveTimeStepping ) {
adaptiveTimeStepping->step( timer, *solver, state, well_state, output_writer_ );
report += adaptiveTimeStepping->step( timer, *solver, state, well_state, output_writer_ );
}
else {
// solve for complete report step
solver->step(timer, state, well_state);
stepReport = solver->step(timer, state, well_state);
report += stepReport;
if( terminal_output_ )
{
//stepReport.briefReport();
std::ostringstream iter_msg;
iter_msg << "Stepsize " << (double)unit::convert::to(timer.currentStepLength(), unit::day);
if (solver->wellIterations() != 0) {
@@ -324,13 +328,8 @@ public:
// take time that was used to solve system for this reportStep
solver_timer.stop();
// accumulate the number of nonlinear and linear Iterations
totalLinearizations += solver->linearizations();
totalNonlinearIterations += solver->nonlinearIterations();
totalLinearIterations += solver->linearIterations();
// Report timing.
const double st = solver_timer.secsSinceStart();
// update timing.
report.solver_time += solver_timer.secsSinceStart();
// Compute current FIP.
std::vector<std::vector<double>> COIP;
@@ -345,30 +344,22 @@ public:
for (size_t reg = 0; reg < OOIP.size(); ++reg) {
outputFluidInPlace(OOIP[reg], COIP[reg], eclState().getUnits(), reg+1);
}
}
// accumulate total time
stime += st;
if ( terminal_output_ )
{
std::string msg;
msg = "Fully implicit solver took: " + std::to_string(st) + " seconds. Total solver time taken: " + std::to_string(stime) + " seconds.";
msg =
"Time step took " + std::to_string(stepReport.solver_time) + " seconds; "
"total solver time " + std::to_string(report.solver_time) + " seconds.";
OpmLog::note(msg);
}
if ( output_writer_.output() ) {
SimulatorReport step_report;
step_report.pressure_time = st;
step_report.total_time = step_timer.secsSinceStart();
step_report.reportParam(tstep_os);
}
// Increment timer, remember well state.
++timer;
// write simulation state at the report stage
Dune::Timer perfTimer;
perfTimer.start();
output_writer_.writeTimeStep( timer, state, well_state, solver->model() );
report.output_write_time += perfTimer.stop();
prev_well_state = well_state;
// The well potentials are only computed if they are needed
@@ -383,13 +374,8 @@ public:
// Stop timer and create timing report
total_timer.stop();
SimulatorReport report;
report.pressure_time = stime;
report.transport_time = 0.0;
report.total_time = total_timer.secsSinceStart();
report.total_linearizations = totalLinearizations;
report.total_newton_iterations = totalNonlinearIterations;
report.total_linear_iterations = totalLinearIterations;
report.converged = true;
return report;
}