Use Schedule constructor.

This commit is contained in:
Joakim Hove
2017-10-29 21:06:19 +01:00
committed by Joakim Hove (IT SI SIB)
parent 63f4b6d734
commit 566f4fbb02
55 changed files with 267 additions and 106 deletions

View File

@@ -138,25 +138,24 @@ int main(int argc, char** argv)
Opm::checkDeck(*deck, parser);
Opm::MissingFeatures::checkKeywords(*deck);
}
std::shared_ptr<Opm::EclipseState> eclipseState =
std::make_shared< Opm::EclipseState > ( *deck, parseContext );
Opm::Runspec runspec( *deck );
const auto& phases = runspec.phases();
// Twophase cases
std::shared_ptr<Opm::EclipseState> eclipseState = std::make_shared< Opm::EclipseState > ( *deck, parseContext );
std::shared_ptr<Opm::Schedule> schedule = std::make_shared<Opm::Schedule>(*deck, eclipseState->getInputGrid(), eclipseState->get3DProperties(), phases, parseContext);
std::shared_ptr<Opm::SummaryConfig> summary_config = std::make_shared<Opm::SummaryConfig>(*deck, *schedule, eclipseState->getTableManager(), parseContext);
// Twophase cases
if( phases.size() == 2 ) {
// oil-gas
if (phases.active( Opm::Phase::GAS ))
{
Opm::flowEbosGasOilSetDeck(*deck, *eclipseState);
Opm::flowEbosGasOilSetDeck(*deck, *eclipseState, *schedule, *summary_config);
return Opm::flowEbosGasOilMain(argc, argv);
}
// oil-water
else if ( phases.active( Opm::Phase::WATER ) )
{
Opm::flowEbosOilWaterSetDeck(*deck, *eclipseState);
Opm::flowEbosOilWaterSetDeck(*deck, *eclipseState, *schedule, *summary_config);
return Opm::flowEbosOilWaterMain(argc, argv);
}
else {
@@ -167,17 +166,17 @@ int main(int argc, char** argv)
}
// Polymer case
else if ( phases.active( Opm::Phase::POLYMER ) ) {
Opm::flowEbosPolymerSetDeck(*deck, *eclipseState);
Opm::flowEbosPolymerSetDeck(*deck, *eclipseState, *schedule, *summary_config);
return Opm::flowEbosPolymerMain(argc, argv);
}
// Solvent case
else if ( phases.active( Opm::Phase::SOLVENT ) ) {
Opm::flowEbosSolventSetDeck(*deck, *eclipseState);
Opm::flowEbosSolventSetDeck(*deck, *eclipseState, *schedule, *summary_config);
return Opm::flowEbosSolventMain(argc, argv);
}
// Blackoil case
else if( phases.size() == 3 ) {
Opm::flowEbosBlackoilSetDeck(*deck, *eclipseState);
Opm::flowEbosBlackoilSetDeck(*deck, *eclipseState, *schedule, *summary_config);
return Opm::flowEbosBlackoilMain(argc, argv);
}
else

View File

@@ -36,7 +36,6 @@ main(int argc, char** argv)
{
typedef UnstructuredGrid Grid;
typedef Opm::SimulatorFullyImplicitBlackoilMultiSegment<Grid> Simulator;
Opm::FlowMain<Grid, Simulator> mainfunc;
return mainfunc.execute(argc, argv);
}

View File

@@ -88,6 +88,7 @@ try
// If we have a "deck_filename", grid and props will be read from that.
bool use_deck = param.has("deck_filename");
std::shared_ptr< EclipseState > eclipseState;
std::shared_ptr< Schedule > schedule;
std::unique_ptr<GridManager> grid;
std::unique_ptr<BlackoilPropertiesInterface> props;
std::unique_ptr<RockCompressibility> rock_comp;
@@ -104,6 +105,12 @@ try
std::string deck_filename = param.get<std::string>("deck_filename");
auto deck = parser.parseFile(deck_filename , parseContext);
eclipseState.reset(new EclipseState(deck, parseContext));
schedule.reset( new Schedule(deck,
eclipseState->getInputGrid(),
eclipseState->get3DProperties(),
eclipseState->runspec().phases(),
parseContext));
// Grid init
grid.reset(new GridManager(eclipseState->getInputGrid()));
@@ -234,7 +241,7 @@ try
int step = 0;
SimulatorTimer simtimer;
// Use timer for last epoch to obtain total time.
const auto& timeMap = eclipseState->getSchedule().getTimeMap();
const auto& timeMap = schedule->getTimeMap();
simtimer.init(timeMap);
const double total_time = simtimer.totalTime();
for (size_t reportStepIdx = 0; reportStepIdx < timeMap.numTimesteps(); ++reportStepIdx) {
@@ -247,7 +254,7 @@ try
<< simtimer.numSteps() - step << ")\n\n" << std::flush;
// Create new wells, well_state
WellsManager wells(*eclipseState , reportStepIdx , *grid->c_grid());
WellsManager wells(*eclipseState , *schedule, reportStepIdx , *grid->c_grid());
// @@@ HACK: we should really make a new well state and
// properly transfer old well state to it every report step,
// since number of wells may change etc.

View File

@@ -101,7 +101,7 @@ try
// If we have a "deck_filename", grid and props will be read from that.
bool use_deck = param.has("deck_filename");
std::shared_ptr< EclipseState > eclipseState;
std::shared_ptr< Schedule > schedule;
std::unique_ptr<GridManager> grid;
std::unique_ptr<IncompPropertiesInterface> props;
std::unique_ptr<RockCompressibility> rock_comp;
@@ -117,6 +117,11 @@ try
std::string deck_filename = param.get<std::string>("deck_filename");
auto deck = parser.parseFile(deck_filename , parseContext);
eclipseState.reset( new EclipseState(deck, parseContext));
schedule.reset( new Schedule(deck,
eclipseState->getInputGrid(),
eclipseState->get3DProperties(),
eclipseState->runspec().phases(),
parseContext));
// Grid init
grid.reset(new GridManager(eclipseState->getInputGrid()));
{
@@ -244,7 +249,7 @@ try
rep = simulator.run(simtimer, *state, well_state);
} else {
// With a deck, we may have more epochs etc.
const auto& timeMap = eclipseState->getSchedule().getTimeMap();
const auto& timeMap = schedule->getTimeMap();
std::cout << "\n\n================ Starting main simulation loop ===============\n"
<< " (number of report steps: "
@@ -268,7 +273,7 @@ try
// << simtimer.numSteps() - step << ")\n\n" << std::flush;
// Create new wells, well_state
WellsManager wells(*eclipseState , reportStepIdx , *grid->c_grid());
WellsManager wells(*eclipseState, *schedule, reportStepIdx , *grid->c_grid());
// @@@ HACK: we should really make a new well state and
// properly transfer old well state to it every report step,
// since number of wells may change etc.

View File

@@ -107,6 +107,7 @@ try
std::unique_ptr<RockCompressibility> rock_comp;
std::unique_ptr<TwophaseState> state;
std::shared_ptr< EclipseState > eclipseState;
std::shared_ptr< Schedule > schedule;
// bool check_well_controls = false;
// int max_well_control_iterations = 0;
@@ -116,6 +117,11 @@ try
Opm::ParseContext parseContext;
auto deck = parser.parseFile(deck_filename, parseContext);
eclipseState.reset(new EclipseState(deck , parseContext));
schedule.reset( new Schedule(deck,
eclipseState->getInputGrid(),
eclipseState->get3DProperties(),
eclipseState->runspec().phases(),
parseContext));
// Grid init
grid.reset(new GridManager(eclipseState->getInputGrid()));
@@ -248,7 +254,7 @@ try
} else {
// With a deck, we may have more report steps etc.
WellState well_state;
const auto& timeMap = eclipseState->getSchedule().getTimeMap();
const auto& timeMap = schedule->getTimeMap();
SimulatorTimer simtimer;
for (size_t reportStepIdx = 0; reportStepIdx < timeMap.numTimesteps(); ++reportStepIdx) {
// Report on start of report step.
@@ -257,7 +263,7 @@ try
<< timeMap.numTimesteps() - reportStepIdx << ")\n\n" << std::flush;
// Create new wells, well_state
WellsManager wells(*eclipseState , reportStepIdx , *grid->c_grid());
WellsManager wells(*eclipseState , *schedule, reportStepIdx , *grid->c_grid());
// @@@ HACK: we should really make a new well state and
// properly transfer old well state to it every report step,
// since number of wells may change etc.

View File

@@ -96,6 +96,7 @@ try
Opm::PolymerProperties poly_props;
Opm::Deck deck;
std::unique_ptr< EclipseState > eclipseState;
std::unique_ptr< Schedule> schedule;
// bool check_well_controls = false;
// int max_well_control_iterations = 0;
double gravity[3] = { 0.0 };
@@ -105,7 +106,7 @@ try
Opm::ParseContext parseContext({{ ParseContext::PARSE_RANDOM_SLASH , InputError::IGNORE }});
deck = parser.parseFile(deck_filename , parseContext);
eclipseState.reset( new EclipseState(deck , parseContext) );
schedule.reset( new Schedule(deck, eclipseState->getInputGrid(), eclipseState->get3DProperties(), eclipseState->runspec().phases(), parseContext ));
// Grid init
grid.reset(new GridManager(eclipseState->getInputGrid()));
{
@@ -282,13 +283,13 @@ try
// Create new wells, polymer inflow controls.
eclipseState.reset( new EclipseState( deck ) );
WellsManager wells(*eclipseState , reportStepIdx , *grid->c_grid());
WellsManager wells(*eclipseState , *schedule, reportStepIdx , *grid->c_grid());
boost::scoped_ptr<PolymerInflowInterface> polymer_inflow;
if (use_wpolymer) {
if (wells.c_wells() == 0) {
OPM_THROW(std::runtime_error, "Cannot control polymer injection via WPOLYMER without wells.");
}
polymer_inflow.reset(new PolymerInflowFromDeck(*eclipseState, *wells.c_wells(), props->numCells(), simtimer.currentStepNum()));
polymer_inflow.reset(new PolymerInflowFromDeck( *schedule, *wells.c_wells(), props->numCells(), simtimer.currentStepNum()));
} else {
polymer_inflow.reset(new PolymerInflowBasic(param.getDefault("poly_start_days", 300.0)*Opm::unit::day,
param.getDefault("poly_end_days", 800.0)*Opm::unit::day,

View File

@@ -94,6 +94,7 @@ try
boost::scoped_ptr<IncompPropertiesInterface> props;
boost::scoped_ptr<RockCompressibility> rock_comp;
std::shared_ptr< EclipseState > eclipseState;
std::shared_ptr<Schedule> schedule;
std::unique_ptr<PolymerState> state;
Opm::PolymerProperties poly_props;
// bool check_well_controls = false;
@@ -106,7 +107,7 @@ try
deck = parser.parseFile(deck_filename , parseContext);
eclipseState.reset(new Opm::EclipseState(deck , parseContext));
schedule.reset( new Opm::Schedule(deck, eclipseState->getInputGrid(), eclipseState->get3DProperties(), eclipseState->runspec().phases(), parseContext));
// Grid init
grid.reset(new GridManager(eclipseState->getInputGrid()));
{
@@ -295,7 +296,7 @@ try
WellState well_state;
int step = 0;
const auto& timeMap = eclipseState->getSchedule().getTimeMap();
const auto& timeMap = schedule->getTimeMap();
SimulatorTimer simtimer;
simtimer.init(timeMap);
// Check for WPOLYMER presence in last epoch to decide
@@ -316,13 +317,13 @@ try
<< simtimer.numSteps() - step << ")\n\n" << std::flush;
// Create new wells, polymer inflow controls.
WellsManager wells(*eclipseState , reportStepIdx , *grid->c_grid());
WellsManager wells(*eclipseState , *schedule, reportStepIdx , *grid->c_grid());
boost::scoped_ptr<PolymerInflowInterface> polymer_inflow;
if (use_wpolymer) {
if (wells.c_wells() == 0) {
OPM_THROW(std::runtime_error, "Cannot control polymer injection via WPOLYMER without wells.");
}
polymer_inflow.reset(new PolymerInflowFromDeck(*eclipseState, *wells.c_wells(), props->numCells(), simtimer.currentStepNum()));
polymer_inflow.reset(new PolymerInflowFromDeck(*schedule, *wells.c_wells(), props->numCells(), simtimer.currentStepNum()));
} else {
polymer_inflow.reset(new PolymerInflowBasic(param.getDefault("poly_start_days", 300.0)*Opm::unit::day,
param.getDefault("poly_end_days", 800.0)*Opm::unit::day,

View File

@@ -38,6 +38,7 @@ try
Opm::Parser parser;
Opm::Deck deck = parser.parseFile(file_name , parseContext);
Opm::EclipseState eclipseState(deck , parseContext);
Opm::Schedule schedule(deck, eclipseState.getInputGrid(), eclipseState.get3DProperties(), eclipseState.runspec().phases(), parseContext);
std::cout << "Done!" << std::endl;
// Setup grid
@@ -48,7 +49,7 @@ try
RockCompressibility rock_comp(eclipseState);
// Finally handle the wells
WellsManager wells(eclipseState , 0 , *grid.c_grid());
WellsManager wells(eclipseState , schedule, 0 , *grid.c_grid());
double gravity[3] = {0.0, 0.0, parameters.getDefault<double>("gravity", 0.0)};
Opm::LinearSolverFactory linsolver(parameters);