mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
re-add the epoch stuff
this is required until the new time step handling code lands...
This commit is contained in:
parent
d7d25253f3
commit
c23b38f60b
@ -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 outStream;
|
std::ofstream epoch_os;
|
||||||
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 + "/timing.param";
|
std::string filename = output_dir + "/epoch_timing.param";
|
||||||
outStream.open(filename.c_str(), std::fstream::trunc | std::fstream::out);
|
epoch_os.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);
|
||||||
@ -202,59 +202,67 @@ try
|
|||||||
|
|
||||||
|
|
||||||
std::cout << "\n\n================ Starting main simulation loop ===============\n"
|
std::cout << "\n\n================ Starting main simulation loop ===============\n"
|
||||||
<< "\n\n" << std::flush;
|
<< " (number of epochs: "
|
||||||
|
<< (deck->numberOfEpochs()) << ")\n\n" << std::flush;
|
||||||
|
|
||||||
SimulatorReport rep;
|
SimulatorReport rep;
|
||||||
|
// With a deck, we may have more epochs etc.
|
||||||
WellState well_state;
|
WellState well_state;
|
||||||
SimulatorTimer simtimer;
|
|
||||||
int step = 0;
|
int step = 0;
|
||||||
|
SimulatorTimer simtimer;
|
||||||
// Update the timer.
|
// Use timer for last epoch to obtain total time.
|
||||||
#warning "HACK: required until the SimulationTimer, WellsManager and the EclipseWriter don't require the old parser anymore"
|
deck->setCurrentEpoch(deck->numberOfEpochs() - 1);
|
||||||
#if 0 // USE_NEW_PARSER
|
simtimer.init(*deck);
|
||||||
if (newParserDeck->hasKeyword("TSTEP")) {
|
|
||||||
simtimer.init(newParserDeck);
|
|
||||||
} else {
|
|
||||||
simtimer.init(param);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
if (deck->hasField("TSTEP")) {
|
|
||||||
simtimer.init(*deck);
|
|
||||||
} else {
|
|
||||||
simtimer.init(param);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
const double total_time = simtimer.totalTime();
|
const double total_time = simtimer.totalTime();
|
||||||
|
for (int epoch = 0; epoch < deck->numberOfEpochs(); ++epoch) {
|
||||||
|
// Set epoch index.
|
||||||
|
deck->setCurrentEpoch(epoch);
|
||||||
|
|
||||||
simtimer.setCurrentStepNum(step);
|
// Update the timer.
|
||||||
simtimer.setTotalTime(total_time);
|
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: "
|
// Report on start of epoch.
|
||||||
<< simtimer.numSteps() - step << ")\n\n" << std::flush;
|
std::cout << "\n\n-------------- Starting epoch " << epoch << " --------------"
|
||||||
|
<< "\n (number of steps: "
|
||||||
|
<< simtimer.numSteps() - step << ")\n\n" << std::flush;
|
||||||
|
|
||||||
// Create new wells, well_state
|
// Create new wells, well_state
|
||||||
#warning "HACK: required until the SimulationTimer, WellsManager and the EclipseWriter don't require the old parser anymore"
|
WellsManager wells(*deck, *grid->c_grid(), props->permeability());
|
||||||
#if 0 // USE_NEW_PARSER
|
// @@@ HACK: we should really make a new well state and
|
||||||
WellsManager wells(newParserDeck, *grid->c_grid(), props->permeability());
|
// properly transfer old well state to it every epoch,
|
||||||
#else
|
// since number of wells may change etc.
|
||||||
WellsManager wells(*deck, *grid->c_grid(), props->permeability());
|
if (epoch == 0) {
|
||||||
#endif
|
well_state.init(wells.c_wells(), state);
|
||||||
well_state.init(wells.c_wells(), state);
|
}
|
||||||
|
|
||||||
// Create and run simulator.
|
// Create and run simulator.
|
||||||
SimulatorFullyImplicitBlackoil simulator(param,
|
SimulatorFullyImplicitBlackoil simulator(param,
|
||||||
*grid->c_grid(),
|
*grid->c_grid(),
|
||||||
*new_props,
|
*new_props,
|
||||||
rock_comp->isActive() ? rock_comp.get() : 0,
|
rock_comp->isActive() ? rock_comp.get() : 0,
|
||||||
wells,
|
wells,
|
||||||
linsolver,
|
linsolver,
|
||||||
grav,
|
grav,
|
||||||
outputWriter);
|
outputWriter);
|
||||||
|
if (epoch == 0) {
|
||||||
warnIfUnusedParams(param);
|
warnIfUnusedParams(param);
|
||||||
SimulatorReport report = simulator.run(simtimer, state, well_state);
|
}
|
||||||
if (output) {
|
SimulatorReport epoch_rep = simulator.run(simtimer, state, well_state);
|
||||||
report.reportParam(outStream);
|
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";
|
std::cout << "\n\n================ End of simulation ===============\n\n";
|
||||||
|
Loading…
Reference in New Issue
Block a user