TimeMap: replace boost::gregorian::date by boost::posix_time::ptime
this is necessary because boost::gregorian::date does not have a notion of "time during a day" which is required to specify time step lengths less than a day...
This commit is contained in:
@@ -42,13 +42,13 @@ namespace Opm {
|
||||
}
|
||||
|
||||
void Schedule::createTimeMap(DeckConstPtr deck) {
|
||||
boost::gregorian::date startDate(defaultStartDate);
|
||||
boost::posix_time::ptime startTime(defaultStartDate);
|
||||
if (deck->hasKeyword("START")) {
|
||||
DeckKeywordConstPtr startKeyword = deck->getKeyword("START");
|
||||
startDate = TimeMap::dateFromEclipse(startKeyword->getRecord(0));
|
||||
startTime = TimeMap::timeFromEclipse(startKeyword->getRecord(0));
|
||||
}
|
||||
|
||||
m_timeMap.reset(new TimeMap(startDate));
|
||||
m_timeMap.reset(new TimeMap(startTime));
|
||||
}
|
||||
|
||||
void Schedule::iterateScheduleSection(DeckConstPtr deck) {
|
||||
@@ -397,10 +397,6 @@ namespace Opm {
|
||||
m_rootGroupTree->add(currentStep, newTree);
|
||||
}
|
||||
|
||||
boost::gregorian::date Schedule::getStartDate() const {
|
||||
return m_timeMap->getStartDate();
|
||||
}
|
||||
|
||||
TimeMapConstPtr Schedule::getTimeMap() const {
|
||||
return m_timeMap;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,8 @@ namespace Opm
|
||||
class Schedule {
|
||||
public:
|
||||
Schedule(DeckConstPtr deck);
|
||||
boost::gregorian::date getStartDate() const;
|
||||
boost::posix_time::ptime getStartTime() const
|
||||
{ return m_timeMap->getStartTime(/*timeStepIdx=*/0); }
|
||||
TimeMapConstPtr getTimeMap() const;
|
||||
|
||||
size_t numWells() const;
|
||||
|
||||
@@ -23,22 +23,20 @@
|
||||
#include <opm/parser/eclipse/Deck/DeckDoubleItem.hpp>
|
||||
|
||||
namespace Opm {
|
||||
|
||||
TimeMap::TimeMap(boost::gregorian::date startDate) {
|
||||
if (startDate.is_not_a_date())
|
||||
TimeMap::TimeMap(boost::posix_time::ptime startDate) {
|
||||
if (startDate.is_not_a_date_time())
|
||||
throw std::invalid_argument("Input argument not properly initialized.");
|
||||
|
||||
m_startDate = startDate;
|
||||
m_timeList.push_back( boost::posix_time::ptime(startDate) );
|
||||
}
|
||||
|
||||
|
||||
void TimeMap::addDate(boost::gregorian::date newDate) {
|
||||
void TimeMap::addTime(boost::posix_time::ptime newTime) {
|
||||
boost::posix_time::ptime lastTime = m_timeList.back();
|
||||
if (boost::posix_time::ptime(newDate) > lastTime)
|
||||
m_timeList.push_back( boost::posix_time::ptime(newDate) );
|
||||
if (newTime > lastTime)
|
||||
m_timeList.push_back( newTime );
|
||||
else
|
||||
throw std::invalid_argument("Dates added must be in strictly increasing order.");
|
||||
throw std::invalid_argument("Times added must be in strictly increasing order.");
|
||||
}
|
||||
|
||||
|
||||
@@ -55,12 +53,6 @@ namespace Opm {
|
||||
return m_timeList.size();
|
||||
}
|
||||
|
||||
|
||||
boost::gregorian::date TimeMap::getStartDate() const {
|
||||
return m_startDate;
|
||||
}
|
||||
|
||||
|
||||
std::map<std::string , boost::gregorian::greg_month> TimeMap::initEclipseMonthNames() {
|
||||
std::map<std::string , boost::gregorian::greg_month> monthNames;
|
||||
|
||||
@@ -85,15 +77,23 @@ namespace Opm {
|
||||
}
|
||||
|
||||
|
||||
boost::gregorian::date TimeMap::dateFromEclipse(int day , const std::string& eclipseMonthName, int year) {
|
||||
static const std::map<std::string,boost::gregorian::greg_month> monthNames = initEclipseMonthNames();
|
||||
boost::gregorian::greg_month month = monthNames.at( eclipseMonthName );
|
||||
return boost::gregorian::date( year , month , day );
|
||||
boost::posix_time::ptime TimeMap::timeFromEclipse(int day,
|
||||
const std::string& eclipseMonthName,
|
||||
int year,
|
||||
const std::string& eclipseTimeString) {
|
||||
static const std::map<std::string , boost::gregorian::greg_month> eclipseMonthNames = initEclipseMonthNames();
|
||||
boost::gregorian::greg_month month = eclipseMonthNames.at( eclipseMonthName );
|
||||
boost::gregorian::date date( year , month , day );
|
||||
boost::posix_time::time_duration dayTime = dayTimeFromEclipse(eclipseTimeString);
|
||||
return boost::posix_time::ptime(date, dayTime);
|
||||
}
|
||||
|
||||
|
||||
boost::posix_time::time_duration TimeMap::dayTimeFromEclipse(const std::string& eclipseTimeString) {
|
||||
return boost::posix_time::duration_from_string(eclipseTimeString);
|
||||
}
|
||||
|
||||
boost::gregorian::date TimeMap::dateFromEclipse(DeckRecordConstPtr dateRecord) {
|
||||
boost::posix_time::ptime TimeMap::timeFromEclipse(DeckRecordConstPtr dateRecord) {
|
||||
static const std::string errorMsg("The datarecord must consist of the three values "
|
||||
"\"DAY(int) MONTH(string) YEAR(int)\" plus the optional value \"TIME(string)\".\n");
|
||||
if (dateRecord->size() < 3 || dateRecord->size() > 4)
|
||||
@@ -102,33 +102,32 @@ namespace Opm {
|
||||
DeckItemConstPtr dayItem = dateRecord->getItem( 0 );
|
||||
DeckItemConstPtr monthItem = dateRecord->getItem( 1 );
|
||||
DeckItemConstPtr yearItem = dateRecord->getItem( 2 );
|
||||
//DeckItemConstPtr timeItem = dateRecord->getItem( 3 );
|
||||
|
||||
try {
|
||||
int day = dayItem->getInt(0);
|
||||
const std::string& month = monthItem->getString(0);
|
||||
int year = yearItem->getInt(0);
|
||||
|
||||
return TimeMap::dateFromEclipse( day , month , year);
|
||||
std::string eclipseTimeString = "00:00:00.000";
|
||||
if (dateRecord->size() > 3 && dateRecord->getItem( 3 )->size() > 0)
|
||||
eclipseTimeString = dateRecord->getItem( 3 )->getString(0);
|
||||
|
||||
return TimeMap::timeFromEclipse(day, month, year, eclipseTimeString);
|
||||
} catch (...) {
|
||||
throw std::invalid_argument( errorMsg );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void TimeMap::addFromDATESKeyword( DeckKeywordConstPtr DATESKeyword ) {
|
||||
if (DATESKeyword->name() != "DATES")
|
||||
throw std::invalid_argument("Method requires DATES keyword input.");
|
||||
|
||||
for (size_t recordIndex = 0; recordIndex < DATESKeyword->size(); recordIndex++) {
|
||||
DeckRecordConstPtr record = DATESKeyword->getRecord( recordIndex );
|
||||
boost::gregorian::date date = TimeMap::dateFromEclipse( record );
|
||||
addDate( date );
|
||||
boost::posix_time::ptime nextTime = TimeMap::timeFromEclipse( record );
|
||||
addTime( nextTime );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void TimeMap::addFromTSTEPKeyword( DeckKeywordConstPtr TSTEPKeyword ) {
|
||||
if (TSTEPKeyword->name() != "TSTEP")
|
||||
@@ -139,7 +138,11 @@ namespace Opm {
|
||||
|
||||
for (size_t itemIndex = 0; itemIndex < item->size(); itemIndex++) {
|
||||
double days = item->getRawDouble( itemIndex );
|
||||
boost::posix_time::time_duration step = boost::posix_time::seconds( static_cast<long int>(days * 24 * 3600) );
|
||||
long int wholeSeconds = static_cast<long int>(days * 24*60*60);
|
||||
long int milliSeconds = static_cast<long int>((days * 24*60*60 - wholeSeconds)*1000);
|
||||
boost::posix_time::time_duration step =
|
||||
boost::posix_time::seconds(wholeSeconds) +
|
||||
boost::posix_time::milliseconds(milliSeconds);
|
||||
addTStep( step );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,19 +30,21 @@ namespace Opm {
|
||||
|
||||
class TimeMap {
|
||||
public:
|
||||
TimeMap(boost::gregorian::date startDate);
|
||||
void addDate(boost::gregorian::date newDate);
|
||||
TimeMap(boost::posix_time::ptime startDate);
|
||||
void addTime(boost::posix_time::ptime newTime);
|
||||
void addTStep(boost::posix_time::time_duration step);
|
||||
void addFromDATESKeyword( DeckKeywordConstPtr DATESKeyword );
|
||||
void addFromTSTEPKeyword( DeckKeywordConstPtr TSTEPKeyword );
|
||||
boost::gregorian::date getStartDate() const;
|
||||
size_t size() const;
|
||||
static boost::gregorian::date dateFromEclipse(DeckRecordConstPtr dateRecord);
|
||||
static boost::gregorian::date dateFromEclipse(int day , const std::string& month, int year);
|
||||
/// Return the date and time where a given time step starts.
|
||||
boost::posix_time::ptime getStartTime(int tStepIdx) const
|
||||
{ return m_timeList[tStepIdx]; }
|
||||
static boost::posix_time::ptime timeFromEclipse(DeckRecordConstPtr dateRecord);
|
||||
static boost::posix_time::ptime timeFromEclipse(int day , const std::string& month, int year, const std::string& eclipseTimeString = "00:00:00.000");
|
||||
static boost::posix_time::time_duration dayTimeFromEclipse(const std::string& eclipseTimeString);
|
||||
private:
|
||||
static std::map<std::string , boost::gregorian::greg_month> initEclipseMonthNames();
|
||||
|
||||
boost::gregorian::date m_startDate;
|
||||
std::vector<boost::posix_time::ptime> m_timeList;
|
||||
};
|
||||
typedef std::shared_ptr<TimeMap> TimeMapPtr;
|
||||
|
||||
@@ -35,14 +35,14 @@
|
||||
|
||||
BOOST_AUTO_TEST_CASE(CreateDynamicTest) {
|
||||
boost::gregorian::date startDate( 2010 , boost::gregorian::Jan , 1);
|
||||
Opm::TimeMapPtr timeMap(new Opm::TimeMap(startDate));
|
||||
Opm::TimeMapPtr timeMap(new Opm::TimeMap(boost::posix_time::ptime(startDate)));
|
||||
Opm::DynamicState<double> state(timeMap , 9.99);
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(DynamicStateGetOutOfRangeThrows) {
|
||||
boost::gregorian::date startDate( 2010 , boost::gregorian::Jan , 1);
|
||||
Opm::TimeMapPtr timeMap(new Opm::TimeMap(startDate));
|
||||
Opm::TimeMapPtr timeMap(new Opm::TimeMap(boost::posix_time::ptime(startDate)));
|
||||
Opm::DynamicState<double> state(timeMap , 9.99);
|
||||
BOOST_CHECK_THROW( state.get(1) , std::range_error);
|
||||
}
|
||||
@@ -50,7 +50,7 @@ BOOST_AUTO_TEST_CASE(DynamicStateGetOutOfRangeThrows) {
|
||||
|
||||
BOOST_AUTO_TEST_CASE(DynamicStateGetDefault) {
|
||||
boost::gregorian::date startDate( 2010 , boost::gregorian::Jan , 1);
|
||||
Opm::TimeMapPtr timeMap(new Opm::TimeMap(startDate));
|
||||
Opm::TimeMapPtr timeMap(new Opm::TimeMap(boost::posix_time::ptime(startDate)));
|
||||
Opm::DynamicState<int> state(timeMap , 137);
|
||||
BOOST_CHECK_EQUAL( 137 , state.get(0));
|
||||
}
|
||||
@@ -58,7 +58,7 @@ BOOST_AUTO_TEST_CASE(DynamicStateGetDefault) {
|
||||
|
||||
BOOST_AUTO_TEST_CASE(DynamicStateSetOutOfRangeThrows) {
|
||||
boost::gregorian::date startDate( 2010 , boost::gregorian::Jan , 1);
|
||||
Opm::TimeMapPtr timeMap(new Opm::TimeMap(startDate));
|
||||
Opm::TimeMapPtr timeMap(new Opm::TimeMap(boost::posix_time::ptime(startDate)));
|
||||
Opm::DynamicState<int> state(timeMap , 137);
|
||||
for (size_t i = 0; i < 2; i++)
|
||||
timeMap->addTStep( boost::posix_time::hours( (i+1) * 24 ));
|
||||
@@ -69,7 +69,7 @@ BOOST_AUTO_TEST_CASE(DynamicStateSetOutOfRangeThrows) {
|
||||
|
||||
BOOST_AUTO_TEST_CASE(DynamicStateSetOK) {
|
||||
boost::gregorian::date startDate( 2010 , boost::gregorian::Jan , 1);
|
||||
Opm::TimeMapPtr timeMap(new Opm::TimeMap(startDate));
|
||||
Opm::TimeMapPtr timeMap(new Opm::TimeMap(boost::posix_time::ptime(startDate)));
|
||||
Opm::DynamicState<int> state(timeMap , 137);
|
||||
for (size_t i = 0; i < 10; i++)
|
||||
timeMap->addTStep( boost::posix_time::hours( (i+1) * 24 ));
|
||||
@@ -98,7 +98,7 @@ BOOST_AUTO_TEST_CASE(DynamicStateSetOK) {
|
||||
|
||||
BOOST_AUTO_TEST_CASE(DynamicStateAddIndexAlreadySetThrows) {
|
||||
boost::gregorian::date startDate( 2010 , boost::gregorian::Jan , 1);
|
||||
Opm::TimeMapPtr timeMap(new Opm::TimeMap(startDate));
|
||||
Opm::TimeMapPtr timeMap(new Opm::TimeMap(boost::posix_time::ptime(startDate)));
|
||||
Opm::DynamicState<int> state(timeMap , 137);
|
||||
for (size_t i = 0; i < 10; i++)
|
||||
timeMap->addTStep( boost::posix_time::hours( (i+1) * 24 ));
|
||||
@@ -112,7 +112,7 @@ BOOST_AUTO_TEST_CASE(DynamicStateAddIndexAlreadySetThrows) {
|
||||
|
||||
BOOST_AUTO_TEST_CASE(DynamicStateCheckSize) {
|
||||
boost::gregorian::date startDate( 2010 , boost::gregorian::Jan , 1);
|
||||
Opm::TimeMapPtr timeMap(new Opm::TimeMap(startDate));
|
||||
Opm::TimeMapPtr timeMap(new Opm::TimeMap(boost::posix_time::ptime(startDate)));
|
||||
Opm::DynamicState<int> state(timeMap , 137);
|
||||
for (size_t i = 0; i < 10; i++)
|
||||
timeMap->addTStep( boost::posix_time::hours( (i+1) * 24 ));
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
Opm::TimeMapPtr createXDaysTimeMap(size_t numDays) {
|
||||
boost::gregorian::date startDate( 2010 , boost::gregorian::Jan , 1);
|
||||
Opm::TimeMapPtr timeMap(new Opm::TimeMap(startDate));
|
||||
Opm::TimeMapPtr timeMap(new Opm::TimeMap(boost::posix_time::ptime(startDate)));
|
||||
for (size_t i = 0; i < numDays; i++)
|
||||
timeMap->addTStep( boost::posix_time::hours( (i+1) * 24 ));
|
||||
return timeMap;
|
||||
|
||||
@@ -95,14 +95,14 @@ BOOST_AUTO_TEST_CASE(CreateScheduleDeckMissingReturnsDefaults) {
|
||||
DeckKeywordPtr keyword(new DeckKeyword("SCHEDULE"));
|
||||
deck->addKeyword( keyword );
|
||||
Schedule schedule(deck);
|
||||
BOOST_CHECK_EQUAL( schedule.getStartDate() , boost::gregorian::date( 1983 , boost::gregorian::Jan , 1));
|
||||
BOOST_CHECK_EQUAL( schedule.getStartTime() , boost::posix_time::ptime(boost::gregorian::date( 1983 , boost::gregorian::Jan , 1)));
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(CreateScheduleDeckWithStart) {
|
||||
DeckPtr deck = createDeck();
|
||||
Schedule schedule(deck);
|
||||
BOOST_CHECK_EQUAL( schedule.getStartDate() , boost::gregorian::date( 1998 , boost::gregorian::Mar , 8));
|
||||
BOOST_CHECK_EQUAL( schedule.getStartTime() , boost::posix_time::ptime(boost::gregorian::date( 1998 , boost::gregorian::Mar , 8)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -33,17 +33,17 @@
|
||||
#include <opm/parser/eclipse/Deck/DeckStringItem.hpp>
|
||||
#include <opm/parser/eclipse/Deck/DeckRecord.hpp>
|
||||
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
|
||||
|
||||
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
||||
|
||||
BOOST_AUTO_TEST_CASE(CreateTimeMap_InvalidThrow) {
|
||||
boost::gregorian::date startDate;
|
||||
BOOST_CHECK_THROW(Opm::TimeMap timeMap(startDate) , std::invalid_argument);
|
||||
BOOST_CHECK_THROW(Opm::TimeMap(boost::posix_time::ptime(startDate)) , std::invalid_argument);
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(CreateTimeMap) {
|
||||
boost::gregorian::date startDate( 2010 , boost::gregorian::Jan , 1);
|
||||
Opm::TimeMap timeMap(startDate);
|
||||
Opm::TimeMap timeMap((boost::posix_time::ptime(startDate)));
|
||||
BOOST_CHECK_EQUAL(1U , timeMap.size());
|
||||
}
|
||||
|
||||
@@ -51,32 +51,34 @@ BOOST_AUTO_TEST_CASE(CreateTimeMap) {
|
||||
|
||||
BOOST_AUTO_TEST_CASE(AddDateBeforeThrows) {
|
||||
boost::gregorian::date startDate( 2010 , boost::gregorian::Jan , 1);
|
||||
Opm::TimeMap timeMap(startDate);
|
||||
Opm::TimeMap timeMap((boost::posix_time::ptime(startDate)));
|
||||
|
||||
BOOST_CHECK_THROW( timeMap.addDate( boost::gregorian::date(2009,boost::gregorian::Feb,2)) , std::invalid_argument);
|
||||
BOOST_CHECK_THROW( timeMap.addTime( boost::posix_time::ptime(boost::gregorian::date(2009,boost::gregorian::Feb,2))),
|
||||
std::invalid_argument);
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(GetStartDate) {
|
||||
boost::gregorian::date startDate( 2010 , boost::gregorian::Jan , 1);
|
||||
Opm::TimeMap timeMap(startDate);
|
||||
BOOST_CHECK_EQUAL( startDate , timeMap.getStartDate());
|
||||
boost::posix_time::ptime startTime(startDate);
|
||||
Opm::TimeMap timeMap(startTime);
|
||||
BOOST_CHECK_EQUAL( startTime , timeMap.getStartTime(/*timeStepIdx=*/0));
|
||||
}
|
||||
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(AddDateAfterSizeCorrect) {
|
||||
boost::gregorian::date startDate( 2010 , boost::gregorian::Jan , 1);
|
||||
Opm::TimeMap timeMap(startDate);
|
||||
Opm::TimeMap timeMap((boost::posix_time::ptime(startDate)));
|
||||
|
||||
timeMap.addDate( boost::gregorian::date(2010,boost::gregorian::Feb,2));
|
||||
timeMap.addTime( boost::posix_time::ptime(boost::gregorian::date(2010,boost::gregorian::Feb,2)));
|
||||
BOOST_CHECK_EQUAL( 2U , timeMap.size());
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(AddDateNegativeStepThrows) {
|
||||
boost::gregorian::date startDate( 2010 , boost::gregorian::Jan , 1);
|
||||
Opm::TimeMap timeMap(startDate);
|
||||
boost::gregorian::date startDate( 2010 , boost::gregorian::Jan , 1);
|
||||
Opm::TimeMap timeMap((boost::posix_time::ptime(startDate)));
|
||||
|
||||
BOOST_CHECK_THROW( timeMap.addTStep( boost::posix_time::hours(-1)) , std::invalid_argument);
|
||||
}
|
||||
@@ -85,7 +87,7 @@ BOOST_AUTO_TEST_CASE(AddDateNegativeStepThrows) {
|
||||
|
||||
BOOST_AUTO_TEST_CASE(AddStepSizeCorrect) {
|
||||
boost::gregorian::date startDate( 2010 , boost::gregorian::Jan , 1);
|
||||
Opm::TimeMapPtr timeMap( new Opm::TimeMap(startDate) );
|
||||
Opm::TimeMapPtr timeMap( new Opm::TimeMap(boost::posix_time::ptime(boost::posix_time::ptime(startDate))) );
|
||||
|
||||
timeMap->addTStep( boost::posix_time::hours(1));
|
||||
timeMap->addTStep( boost::posix_time::hours(24));
|
||||
@@ -105,22 +107,22 @@ BOOST_AUTO_TEST_CASE( dateFromEclipseThrowsInvalidRecord ) {
|
||||
yearItem->push_back(1987 );
|
||||
monthItem->push_back("FEB");
|
||||
|
||||
BOOST_CHECK_THROW( Opm::TimeMap::dateFromEclipse( startRecord ) , std::invalid_argument );
|
||||
BOOST_CHECK_THROW( Opm::TimeMap::timeFromEclipse( startRecord ) , std::invalid_argument );
|
||||
|
||||
startRecord->addItem( dayItem );
|
||||
BOOST_CHECK_THROW( Opm::TimeMap::dateFromEclipse( startRecord ) , std::invalid_argument );
|
||||
BOOST_CHECK_THROW( Opm::TimeMap::timeFromEclipse( startRecord ) , std::invalid_argument );
|
||||
|
||||
startRecord->addItem( monthItem );
|
||||
BOOST_CHECK_THROW( Opm::TimeMap::dateFromEclipse( startRecord ) , std::invalid_argument );
|
||||
BOOST_CHECK_THROW( Opm::TimeMap::timeFromEclipse( startRecord ) , std::invalid_argument );
|
||||
|
||||
startRecord->addItem( yearItem );
|
||||
BOOST_CHECK_NO_THROW(Opm::TimeMap::dateFromEclipse( startRecord ));
|
||||
BOOST_CHECK_NO_THROW(Opm::TimeMap::timeFromEclipse( startRecord ));
|
||||
|
||||
startRecord->addItem( timeItem );
|
||||
BOOST_CHECK_NO_THROW(Opm::TimeMap::dateFromEclipse( startRecord ));
|
||||
BOOST_CHECK_NO_THROW(Opm::TimeMap::timeFromEclipse( startRecord ));
|
||||
|
||||
startRecord->addItem( extraItem );
|
||||
BOOST_CHECK_THROW( Opm::TimeMap::dateFromEclipse( startRecord ) , std::invalid_argument );
|
||||
BOOST_CHECK_THROW( Opm::TimeMap::timeFromEclipse( startRecord ) , std::invalid_argument );
|
||||
}
|
||||
|
||||
|
||||
@@ -139,34 +141,34 @@ BOOST_AUTO_TEST_CASE( dateFromEclipseInvalidMonthThrows ) {
|
||||
startRecord->addItem( monthItem );
|
||||
startRecord->addItem( yearItem );
|
||||
|
||||
BOOST_CHECK_THROW( Opm::TimeMap::dateFromEclipse( startRecord ) , std::invalid_argument );
|
||||
BOOST_CHECK_THROW( Opm::TimeMap::timeFromEclipse( startRecord ) , std::invalid_argument );
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE( dateFromEclipseCheckMonthNames ) {
|
||||
BOOST_AUTO_TEST_CASE( timeFromEclipseCheckMonthNames ) {
|
||||
|
||||
BOOST_CHECK_EQUAL( boost::gregorian::date( 2000 , boost::gregorian::Jan , 1 ) , Opm::TimeMap::dateFromEclipse( 1 , "JAN" , 2000));
|
||||
BOOST_CHECK_EQUAL( boost::gregorian::date( 2000 , boost::gregorian::Feb , 1 ) , Opm::TimeMap::dateFromEclipse( 1 , "FEB" , 2000));
|
||||
BOOST_CHECK_EQUAL( boost::gregorian::date( 2000 , boost::gregorian::Mar , 1 ) , Opm::TimeMap::dateFromEclipse( 1 , "MAR" , 2000));
|
||||
BOOST_CHECK_EQUAL( boost::gregorian::date( 2000 , boost::gregorian::Apr , 1 ) , Opm::TimeMap::dateFromEclipse( 1 , "APR" , 2000));
|
||||
BOOST_CHECK_EQUAL( boost::gregorian::date( 2000 , boost::gregorian::May , 1 ) , Opm::TimeMap::dateFromEclipse( 1 , "MAI" , 2000));
|
||||
BOOST_CHECK_EQUAL( boost::gregorian::date( 2000 , boost::gregorian::May , 1 ) , Opm::TimeMap::dateFromEclipse( 1 , "MAY" , 2000));
|
||||
BOOST_CHECK_EQUAL( boost::gregorian::date( 2000 , boost::gregorian::Jun , 1 ) , Opm::TimeMap::dateFromEclipse( 1 , "JUN" , 2000));
|
||||
BOOST_CHECK_EQUAL( boost::gregorian::date( 2000 , boost::gregorian::Jul , 1 ) , Opm::TimeMap::dateFromEclipse( 1 , "JUL" , 2000));
|
||||
BOOST_CHECK_EQUAL( boost::gregorian::date( 2000 , boost::gregorian::Jul , 1 ) , Opm::TimeMap::dateFromEclipse( 1 , "JLY" , 2000));
|
||||
BOOST_CHECK_EQUAL( boost::gregorian::date( 2000 , boost::gregorian::Aug , 1 ) , Opm::TimeMap::dateFromEclipse( 1 , "AUG" , 2000));
|
||||
BOOST_CHECK_EQUAL( boost::gregorian::date( 2000 , boost::gregorian::Sep , 1 ) , Opm::TimeMap::dateFromEclipse( 1 , "SEP" , 2000));
|
||||
BOOST_CHECK_EQUAL( boost::gregorian::date( 2000 , boost::gregorian::Oct , 1 ) , Opm::TimeMap::dateFromEclipse( 1 , "OKT" , 2000));
|
||||
BOOST_CHECK_EQUAL( boost::gregorian::date( 2000 , boost::gregorian::Oct , 1 ) , Opm::TimeMap::dateFromEclipse( 1 , "OCT" , 2000));
|
||||
BOOST_CHECK_EQUAL( boost::gregorian::date( 2000 , boost::gregorian::Nov , 1 ) , Opm::TimeMap::dateFromEclipse( 1 , "NOV" , 2000));
|
||||
BOOST_CHECK_EQUAL( boost::gregorian::date( 2000 , boost::gregorian::Dec , 1 ) , Opm::TimeMap::dateFromEclipse( 1 , "DEC" , 2000));
|
||||
BOOST_CHECK_EQUAL( boost::gregorian::date( 2000 , boost::gregorian::Dec , 1 ) , Opm::TimeMap::dateFromEclipse( 1 , "DES" , 2000));
|
||||
BOOST_CHECK_EQUAL( boost::posix_time::ptime(boost::gregorian::date( 2000 , boost::gregorian::Jan , 1 )) , Opm::TimeMap::timeFromEclipse( 1 , "JAN" , 2000));
|
||||
BOOST_CHECK_EQUAL( boost::posix_time::ptime(boost::gregorian::date( 2000 , boost::gregorian::Feb , 1 )) , Opm::TimeMap::timeFromEclipse( 1 , "FEB" , 2000));
|
||||
BOOST_CHECK_EQUAL( boost::posix_time::ptime(boost::gregorian::date( 2000 , boost::gregorian::Mar , 1 )) , Opm::TimeMap::timeFromEclipse( 1 , "MAR" , 2000));
|
||||
BOOST_CHECK_EQUAL( boost::posix_time::ptime(boost::gregorian::date( 2000 , boost::gregorian::Apr , 1 )) , Opm::TimeMap::timeFromEclipse( 1 , "APR" , 2000));
|
||||
BOOST_CHECK_EQUAL( boost::posix_time::ptime(boost::gregorian::date( 2000 , boost::gregorian::May , 1 )) , Opm::TimeMap::timeFromEclipse( 1 , "MAI" , 2000));
|
||||
BOOST_CHECK_EQUAL( boost::posix_time::ptime(boost::gregorian::date( 2000 , boost::gregorian::May , 1 )) , Opm::TimeMap::timeFromEclipse( 1 , "MAY" , 2000));
|
||||
BOOST_CHECK_EQUAL( boost::posix_time::ptime(boost::gregorian::date( 2000 , boost::gregorian::Jun , 1 )) , Opm::TimeMap::timeFromEclipse( 1 , "JUN" , 2000));
|
||||
BOOST_CHECK_EQUAL( boost::posix_time::ptime(boost::gregorian::date( 2000 , boost::gregorian::Jul , 1 )) , Opm::TimeMap::timeFromEclipse( 1 , "JUL" , 2000));
|
||||
BOOST_CHECK_EQUAL( boost::posix_time::ptime(boost::gregorian::date( 2000 , boost::gregorian::Jul , 1 )) , Opm::TimeMap::timeFromEclipse( 1 , "JLY" , 2000));
|
||||
BOOST_CHECK_EQUAL( boost::posix_time::ptime(boost::gregorian::date( 2000 , boost::gregorian::Aug , 1 )) , Opm::TimeMap::timeFromEclipse( 1 , "AUG" , 2000));
|
||||
BOOST_CHECK_EQUAL( boost::posix_time::ptime(boost::gregorian::date( 2000 , boost::gregorian::Sep , 1 )) , Opm::TimeMap::timeFromEclipse( 1 , "SEP" , 2000));
|
||||
BOOST_CHECK_EQUAL( boost::posix_time::ptime(boost::gregorian::date( 2000 , boost::gregorian::Oct , 1 )) , Opm::TimeMap::timeFromEclipse( 1 , "OKT" , 2000));
|
||||
BOOST_CHECK_EQUAL( boost::posix_time::ptime(boost::gregorian::date( 2000 , boost::gregorian::Oct , 1 )) , Opm::TimeMap::timeFromEclipse( 1 , "OCT" , 2000));
|
||||
BOOST_CHECK_EQUAL( boost::posix_time::ptime(boost::gregorian::date( 2000 , boost::gregorian::Nov , 1 )) , Opm::TimeMap::timeFromEclipse( 1 , "NOV" , 2000));
|
||||
BOOST_CHECK_EQUAL( boost::posix_time::ptime(boost::gregorian::date( 2000 , boost::gregorian::Dec , 1 )) , Opm::TimeMap::timeFromEclipse( 1 , "DEC" , 2000));
|
||||
BOOST_CHECK_EQUAL( boost::posix_time::ptime(boost::gregorian::date( 2000 , boost::gregorian::Dec , 1 )) , Opm::TimeMap::timeFromEclipse( 1 , "DES" , 2000));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE( dateFromEclipseInputRecord ) {
|
||||
BOOST_AUTO_TEST_CASE( timeFromEclipseInputRecord ) {
|
||||
Opm::DeckRecordPtr startRecord(new Opm::DeckRecord());
|
||||
Opm::DeckIntItemPtr dayItem( new Opm::DeckIntItem("DAY") );
|
||||
Opm::DeckStringItemPtr monthItem(new Opm::DeckStringItem("MONTH") );
|
||||
@@ -180,14 +182,14 @@ BOOST_AUTO_TEST_CASE( dateFromEclipseInputRecord ) {
|
||||
startRecord->addItem( monthItem );
|
||||
startRecord->addItem( yearItem );
|
||||
|
||||
BOOST_CHECK_EQUAL( boost::gregorian::date( 1987 , boost::gregorian::Jan , 10 ) , Opm::TimeMap::dateFromEclipse( startRecord ));
|
||||
BOOST_CHECK_EQUAL( boost::posix_time::ptime(boost::gregorian::date( 1987 , boost::gregorian::Jan , 10 )) , Opm::TimeMap::timeFromEclipse( startRecord ));
|
||||
}
|
||||
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE( addDATESFromWrongKeywordThrows ) {
|
||||
boost::gregorian::date startDate( 2010 , boost::gregorian::Jan , 1);
|
||||
Opm::TimeMap timeMap(startDate);
|
||||
Opm::TimeMap timeMap((boost::posix_time::ptime(startDate)));
|
||||
Opm::DeckKeywordConstPtr deckKeyword(new Opm::DeckKeyword("NOTDATES"));
|
||||
BOOST_CHECK_THROW( timeMap.addFromDATESKeyword( deckKeyword ) , std::invalid_argument );
|
||||
}
|
||||
@@ -196,7 +198,8 @@ BOOST_AUTO_TEST_CASE( addDATESFromWrongKeywordThrows ) {
|
||||
|
||||
BOOST_AUTO_TEST_CASE( addTSTEPFromWrongKeywordThrows ) {
|
||||
boost::gregorian::date startDate( 2010 , boost::gregorian::Jan , 1);
|
||||
Opm::TimeMap timeMap(startDate);
|
||||
boost::posix_time::ptime ptime(startDate);
|
||||
Opm::TimeMap timeMap(ptime);
|
||||
Opm::DeckKeywordConstPtr deckKeyword(new Opm::DeckKeyword("NOTTSTEP"));
|
||||
BOOST_CHECK_THROW( timeMap.addFromTSTEPKeyword( deckKeyword ) , std::invalid_argument );
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
Opm::TimeMapPtr createXDaysTimeMap(size_t numDays) {
|
||||
boost::gregorian::date startDate( 2010 , boost::gregorian::Jan , 1);
|
||||
Opm::TimeMapPtr timeMap(new Opm::TimeMap(startDate));
|
||||
Opm::TimeMapPtr timeMap(new Opm::TimeMap(boost::posix_time::ptime(startDate)));
|
||||
for (size_t i = 0; i < numDays; i++)
|
||||
timeMap->addTStep( boost::posix_time::hours( (i+1) * 24 ));
|
||||
return timeMap;
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
Opm::TimeMapPtr createXDaysTimeMap(size_t numDays) {
|
||||
boost::gregorian::date startDate( 2010 , boost::gregorian::Jan , 1);
|
||||
Opm::TimeMapPtr timeMap(new Opm::TimeMap(startDate));
|
||||
Opm::TimeMapPtr timeMap(new Opm::TimeMap(boost::posix_time::ptime(startDate)));
|
||||
for (size_t i = 0; i < numDays; i++)
|
||||
timeMap->addTStep( boost::posix_time::hours( (i+1) * 24 ));
|
||||
return timeMap;
|
||||
|
||||
@@ -81,7 +81,7 @@ BOOST_AUTO_TEST_CASE(CreatSchedule) {
|
||||
EclipseState state(deck);
|
||||
ScheduleConstPtr schedule = state.getSchedule();
|
||||
|
||||
BOOST_CHECK_EQUAL( schedule->getStartDate() , boost::gregorian::date(1998 , 3 , 8 ));
|
||||
BOOST_CHECK_EQUAL( schedule->getStartTime() , boost::posix_time::ptime(boost::gregorian::date(1998 , 3 , 8 )));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ BOOST_AUTO_TEST_CASE(CreateSchedule) {
|
||||
DeckPtr deck = parser->parseFile(scheduleFile.string());
|
||||
ScheduleConstPtr sched(new Schedule(deck));
|
||||
TimeMapConstPtr timeMap = sched->getTimeMap();
|
||||
BOOST_CHECK_EQUAL(boost::gregorian::date(2007, boost::gregorian::May, 10), sched->getStartDate());
|
||||
BOOST_CHECK_EQUAL(boost::posix_time::ptime(boost::gregorian::date(2007, boost::gregorian::May, 10)), sched->getStartTime());
|
||||
BOOST_CHECK_EQUAL(9U, timeMap->size());
|
||||
BOOST_CHECK( deck->hasKeyword("NETBALAN") );
|
||||
}
|
||||
@@ -53,7 +53,7 @@ BOOST_AUTO_TEST_CASE(CreateSchedule_Comments_After_Keywords) {
|
||||
DeckPtr deck = parser->parseFile(scheduleFile.string());
|
||||
ScheduleConstPtr sched(new Schedule(deck));
|
||||
TimeMapConstPtr timeMap = sched->getTimeMap();
|
||||
BOOST_CHECK_EQUAL(boost::gregorian::date(2007, boost::gregorian::May, 10), sched->getStartDate());
|
||||
BOOST_CHECK_EQUAL(boost::posix_time::ptime(boost::gregorian::date(2007, boost::gregorian::May, 10)), sched->getStartTime());
|
||||
BOOST_CHECK_EQUAL(9U, timeMap->size());
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user