re-add the epoch stuff

this is required until the new time step handling code lands...
This commit is contained in:
Andreas Lauser 2014-02-13 15:14:23 +01:00
parent d7d25253f3
commit c23b38f60b

View File

@ -179,7 +179,7 @@ try
// Write parameters used for later reference.
bool output = param.getDefault("output", true);
std::ofstream outStream;
std::ofstream epoch_os;
std::string output_dir;
if (output) {
output_dir =
@ -191,8 +191,8 @@ try
catch (...) {
OPM_THROW(std::runtime_error, "Creating directories failed: " << fpath);
}
std::string filename = output_dir + "/timing.param";
outStream.open(filename.c_str(), std::fstream::trunc | std::fstream::out);
std::string filename = output_dir + "/epoch_timing.param";
epoch_os.open(filename.c_str(), std::fstream::trunc | std::fstream::out);
// open file to clean it. The file is appended to in SimulatorTwophase
filename = output_dir + "/step_timing.param";
std::fstream step_os(filename.c_str(), std::fstream::trunc | std::fstream::out);
@ -202,59 +202,67 @@ try
std::cout << "\n\n================ Starting main simulation loop ===============\n"
<< "\n\n" << std::flush;
<< " (number of epochs: "
<< (deck->numberOfEpochs()) << ")\n\n" << std::flush;
SimulatorReport rep;
// With a deck, we may have more epochs etc.
WellState well_state;
SimulatorTimer simtimer;
int step = 0;
// Update the timer.
#warning "HACK: required until the SimulationTimer, WellsManager and the EclipseWriter don't require the old parser anymore"
#if 0 // USE_NEW_PARSER
if (newParserDeck->hasKeyword("TSTEP")) {
simtimer.init(newParserDeck);
} else {
simtimer.init(param);
}
#else
if (deck->hasField("TSTEP")) {
simtimer.init(*deck);
} else {
simtimer.init(param);
}
#endif
SimulatorTimer simtimer;
// Use timer for last epoch to obtain total time.
deck->setCurrentEpoch(deck->numberOfEpochs() - 1);
simtimer.init(*deck);
const double total_time = simtimer.totalTime();
for (int epoch = 0; epoch < deck->numberOfEpochs(); ++epoch) {
// Set epoch index.
deck->setCurrentEpoch(epoch);
simtimer.setCurrentStepNum(step);
simtimer.setTotalTime(total_time);
// Update the timer.
if (deck->hasField("TSTEP")) {
simtimer.init(*deck);
} else {
if (epoch != 0) {
OPM_THROW(std::runtime_error, "No TSTEP in deck for epoch " << epoch);
}
simtimer.init(param);
}
simtimer.setCurrentStepNum(step);
simtimer.setTotalTime(total_time);
std::cout << " (number of steps: "
<< simtimer.numSteps() - step << ")\n\n" << std::flush;
// Report on start of epoch.
std::cout << "\n\n-------------- Starting epoch " << epoch << " --------------"
<< "\n (number of steps: "
<< simtimer.numSteps() - step << ")\n\n" << std::flush;
// Create new wells, well_state
#warning "HACK: required until the SimulationTimer, WellsManager and the EclipseWriter don't require the old parser anymore"
#if 0 // USE_NEW_PARSER
WellsManager wells(newParserDeck, *grid->c_grid(), props->permeability());
#else
WellsManager wells(*deck, *grid->c_grid(), props->permeability());
#endif
well_state.init(wells.c_wells(), state);
// Create new wells, well_state
WellsManager wells(*deck, *grid->c_grid(), props->permeability());
// @@@ HACK: we should really make a new well state and
// properly transfer old well state to it every epoch,
// since number of wells may change etc.
if (epoch == 0) {
well_state.init(wells.c_wells(), state);
}
// Create and run simulator.
SimulatorFullyImplicitBlackoil simulator(param,
*grid->c_grid(),
*new_props,
rock_comp->isActive() ? rock_comp.get() : 0,
wells,
linsolver,
grav,
outputWriter);
warnIfUnusedParams(param);
SimulatorReport report = simulator.run(simtimer, state, well_state);
if (output) {
report.reportParam(outStream);
// Create and run simulator.
SimulatorFullyImplicitBlackoil simulator(param,
*grid->c_grid(),
*new_props,
rock_comp->isActive() ? rock_comp.get() : 0,
wells,
linsolver,
grav,
outputWriter);
if (epoch == 0) {
warnIfUnusedParams(param);
}
SimulatorReport epoch_rep = simulator.run(simtimer, state, well_state);
if (output) {
epoch_rep.reportParam(epoch_os);
}
// Update total timing report and remember step number.
rep += epoch_rep;
step = simtimer.currentStepNum();
}
std::cout << "\n\n================ End of simulation ===============\n\n";