From 02f88ce8ffdeee3f175384d0af56ccecc36324d5 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Thu, 24 Apr 2014 09:01:58 +0200 Subject: [PATCH] Added EclipseGrid to the EclipseState class --- .../eclipse/EclipseState/EclipseState.cpp | 14 ++++++++++++++ .../eclipse/EclipseState/EclipseState.hpp | 4 ++++ .../eclipse/EclipseState/Grid/EclipseGrid.cpp | 2 +- .../EclipseState/tests/EclipseStateTests.cpp | 18 +++++++++++++++++- 4 files changed, 36 insertions(+), 2 deletions(-) diff --git a/opm/parser/eclipse/EclipseState/EclipseState.cpp b/opm/parser/eclipse/EclipseState/EclipseState.cpp index 84f5d84fd..1ecf86b79 100644 --- a/opm/parser/eclipse/EclipseState/EclipseState.cpp +++ b/opm/parser/eclipse/EclipseState/EclipseState.cpp @@ -18,6 +18,7 @@ */ #include +#include #include #include #include @@ -27,11 +28,17 @@ namespace Opm { EclipseState::EclipseState(DeckConstPtr deck) { initPhases(deck); + initEclipseGrid(deck); initSchedule(deck); initTitle(deck); } + EclipseGridConstPtr EclipseState::getEclipseGrid() const { + return m_eclipseGrid; + } + + ScheduleConstPtr EclipseState::getSchedule() const { return schedule; } @@ -45,6 +52,13 @@ namespace Opm { schedule = ScheduleConstPtr( new Schedule(deck) ); } + void EclipseState::initEclipseGrid(DeckConstPtr deck) { + std::shared_ptr gridSection(new Opm::GRIDSection(deck) ); + std::shared_ptr runspecSection(new Opm::RUNSPECSection(deck) ); + + m_eclipseGrid = EclipseGridConstPtr( new EclipseGrid( runspecSection , gridSection )); + } + void EclipseState::initPhases(DeckConstPtr deck) { if (deck->hasKeyword("OIL")) diff --git a/opm/parser/eclipse/EclipseState/EclipseState.hpp b/opm/parser/eclipse/EclipseState/EclipseState.hpp index 2071042b1..a0113c0a9 100644 --- a/opm/parser/eclipse/EclipseState/EclipseState.hpp +++ b/opm/parser/eclipse/EclipseState/EclipseState.hpp @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -33,14 +34,17 @@ namespace Opm { public: EclipseState(DeckConstPtr deck); ScheduleConstPtr getSchedule() const; + EclipseGridConstPtr getEclipseGrid() const; bool hasPhase(enum Phase::PhaseEnum phase) const; std::string getTitle() const; private: void initSchedule(DeckConstPtr deck); + void initEclipseGrid(DeckConstPtr deck); void initPhases(DeckConstPtr deck); void initTitle(DeckConstPtr deck); + EclipseGridConstPtr m_eclipseGrid; ScheduleConstPtr schedule; std::set phases; std::string m_title; diff --git a/opm/parser/eclipse/EclipseState/Grid/EclipseGrid.cpp b/opm/parser/eclipse/EclipseState/Grid/EclipseGrid.cpp index e52eb227b..0277cf884 100644 --- a/opm/parser/eclipse/EclipseState/Grid/EclipseGrid.cpp +++ b/opm/parser/eclipse/EclipseState/Grid/EclipseGrid.cpp @@ -40,7 +40,7 @@ namespace Opm { } else if (hasCartesianKeywords(gridSection)) { initCartesianGrid(dims , gridSection); } else - throw std::invalid_argument("The GRID section must have COORD / ZCORN or D?? keywords"); + throw std::invalid_argument("The GRID section must have COORD / ZCORN or D?? + TOPS keywords"); } else throw std::invalid_argument("The RUNSPEC section must have the DIMENS keyword with grid dimensions"); diff --git a/opm/parser/eclipse/EclipseState/tests/EclipseStateTests.cpp b/opm/parser/eclipse/EclipseState/tests/EclipseStateTests.cpp index 262518011..4c557f912 100644 --- a/opm/parser/eclipse/EclipseState/tests/EclipseStateTests.cpp +++ b/opm/parser/eclipse/EclipseState/tests/EclipseStateTests.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -37,6 +38,20 @@ using namespace Opm; DeckPtr createDeck() { const char *deckData = + "RUNSPEC\n" + "\n" + "DIMENS\n" + " 10 10 10 /\n" + "GRID\n" + "DX\n" + "1000*0.25 /\n" + "DYV\n" + "10*0.25 /\n" + "DZ\n" + "1000*0.25 /\n" + "TOPS\n" + "1000*0.25 /\n" + "EDIT\n" "OIL\n" "\n" "GAS\n" @@ -60,7 +75,8 @@ BOOST_AUTO_TEST_CASE(CreatSchedule) { DeckPtr deck = createDeck(); EclipseState state(deck); ScheduleConstPtr schedule = state.getSchedule(); - + EclipseGridConstPtr eclipseGrid = state.getEclipseGrid(); + BOOST_CHECK_EQUAL( schedule->getStartTime() , boost::posix_time::ptime(boost::gregorian::date(1998 , 3 , 8 ))); }