mirror of
https://github.com/OPM/opm-simulators.git
synced 2024-12-30 11:06:55 -06:00
Fix output statements in run().
This fixes the following bugs: - No longer overwrite the matlab-output files each step. - Create output also for the initial state. - Change filenames of matlab-output by one (initial state is 000.txt, final state is NNN.txt and not (NNN-1).txt for total of NNN steps). - Eclipse binary output matches eclipse output (includes the same steps including initial state) for the same case. Also added several comments outlining the parts of the run() function.
This commit is contained in:
parent
687465d591
commit
5f9841eacc
@ -266,10 +266,11 @@ namespace Opm
|
|||||||
|
|
||||||
// Main simulation loop.
|
// Main simulation loop.
|
||||||
while (!timer.done()) {
|
while (!timer.done()) {
|
||||||
// Report timestep and (optionally) write state to disk.
|
// Report timestep.
|
||||||
step_timer.start();
|
step_timer.start();
|
||||||
timer.report(std::cout);
|
timer.report(std::cout);
|
||||||
|
|
||||||
|
// Create wells and well state.
|
||||||
WellsManager wells_manager(eclipse_state_,
|
WellsManager wells_manager(eclipse_state_,
|
||||||
timer.currentStepNum(),
|
timer.currentStepNum(),
|
||||||
Opm::UgGridHelpers::numCells(grid_),
|
Opm::UgGridHelpers::numCells(grid_),
|
||||||
@ -280,67 +281,67 @@ namespace Opm
|
|||||||
Opm::UgGridHelpers::cell2Faces(grid_),
|
Opm::UgGridHelpers::cell2Faces(grid_),
|
||||||
Opm::UgGridHelpers::beginFaceCentroids(grid_),
|
Opm::UgGridHelpers::beginFaceCentroids(grid_),
|
||||||
props_.permeability());
|
props_.permeability());
|
||||||
|
|
||||||
const Wells* wells = wells_manager.c_wells();
|
const Wells* wells = wells_manager.c_wells();
|
||||||
WellStateFullyImplicitBlackoil well_state;
|
WellStateFullyImplicitBlackoil well_state;
|
||||||
well_state.init(wells, state);
|
well_state.init(wells, state);
|
||||||
|
if (timer.currentStepNum() != 0) {
|
||||||
if (timer.currentStepNum() == 0) {
|
// Transfer previous well state to current.
|
||||||
output_writer_.writeInit(timer);
|
|
||||||
} else {
|
|
||||||
// Transfer previous well state tu current.
|
|
||||||
well_state.partialCopy(prev_well_state, *wells, prev_well_state.numWells());
|
well_state.partialCopy(prev_well_state, *wells, prev_well_state.numWells());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Output state at start of time step.
|
||||||
if (output_ && (timer.currentStepNum() % output_interval_ == 0)) {
|
if (output_ && (timer.currentStepNum() % output_interval_ == 0)) {
|
||||||
if (output_vtk_) {
|
if (output_vtk_) {
|
||||||
outputStateVtk(grid_, state, timer.currentStepNum(), output_dir_);
|
outputStateVtk(grid_, state, timer.currentStepNum(), output_dir_);
|
||||||
}
|
}
|
||||||
outputStateMatlab(grid_, state, timer.currentStepNum(), output_dir_);
|
outputStateMatlab(grid_, state, timer.currentStepNum(), output_dir_);
|
||||||
outputWellStateMatlab(well_state,timer.currentStepNum(), output_dir_);
|
outputWellStateMatlab(well_state,timer.currentStepNum(), output_dir_);
|
||||||
|
}
|
||||||
|
if (output_) {
|
||||||
|
if (timer.currentStepNum() == 0) {
|
||||||
|
output_writer_.writeInit(timer);
|
||||||
|
}
|
||||||
|
output_writer_.writeTimeStep(timer, state, well_state.basicWellState());
|
||||||
}
|
}
|
||||||
|
|
||||||
SimulatorReport sreport;
|
// Max oil saturation (for VPPARS), hysteresis update.
|
||||||
|
|
||||||
FullyImplicitBlackoilSolver<T> solver(param_, grid_, props_, geo_, rock_comp_props_, *wells, solver_, has_disgas_, has_vapoil_);
|
|
||||||
// Max oil saturation
|
|
||||||
props_.updateSatOilMax(state.saturation());
|
props_.updateSatOilMax(state.saturation());
|
||||||
|
|
||||||
// Hysteresis
|
|
||||||
props_.updateSatHyst(state.saturation(), allcells_);
|
props_.updateSatHyst(state.saturation(), allcells_);
|
||||||
|
|
||||||
// Run solver.
|
// Run a single step of the solver.
|
||||||
solver_timer.start();
|
solver_timer.start();
|
||||||
|
FullyImplicitBlackoilSolver<T> solver(param_, grid_, props_, geo_, rock_comp_props_, *wells, solver_, has_disgas_, has_vapoil_);
|
||||||
solver.step(timer.currentStepLength(), state, well_state);
|
solver.step(timer.currentStepLength(), state, well_state);
|
||||||
|
|
||||||
// Stop timer and report.
|
|
||||||
solver_timer.stop();
|
solver_timer.stop();
|
||||||
|
|
||||||
|
// Report timing.
|
||||||
const double st = solver_timer.secsSinceStart();
|
const double st = solver_timer.secsSinceStart();
|
||||||
std::cout << "Fully implicit solver took: " << st << " seconds." << std::endl;
|
std::cout << "Fully implicit solver took: " << st << " seconds." << std::endl;
|
||||||
|
|
||||||
stime += st;
|
stime += st;
|
||||||
sreport.pressure_time = st;
|
|
||||||
|
|
||||||
sreport.total_time = step_timer.secsSinceStart();
|
|
||||||
if (output_) {
|
if (output_) {
|
||||||
sreport.reportParam(tstep_os);
|
SimulatorReport step_report;
|
||||||
|
step_report.pressure_time = st;
|
||||||
if (output_vtk_) {
|
step_report.total_time = step_timer.secsSinceStart();
|
||||||
outputStateVtk(grid_, state, timer.currentStepNum(), output_dir_);
|
step_report.reportParam(tstep_os);
|
||||||
}
|
|
||||||
outputStateMatlab(grid_, state, timer.currentStepNum(), output_dir_);
|
|
||||||
outputWellStateMatlab(well_state,timer.currentStepNum(), output_dir_);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
output_writer_.writeTimeStep(timer, state, well_state.basicWellState());
|
// Increment timer, remember well state.
|
||||||
|
|
||||||
++timer;
|
++timer;
|
||||||
prev_well_state = well_state;
|
prev_well_state = well_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
total_timer.stop();
|
// Write final simulation state.
|
||||||
|
if (output_) {
|
||||||
|
if (output_vtk_) {
|
||||||
|
outputStateVtk(grid_, state, timer.currentStepNum(), output_dir_);
|
||||||
|
}
|
||||||
|
outputStateMatlab(grid_, state, timer.currentStepNum(), output_dir_);
|
||||||
|
outputWellStateMatlab(prev_well_state, timer.currentStepNum(), output_dir_);
|
||||||
|
output_writer_.writeTimeStep(timer, state, prev_well_state.basicWellState());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stop timer and create timing report
|
||||||
|
total_timer.stop();
|
||||||
SimulatorReport report;
|
SimulatorReport report;
|
||||||
report.pressure_time = stime;
|
report.pressure_time = stime;
|
||||||
report.transport_time = 0.0;
|
report.transport_time = 0.0;
|
||||||
|
Loading…
Reference in New Issue
Block a user