Schedule no longer part of EclipseState.

This commit is contained in:
Joakim Hove 2017-10-24 20:38:15 +02:00
parent bbfd5b6413
commit 19318e5019
7 changed files with 76 additions and 23 deletions

View File

@ -327,6 +327,7 @@ namespace Opm
/// Construct wells from deck.
WellsManager::WellsManager(const Opm::EclipseState& eclipseState,
const Opm::Schedule& schedule,
const size_t timeStep,
const UnstructuredGrid& grid)
: w_(0), is_parallel_run_(false)
@ -334,7 +335,7 @@ namespace Opm
// TODO: not sure about the usage of this WellsManager constructor
// TODO: not sure whether this is the correct thing to do here.
DynamicListEconLimited dummy_list_econ_limited;
init(eclipseState, timeStep, UgGridHelpers::numCells(grid),
init(eclipseState, schedule, timeStep, UgGridHelpers::numCells(grid),
UgGridHelpers::globalCell(grid), UgGridHelpers::cartDims(grid),
UgGridHelpers::dimensions(grid),
UgGridHelpers::cell2Faces(grid), UgGridHelpers::beginFaceCentroids(grid),

View File

@ -85,6 +85,7 @@ namespace Opm
/// the wells handeled by another process. Defaults to empty set.
template<class F2C, class FC>
WellsManager(const Opm::EclipseState& eclipseState,
const Opm::Schedule& schedule,
const size_t timeStep,
int num_cells,
const int* global_cell,
@ -97,6 +98,7 @@ namespace Opm
const std::unordered_set<std::string>& deactivated_wells = std::unordered_set<std::string> ());
WellsManager(const Opm::EclipseState& eclipseState,
const Opm::Schedule& schedule,
const size_t timeStep,
const UnstructuredGrid& grid);
/// Destructor.
@ -154,6 +156,7 @@ namespace Opm
private:
template<class C2F, class FC>
void init(const Opm::EclipseState& eclipseState,
const Opm::Schedule& schedule,
const size_t timeStep,
int num_cells,
const int* global_cell,

View File

@ -309,6 +309,7 @@ void WellsManager::createWellsFromSpecs(std::vector<const Well*>& wells, size_t
template <class C2F, class FC>
WellsManager::
WellsManager(const Opm::EclipseState& eclipseState,
const Opm::Schedule& schedule,
const size_t timeStep,
int number_of_cells,
const int* global_cell,
@ -321,7 +322,7 @@ WellsManager(const Opm::EclipseState& eclipseState,
const std::unordered_set<std::string>& deactivated_wells)
: w_(0), is_parallel_run_(is_parallel_run)
{
init(eclipseState, timeStep, number_of_cells, global_cell,
init(eclipseState, schedule, timeStep, number_of_cells, global_cell,
cart_dims, dimensions,
cell_to_faces, begin_face_centroids, list_econ_limited, deactivated_wells);
}
@ -330,6 +331,7 @@ WellsManager(const Opm::EclipseState& eclipseState,
template <class C2F, class FC>
void
WellsManager::init(const Opm::EclipseState& eclipseState,
const Opm::Schedule& schedule,
const size_t timeStep,
int number_of_cells,
const int* global_cell,
@ -346,7 +348,7 @@ WellsManager::init(const Opm::EclipseState& eclipseState,
"the corresponding grid is 3-dimensional.");
}
if (eclipseState.getSchedule().numWells() == 0) {
if (schedule.numWells() == 0) {
OPM_MESSAGE("No wells specified in Schedule section, "
"initializing no wells");
return;
@ -368,7 +370,6 @@ WellsManager::init(const Opm::EclipseState& eclipseState,
// For easy lookup:
std::map<std::string, int> well_names_to_index;
const auto& schedule = eclipseState.getSchedule();
auto wells = schedule.getWells(timeStep);
std::vector<int> wells_on_proc;

View File

@ -48,6 +48,11 @@ BOOST_AUTO_TEST_CASE(TestStoppedWells)
Opm::Deck deck(parser.parseFile(filename , parseContext));
Opm::EclipseState eclipseState(deck , parseContext);
Opm::GridManager gridManager(eclipseState.getInputGrid());
const auto& grid = eclipseState.getInputGrid();
const TableManager table ( deck );
const Eclipse3DProperties eclipseProperties ( deck , table, grid);
const Schedule sched(deck, grid, eclipseProperties, Phases(true, true, true), parseContext );
double target_surfacerate_inj;
double target_surfacerate_prod;
@ -58,7 +63,7 @@ BOOST_AUTO_TEST_CASE(TestStoppedWells)
// Both wells are open in the first schedule step
{
Opm::WellsManager wellsManager(eclipseState , 0 , *gridManager.c_grid());
Opm::WellsManager wellsManager(eclipseState , sched, 0, *gridManager.c_grid());
const Wells* wells = wellsManager.c_wells();
const struct WellControls* ctrls0 = wells->ctrls[0];
const struct WellControls* ctrls1 = wells->ctrls[1];
@ -78,7 +83,7 @@ BOOST_AUTO_TEST_CASE(TestStoppedWells)
// The injector is stopped
{
Opm::WellsManager wellsManager(eclipseState , 1 , *gridManager.c_grid());
Opm::WellsManager wellsManager(eclipseState, sched, 1 , *gridManager.c_grid());
const Wells* wells = wellsManager.c_wells();
const struct WellControls* ctrls0 = wells->ctrls[0];
const struct WellControls* ctrls1 = wells->ctrls[1];

View File

@ -46,15 +46,20 @@ BOOST_AUTO_TEST_CASE(AddWellsAndGroupToCollection) {
Deck deck = parser.parseFile(scheduleFile, parseContext);
EclipseState eclipseState(deck, parseContext);
PhaseUsage pu = phaseUsageFromDeck(eclipseState);
const auto& grid = eclipseState.getInputGrid();
const TableManager table ( deck );
const Eclipse3DProperties eclipseProperties ( deck , table, grid);
const Schedule sched(deck, grid, eclipseProperties, Phases(true, true, true), parseContext );
WellCollection collection;
// Add groups to WellCollection
const auto& fieldGroup = eclipseState.getSchedule().getGroup("FIELD");
const auto& fieldGroup = sched.getGroup("FIELD");
collection.addField(fieldGroup, 2, pu);
collection.addGroup( eclipseState.getSchedule().getGroup( "G1" ), fieldGroup.name(), 2, pu);
collection.addGroup( eclipseState.getSchedule().getGroup( "G2" ), fieldGroup.name(), 2, pu);
collection.addGroup( sched.getGroup( "G1" ), fieldGroup.name(), 2, pu);
collection.addGroup( sched.getGroup( "G2" ), fieldGroup.name(), 2, pu);
BOOST_CHECK_EQUAL("FIELD", collection.findNode("FIELD")->name());
BOOST_CHECK_EQUAL("FIELD", collection.findNode("G1")->getParent()->name());
@ -62,7 +67,7 @@ BOOST_AUTO_TEST_CASE(AddWellsAndGroupToCollection) {
// Add wells to WellCollection
WellCollection wellCollection;
auto wells = eclipseState.getSchedule().getWells();
auto wells = sched.getWells();
for (size_t i=0; i<wells.size(); i++) {
collection.addWell(wells[i], 2, pu);
}

View File

@ -53,9 +53,14 @@ BOOST_AUTO_TEST_CASE(ConstructGroupFromWell) {
Parser parser;
Deck deck = parser.parseFile(scheduleFile, parseContext);
EclipseState eclipseState(deck , parseContext);
PhaseUsage pu = phaseUsageFromDeck(eclipseState);
const auto& grid = eclipseState.getInputGrid();
const TableManager table ( deck );
const Eclipse3DProperties eclipseProperties ( deck , table, grid);
const Schedule sched(deck, grid, eclipseProperties, Phases(true, true, true), parseContext );
auto wells = eclipseState.getSchedule().getWells();
PhaseUsage pu = phaseUsageFromDeck(eclipseState);
auto wells = sched.getWells();
for (size_t i=0; i<wells.size(); i++) {
const auto* well = wells[i];
@ -87,10 +92,15 @@ BOOST_AUTO_TEST_CASE(ConstructGroupFromGroup) {
Deck deck = parser.parseFile(scheduleFile, parseContext);
EclipseState eclipseState(deck , parseContext);
PhaseUsage pu = phaseUsageFromDeck(eclipseState);
const auto& grid = eclipseState.getInputGrid();
const TableManager table ( deck );
const Eclipse3DProperties eclipseProperties ( deck , table, grid);
const Schedule sched(deck, grid, eclipseProperties, Phases(true, true, true), parseContext );
const auto& nodes = eclipseState.getSchedule().getGroupTree(2);
for( const auto& grp : eclipseState.getSchedule().getGroups() ) {
const auto& nodes = sched.getGroupTree(2);
for( const auto& grp : sched.getGroups() ) {
if( !nodes.exists( grp->name() ) ) continue;
const auto& group = *grp;

View File

@ -31,6 +31,7 @@
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
#include <opm/parser/eclipse/EclipseState/Tables/TableManager.hpp>
#include <opm/core/wells/WellsManager.hpp>
#include <opm/core/wells.h>
@ -183,21 +184,26 @@ BOOST_AUTO_TEST_CASE(New_Constructor_Works) {
Opm::EclipseState eclipseState(deck, parseContext);
Opm::GridManager gridManager(eclipseState.getInputGrid());
const auto& grid = eclipseState.getInputGrid();
const Opm::TableManager table ( deck );
const Opm::Eclipse3DProperties eclipseProperties ( deck , table, grid);
const Opm::Schedule sched(deck, grid, eclipseProperties, Opm::Phases(true, true, true), parseContext );
{
Opm::WellsManager wellsManager(eclipseState, 0, *gridManager.c_grid());
Opm::WellsManager wellsManager(eclipseState, sched, 0, *gridManager.c_grid());
wells_static_check(wellsManager.c_wells());
check_controls_epoch0(wellsManager.c_wells()->ctrls);
}
{
Opm::WellsManager wellsManager(eclipseState, 1, *gridManager.c_grid());
Opm::WellsManager wellsManager(eclipseState, sched, 1, *gridManager.c_grid());
wells_static_check(wellsManager.c_wells());
check_controls_epoch1(wellsManager.c_wells()->ctrls);
}
{
Opm::WellsManager wellsManager(eclipseState, 3, *gridManager.c_grid());
Opm::WellsManager wellsManager(eclipseState, sched, 3, *gridManager.c_grid());
const Wells* wells = wellsManager.c_wells();
// There is 3 wells in total in the deck at the 3rd schedule step.
@ -219,9 +225,14 @@ BOOST_AUTO_TEST_CASE(WellsEqual) {
Opm::Deck deck(parser.parseFile(filename, parseContext));
Opm::EclipseState eclipseState(deck, parseContext);
Opm::GridManager gridManager(eclipseState.getInputGrid());
const auto& grid = eclipseState.getInputGrid();
const Opm::TableManager table ( deck );
const Opm::Eclipse3DProperties eclipseProperties ( deck , table, grid);
const Opm::Schedule sched(deck, grid, eclipseProperties, Opm::Phases(true, true, true), parseContext );
Opm::WellsManager wellsManager0(eclipseState, 0, *gridManager.c_grid());
Opm::WellsManager wellsManager1(eclipseState, 1, *gridManager.c_grid());
Opm::WellsManager wellsManager0(eclipseState, sched, 0, *gridManager.c_grid());
Opm::WellsManager wellsManager1(eclipseState, sched, 1, *gridManager.c_grid());
BOOST_CHECK(wells_equal( wellsManager0.c_wells() , wellsManager0.c_wells(),false));
BOOST_CHECK(!wells_equal( wellsManager0.c_wells() , wellsManager1.c_wells(),false));
@ -234,9 +245,15 @@ BOOST_AUTO_TEST_CASE(ControlsEqual) {
Opm::Deck deck(parser.parseFile(filename, parseContext));
Opm::EclipseState eclipseState(deck, parseContext);
Opm::GridManager gridManager(eclipseState.getInputGrid());
const auto& grid = eclipseState.getInputGrid();
const Opm::TableManager table ( deck );
const Opm::Eclipse3DProperties eclipseProperties ( deck , table, grid);
const Opm::Schedule sched(deck, grid, eclipseProperties, Opm::Phases(true, true, true), parseContext );
Opm::WellsManager wellsManager0(eclipseState, 0, *gridManager.c_grid());
Opm::WellsManager wellsManager1(eclipseState, 1, *gridManager.c_grid());
Opm::WellsManager wellsManager0(eclipseState, sched, 0, *gridManager.c_grid());
Opm::WellsManager wellsManager1(eclipseState, sched, 1, *gridManager.c_grid());
BOOST_CHECK(well_controls_equal( wellsManager0.c_wells()->ctrls[0] , wellsManager0.c_wells()->ctrls[0] , false));
BOOST_CHECK(well_controls_equal( wellsManager0.c_wells()->ctrls[1] , wellsManager0.c_wells()->ctrls[1] , false));
@ -256,8 +273,13 @@ BOOST_AUTO_TEST_CASE(WellShutOK) {
Opm::Deck deck(parser.parseFile(filename, parseContext));
Opm::EclipseState eclipseState(deck, parseContext);
Opm::GridManager gridManager(eclipseState.getInputGrid());
const auto& grid = eclipseState.getInputGrid();
const Opm::TableManager table ( deck );
const Opm::Eclipse3DProperties eclipseProperties ( deck , table, grid);
const Opm::Schedule sched(deck, grid, eclipseProperties, Opm::Phases(true, true, true), parseContext );
Opm::WellsManager wellsManager2(eclipseState, 2, *gridManager.c_grid());
Opm::WellsManager wellsManager2(eclipseState, sched, 2, *gridManager.c_grid());
// Shut wells are not added to the deck. i.e number of wells should be 2-1
BOOST_CHECK(wellsManager2.c_wells()->number_of_wells == 1);
@ -272,8 +294,14 @@ BOOST_AUTO_TEST_CASE(WellSTOPOK) {
Opm::Deck deck(parser.parseFile(filename, parseContext));
Opm::EclipseState eclipseState(deck, parseContext);
Opm::GridManager gridManager(eclipseState.getInputGrid());
const auto& grid = eclipseState.getInputGrid();
const Opm::TableManager table ( deck );
const Opm::Eclipse3DProperties eclipseProperties ( deck , table, grid);
const Opm::Schedule sched(deck, grid, eclipseProperties, Opm::Phases(true, true, true), parseContext );
Opm::WellsManager wellsManager(eclipseState, 0, *gridManager.c_grid());
Opm::WellsManager wellsManager(eclipseState, sched, 0, *gridManager.c_grid());
const Wells* wells = wellsManager.c_wells();
const struct WellControls* ctrls0 = wells->ctrls[0];