Added class EclipseState which currently holds a Schedule instance.

This commit is contained in:
Joakim Hove
2014-01-07 17:39:07 +01:00
parent a88b47750e
commit b90830ea79
5 changed files with 163 additions and 0 deletions

View File

@@ -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

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
#include <iostream>
namespace Opm {
EclipseState::EclipseState(DeckConstPtr deck) {
initSchedule(deck);
}
ScheduleConstPtr EclipseState::getSchedule() const {
return schedule;
}
void EclipseState::initSchedule(DeckConstPtr deck) {
schedule = ScheduleConstPtr( new Schedule(deck) );
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#ifndef ECLIPSESTATE_H
#define ECLIPSESTATE_H
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <memory>
namespace Opm {
class EclipseState {
public:
EclipseState(DeckConstPtr deck);
ScheduleConstPtr getSchedule() const;
private:
void initSchedule(DeckConstPtr deck);
ScheduleConstPtr schedule;
};
typedef std::shared_ptr<EclipseState> EclipseStatePtr;
typedef std::shared_ptr<const EclipseState> EclipseStateConstPtr;
}
#endif

View File

@@ -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 )

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#include <stdexcept>
#include <iostream>
#include <boost/filesystem.hpp>
#define BOOST_TEST_MODULE EclipseStateTests
#include <boost/test/unit_test.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
#include <opm/parser/eclipse/Deck/DeckIntItem.hpp>
#include <opm/parser/eclipse/Deck/DeckStringItem.hpp>
#include <opm/parser/eclipse/Deck/Deck.hpp>
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 ));
}