From b90830ea7931a6f4590f1a62df292e379010e1d6 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Tue, 7 Jan 2014 17:39:07 +0100 Subject: [PATCH] Added class EclipseState which currently holds a Schedule instance. --- opm/parser/eclipse/CMakeLists.txt | 5 ++ .../eclipse/EclipseState/EclipseState.cpp | 41 +++++++++++ .../eclipse/EclipseState/EclipseState.hpp | 44 ++++++++++++ .../eclipse/EclipseState/tests/CMakeLists.txt | 3 + .../EclipseState/tests/EclipseStateTests.cpp | 70 +++++++++++++++++++ 5 files changed, 163 insertions(+) create mode 100644 opm/parser/eclipse/EclipseState/EclipseState.cpp create mode 100644 opm/parser/eclipse/EclipseState/EclipseState.hpp create mode 100644 opm/parser/eclipse/EclipseState/tests/CMakeLists.txt create mode 100644 opm/parser/eclipse/EclipseState/tests/EclipseStateTests.cpp diff --git a/opm/parser/eclipse/CMakeLists.txt b/opm/parser/eclipse/CMakeLists.txt index c8d5e9494..f440dd24d 100644 --- a/opm/parser/eclipse/CMakeLists.txt +++ b/opm/parser/eclipse/CMakeLists.txt @@ -2,6 +2,7 @@ add_subdirectory(Parser/tests) add_subdirectory(RawDeck/tests) add_subdirectory(Deck/tests) add_subdirectory(IntegrationTests) +add_subdirectory(EclipseState/tests) add_subdirectory(EclipseState/Schedule/tests) add_subdirectory(Units/tests) @@ -52,6 +53,8 @@ Parser/ParserStringItem.cpp ) set (state_source +EclipseState/EclipseState.cpp +# EclipseState/Schedule/TimeMap.cpp EclipseState/Schedule/Schedule.cpp EclipseState/Schedule/Well.cpp @@ -93,6 +96,8 @@ Units/UnitSystem.hpp Units/Dimension.hpp Units/ConversionFactors.hpp # +EclipseState/EclipseState.hpp +# EclipseState/Schedule/TimeMap.hpp EclipseState/Schedule/Schedule.hpp EclipseState/Schedule/Well.hpp diff --git a/opm/parser/eclipse/EclipseState/EclipseState.cpp b/opm/parser/eclipse/EclipseState/EclipseState.cpp new file mode 100644 index 000000000..00a7488a0 --- /dev/null +++ b/opm/parser/eclipse/EclipseState/EclipseState.cpp @@ -0,0 +1,41 @@ +/* + Copyright 2013 Statoil ASA. + + This file is part of the Open Porous Media project (OPM). + + OPM is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OPM is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with OPM. If not, see . + */ + +#include +#include +#include + +namespace Opm { + + EclipseState::EclipseState(DeckConstPtr deck) { + initSchedule(deck); + } + + + ScheduleConstPtr EclipseState::getSchedule() const { + return schedule; + } + + + void EclipseState::initSchedule(DeckConstPtr deck) { + schedule = ScheduleConstPtr( new Schedule(deck) ); + } + + +} diff --git a/opm/parser/eclipse/EclipseState/EclipseState.hpp b/opm/parser/eclipse/EclipseState/EclipseState.hpp new file mode 100644 index 000000000..6eeca2c7f --- /dev/null +++ b/opm/parser/eclipse/EclipseState/EclipseState.hpp @@ -0,0 +1,44 @@ +/* + Copyright 2013 Statoil ASA. + + This file is part of the Open Porous Media project (OPM). + + OPM is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OPM is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with OPM. If not, see . + */ + +#ifndef ECLIPSESTATE_H +#define ECLIPSESTATE_H + +#include + +#include + +namespace Opm { + + class EclipseState { + public: + EclipseState(DeckConstPtr deck); + ScheduleConstPtr getSchedule() const; + + + private: + void initSchedule(DeckConstPtr deck); + ScheduleConstPtr schedule; + }; + + typedef std::shared_ptr EclipseStatePtr; + typedef std::shared_ptr EclipseStateConstPtr; +} + +#endif diff --git a/opm/parser/eclipse/EclipseState/tests/CMakeLists.txt b/opm/parser/eclipse/EclipseState/tests/CMakeLists.txt new file mode 100644 index 000000000..dc12cea24 --- /dev/null +++ b/opm/parser/eclipse/EclipseState/tests/CMakeLists.txt @@ -0,0 +1,3 @@ +add_executable(runEclipseStateTests EclipseStateTests.cpp) +target_link_libraries(runEclipseStateTests Parser ${Boost_LIBRARIES}) +add_test(NAME runEclipseStateTests WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND ${EXECUTABLE_OUTPUT_PATH}/runEclipseStateTests ) diff --git a/opm/parser/eclipse/EclipseState/tests/EclipseStateTests.cpp b/opm/parser/eclipse/EclipseState/tests/EclipseStateTests.cpp new file mode 100644 index 000000000..2ea59362f --- /dev/null +++ b/opm/parser/eclipse/EclipseState/tests/EclipseStateTests.cpp @@ -0,0 +1,70 @@ +/* + Copyright 2013 Statoil ASA. + + This file is part of the Open Porous Media project (OPM). + + OPM is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OPM is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with OPM. If not, see . + */ + +#include +#include +#include + +#define BOOST_TEST_MODULE EclipseStateTests +#include +#include + +#include +#include +#include +#include +#include + +using namespace Opm; + +DeckPtr createDeck() { + DeckPtr deck(new Deck()); + DeckKeywordPtr scheduleKeyword(new DeckKeyword("SCHEDULE")); + DeckKeywordPtr startKeyword(new DeckKeyword("START")); + DeckRecordPtr startRecord(new DeckRecord()); + DeckIntItemPtr dayItem( new DeckIntItem("DAY") ); + DeckStringItemPtr monthItem(new DeckStringItem("MONTH") ); + DeckIntItemPtr yearItem(new DeckIntItem("YEAR")); + + + dayItem->push_back( 8 ); + monthItem->push_back( "MAR" ); + yearItem->push_back( 1998 ); + + startRecord->addItem( dayItem ); + startRecord->addItem( monthItem ); + startRecord->addItem( yearItem ); + startKeyword->addRecord( startRecord ); + + deck->addKeyword( startKeyword ); + deck->addKeyword( scheduleKeyword ); + + return deck; +} + + + +BOOST_AUTO_TEST_CASE(CreatSchedule) { + DeckPtr deck = createDeck(); + EclipseState state(deck); + ScheduleConstPtr schedule = state.getSchedule(); + + BOOST_CHECK_EQUAL( schedule->getStartDate() , boost::gregorian::date(1998 , 3 , 8 )); +} +