use the SimulatorTimer which is based on opm-parser's TimeMap

at least if the USE_NEW_PARSER preprocessor macro in sim_fibo_ad.cpp
is set to 1. (if it is false, nothing changes.)
This commit is contained in:
Andreas Lauser
2014-02-20 17:57:44 +01:00
parent dd080c4515
commit 5de11630d5

View File

@@ -104,7 +104,7 @@ try
Opm::ParserPtr newParser(new Opm::Parser() ); Opm::ParserPtr newParser(new Opm::Parser() );
Opm::DeckConstPtr newParserDeck = newParser->parseFile( deck_filename ); Opm::DeckConstPtr newParserDeck = newParser->parseFile( deck_filename );
#warning "HACK: required until the SimulationTimer, WellsManager and the EclipseWriter don't require the old parser anymore" #warning "HACK: required until the WellsManager and the EclipseWriter don't require the old parser anymore"
std::shared_ptr<EclipseGridParser> deck; std::shared_ptr<EclipseGridParser> deck;
deck.reset(new EclipseGridParser(deck_filename)); deck.reset(new EclipseGridParser(deck_filename));
#else #else
@@ -119,7 +119,7 @@ try
grid.reset(new GridManager(*deck)); grid.reset(new GridManager(*deck));
#endif #endif
#warning "HACK: required until the SimulationTimer, WellsManager and the EclipseWriter don't require the old parser anymore" #warning "HACK: required until the WellsManager and the EclipseWriter don't require the old parser anymore"
#if 0 // USE_NEW_PARSER #if 0 // USE_NEW_PARSER
Opm::EclipseWriter outputWriter(param, newParserDeck, share_obj(*grid->c_grid())); Opm::EclipseWriter outputWriter(param, newParserDeck, share_obj(*grid->c_grid()));
#else #else
@@ -179,7 +179,7 @@ try
// Write parameters used for later reference. // Write parameters used for later reference.
bool output = param.getDefault("output", true); bool output = param.getDefault("output", true);
std::ofstream epoch_os; std::ofstream outStream;
std::string output_dir; std::string output_dir;
if (output) { if (output) {
output_dir = output_dir =
@@ -191,8 +191,8 @@ try
catch (...) { catch (...) {
OPM_THROW(std::runtime_error, "Creating directories failed: " << fpath); OPM_THROW(std::runtime_error, "Creating directories failed: " << fpath);
} }
std::string filename = output_dir + "/epoch_timing.param"; std::string filename = output_dir + "/timing.param";
epoch_os.open(filename.c_str(), std::fstream::trunc | std::fstream::out); outStream.open(filename.c_str(), std::fstream::trunc | std::fstream::out);
// open file to clean it. The file is appended to in SimulatorTwophase // open file to clean it. The file is appended to in SimulatorTwophase
filename = output_dir + "/step_timing.param"; filename = output_dir + "/step_timing.param";
std::fstream step_os(filename.c_str(), std::fstream::trunc | std::fstream::out); std::fstream step_os(filename.c_str(), std::fstream::trunc | std::fstream::out);
@@ -200,7 +200,48 @@ try
param.writeParam(output_dir + "/simulation.param"); param.writeParam(output_dir + "/simulation.param");
} }
#warning "TODO: convert the well handling code to the new parser"
#if USE_NEW_PARSER
std::cout << "\n\n================ Starting main simulation loop ===============\n"
<< std::flush;
WellState well_state;
Opm::TimeMapPtr timeMap(new Opm::TimeMap(newParserDeck));
SimulatorTimer simtimer;
// 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.
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);
simtimer.init(timeMap);
SimulatorReport report = simulator.run(simtimer, state, well_state);
if (output) {
report.reportParam(outStream);
warnIfUnusedParams(param);
}
std::cout << "\n\n================ End of simulation ===============\n\n";
report.report(std::cout);
if (output) {
std::string filename = output_dir + "/walltime.param";
std::fstream tot_os(filename.c_str(),std::fstream::trunc | std::fstream::out);
report.reportParam(tot_os);
}
#else
std::cout << "\n\n================ Starting main simulation loop ===============\n" std::cout << "\n\n================ Starting main simulation loop ===============\n"
<< " (number of epochs: " << " (number of epochs: "
<< (deck->numberOfEpochs()) << ")\n\n" << std::flush; << (deck->numberOfEpochs()) << ")\n\n" << std::flush;
@@ -258,7 +299,7 @@ try
} }
SimulatorReport epoch_rep = simulator.run(simtimer, state, well_state); SimulatorReport epoch_rep = simulator.run(simtimer, state, well_state);
if (output) { if (output) {
epoch_rep.reportParam(epoch_os); epoch_rep.reportParam(outStream);
} }
// Update total timing report and remember step number. // Update total timing report and remember step number.
rep += epoch_rep; rep += epoch_rep;
@@ -273,7 +314,7 @@ try
std::fstream tot_os(filename.c_str(),std::fstream::trunc | std::fstream::out); std::fstream tot_os(filename.c_str(),std::fstream::trunc | std::fstream::out);
rep.reportParam(tot_os); rep.reportParam(tot_os);
} }
#endif
} }
catch (const std::exception &e) { catch (const std::exception &e) {
std::cerr << "Program threw an exception: " << e.what() << "\n"; std::cerr << "Program threw an exception: " << e.what() << "\n";