mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-10 02:35:34 -06:00
convert the examples and the tests to opm-parser
This commit is contained in:
parent
dd66aa80e8
commit
a72595f047
@ -85,35 +85,37 @@ try
|
||||
// If we have a "deck_filename", grid and props will be read from that.
|
||||
bool use_deck = param.has("deck_filename");
|
||||
EclipseStateConstPtr eclipseState;
|
||||
std::unique_ptr<EclipseGridParser> deck;
|
||||
std::unique_ptr<GridManager> grid;
|
||||
std::unique_ptr<BlackoilPropertiesInterface> props;
|
||||
std::unique_ptr<RockCompressibility> rock_comp;
|
||||
|
||||
ParserPtr parser(new Opm::Parser());
|
||||
Opm::DeckConstPtr newParserDeck;
|
||||
|
||||
BlackoilState state;
|
||||
// bool check_well_controls = false;
|
||||
// int max_well_control_iterations = 0;
|
||||
double gravity[3] = { 0.0 };
|
||||
if (use_deck) {
|
||||
ParserPtr parser(new Opm::Parser());
|
||||
std::string deck_filename = param.get<std::string>("deck_filename");
|
||||
newParserDeck = parser->parseFile(deck_filename);
|
||||
|
||||
eclipseState.reset( new EclipseState(parser->parseFile(deck_filename)));
|
||||
deck.reset(new EclipseGridParser(deck_filename));
|
||||
eclipseState.reset(new EclipseState(newParserDeck));
|
||||
// Grid init
|
||||
grid.reset(new GridManager(*deck));
|
||||
grid.reset(new GridManager(newParserDeck));
|
||||
// Rock and fluid init
|
||||
props.reset(new BlackoilPropertiesFromDeck(*deck, *grid->c_grid(), param));
|
||||
props.reset(new BlackoilPropertiesFromDeck(newParserDeck, *grid->c_grid(), param));
|
||||
// check_well_controls = param.getDefault("check_well_controls", false);
|
||||
// max_well_control_iterations = param.getDefault("max_well_control_iterations", 10);
|
||||
// Rock compressibility.
|
||||
rock_comp.reset(new RockCompressibility(*deck));
|
||||
rock_comp.reset(new RockCompressibility(newParserDeck));
|
||||
// Gravity.
|
||||
gravity[2] = deck->hasField("NOGRAV") ? 0.0 : unit::gravity;
|
||||
gravity[2] = newParserDeck->hasKeyword("NOGRAV") ? 0.0 : unit::gravity;
|
||||
// Init state variables (saturation and pressure).
|
||||
if (param.has("init_saturation")) {
|
||||
initStateBasic(*grid->c_grid(), *props, param, gravity[2], state);
|
||||
} else {
|
||||
initStateFromDeck(*grid->c_grid(), *props, *deck, gravity[2], state);
|
||||
initStateFromDeck(*grid->c_grid(), *props, newParserDeck, gravity[2], state);
|
||||
}
|
||||
initBlackoilSurfvol(*grid->c_grid(), *props, state);
|
||||
} else {
|
||||
@ -196,9 +198,7 @@ try
|
||||
}
|
||||
|
||||
|
||||
std::cout << "\n\n================ Starting main simulation loop ===============\n"
|
||||
<< " (number of epochs: "
|
||||
<< (use_deck ? deck->numberOfEpochs() : 1) << ")\n\n" << std::flush;
|
||||
std::cout << "\n\n================ Starting main simulation loop ===============\n";
|
||||
|
||||
SimulatorReport rep;
|
||||
if (!use_deck) {
|
||||
@ -225,36 +225,24 @@ try
|
||||
int step = 0;
|
||||
SimulatorTimer simtimer;
|
||||
// Use timer for last epoch to obtain total time.
|
||||
deck->setCurrentEpoch(deck->numberOfEpochs() - 1);
|
||||
simtimer.init(*deck);
|
||||
Opm::TimeMapPtr timeMap(new Opm::TimeMap(newParserDeck));
|
||||
simtimer.init(timeMap);
|
||||
const double total_time = simtimer.totalTime();
|
||||
for (int epoch = 0; epoch < deck->numberOfEpochs(); ++epoch) {
|
||||
// Set epoch index.
|
||||
deck->setCurrentEpoch(epoch);
|
||||
|
||||
// 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);
|
||||
}
|
||||
for (size_t reportStepIdx = 0; reportStepIdx < timeMap->numTimesteps(); ++reportStepIdx) {
|
||||
simtimer.setCurrentStepNum(step);
|
||||
simtimer.setTotalTime(total_time);
|
||||
|
||||
// Report on start of epoch.
|
||||
std::cout << "\n\n-------------- Starting epoch " << epoch << " --------------"
|
||||
// Report on start of report step.
|
||||
std::cout << "\n\n-------------- Starting report step " << reportStepIdx << " --------------"
|
||||
<< "\n (number of steps: "
|
||||
<< simtimer.numSteps() - step << ")\n\n" << std::flush;
|
||||
|
||||
// Create new wells, well_state
|
||||
WellsManager wells(eclipseState , epoch , *grid->c_grid(), props->permeability());
|
||||
WellsManager wells(eclipseState , reportStepIdx , *grid->c_grid(), props->permeability());
|
||||
// @@@ HACK: we should really make a new well state and
|
||||
// properly transfer old well state to it every epoch,
|
||||
// properly transfer old well state to it every report step,
|
||||
// since number of wells may change etc.
|
||||
if (epoch == 0) {
|
||||
if (reportStepIdx == 0) {
|
||||
well_state.init(wells.c_wells(), state);
|
||||
}
|
||||
|
||||
@ -268,7 +256,7 @@ try
|
||||
bcs.c_bcs(),
|
||||
linsolver,
|
||||
grav);
|
||||
if (epoch == 0) {
|
||||
if (reportStepIdx == 0) {
|
||||
warnIfUnusedParams(param);
|
||||
}
|
||||
SimulatorReport epoch_rep = simulator.run(simtimer, state, well_state);
|
||||
|
Loading…
Reference in New Issue
Block a user