OPM-217: Fixed IOConfig RPTRST BASIC with frequency
This commit is contained in:
@@ -114,8 +114,8 @@ namespace Opm {
|
||||
write_restart_file = true;
|
||||
} else {
|
||||
std::vector<size_t>::const_iterator ci_start = timesteps.begin();
|
||||
int index = std::distance( ci_start, ci_timestep );
|
||||
if( (index % frequency) == 0) {
|
||||
int dist = std::distance( ci_start, ci_timestep ) + 1;
|
||||
if( ( (dist > 0) && ((dist % frequency) == 0) ) ) {
|
||||
write_restart_file = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,10 +172,10 @@ BOOST_AUTO_TEST_CASE(IOConfigTest) {
|
||||
frequency = 0;
|
||||
ioConfigPtr->handleRPTRSTBasic(schedule.getTimeMap(),timestep, basic, frequency);
|
||||
|
||||
/*Expected results: Write timestep for timestep 17, 20, 22, 23, 26*/
|
||||
/*Expected results: Write timestep for timestep 20, 22, 23, 26*/
|
||||
|
||||
for (size_t ts = 17; ts <= 26; ++ts) {
|
||||
if ((17 == ts) || (20 == ts) || (22 == ts) || (23 == ts) || (26 == ts)) {
|
||||
if ((20 == ts) || (22 == ts) || (23 == ts) || (26 == ts)) {
|
||||
BOOST_CHECK_EQUAL(true, ioConfigPtr->getWriteRestartFile(ts));
|
||||
} else {
|
||||
BOOST_CHECK_EQUAL(false, ioConfigPtr->getWriteRestartFile(ts));
|
||||
@@ -202,10 +202,10 @@ BOOST_AUTO_TEST_CASE(IOConfigTest) {
|
||||
frequency = 2;
|
||||
ioConfigPtr->handleRPTRSTBasic(schedule.getTimeMap(), timestep, basic, frequency);
|
||||
|
||||
//Expected results: Write timestep for 27, 32 and 36 (27, 30, 32, 33, 36 with frequency 2)
|
||||
//Expected results: Write timestep for 32 and 36 (30, 32, 33, 36 with frequency 2)
|
||||
|
||||
for (size_t ts = 27; ts <= 36; ++ts) {
|
||||
if ((27 == ts) || (32 == ts) || (36 == ts)) {
|
||||
if ((32 == ts) || (36 == ts)) {
|
||||
BOOST_CHECK_EQUAL(true, ioConfigPtr->getWriteRestartFile(ts));
|
||||
} else {
|
||||
BOOST_CHECK_EQUAL(false, ioConfigPtr->getWriteRestartFile(ts));
|
||||
@@ -236,7 +236,7 @@ BOOST_AUTO_TEST_CASE(IOConfigTest) {
|
||||
//Expected results: Write timestep for timestep 38, 44 (38, 42, 44 with frequency 2)
|
||||
|
||||
for (size_t ts = 37; ts <= 46; ++ts) {
|
||||
if ((38 == ts) || (44 == ts)) {
|
||||
if (42 == ts) {
|
||||
BOOST_CHECK_EQUAL(true, ioConfigPtr->getWriteRestartFile(ts));
|
||||
} else {
|
||||
BOOST_CHECK_EQUAL(false, ioConfigPtr->getWriteRestartFile(ts));
|
||||
|
||||
@@ -229,7 +229,7 @@ namespace Opm {
|
||||
void TimeMap::initFirstTimestepsMonths(std::vector<size_t>& timesteps, size_t from_timestep) const {
|
||||
timesteps.clear();
|
||||
|
||||
const boost::posix_time::ptime& ptime_prev = getStartTime(from_timestep-1);
|
||||
const boost::posix_time::ptime& ptime_prev = getStartTime(from_timestep);
|
||||
boost::gregorian::date prev_date = ptime_prev.date();
|
||||
|
||||
for (size_t timestepIndex = from_timestep; timestepIndex < m_timeList.size(); ++timestepIndex) {
|
||||
@@ -248,7 +248,7 @@ namespace Opm {
|
||||
void TimeMap::initFirstTimestepsYears(std::vector<size_t>& timesteps, size_t from_timestep) const {
|
||||
timesteps.clear();
|
||||
|
||||
const boost::posix_time::ptime& ptime_prev = getStartTime(from_timestep-1);
|
||||
const boost::posix_time::ptime& ptime_prev = getStartTime(from_timestep);
|
||||
boost::gregorian::date prev_date = ptime_prev.date();
|
||||
|
||||
for (size_t timestepIndex = from_timestep; timestepIndex < m_timeList.size(); ++timestepIndex) {
|
||||
|
||||
@@ -337,9 +337,9 @@ BOOST_AUTO_TEST_CASE(initTimestepsYearsAndMonths) {
|
||||
|
||||
first_timestep_of_each_month.clear();
|
||||
tmap.initFirstTimestepsMonths(first_timestep_of_each_month, 6);
|
||||
BOOST_CHECK_EQUAL(7, first_timestep_of_each_month.size());
|
||||
int expected_results3[7] = {6,8,9,10,11,12,13};
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(expected_results3, expected_results3+7, first_timestep_of_each_month.begin(), first_timestep_of_each_month.end());
|
||||
BOOST_CHECK_EQUAL(6, first_timestep_of_each_month.size());
|
||||
int expected_results3[6] = {8,9,10,11,12,13};
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(expected_results3, expected_results3+6, first_timestep_of_each_month.begin(), first_timestep_of_each_month.end());
|
||||
|
||||
std::vector<size_t> first_timestep_of_each_year;
|
||||
tmap.initFirstTimestepsYears(first_timestep_of_each_year);
|
||||
@@ -349,6 +349,6 @@ BOOST_AUTO_TEST_CASE(initTimestepsYearsAndMonths) {
|
||||
|
||||
first_timestep_of_each_year.clear();
|
||||
tmap.initFirstTimestepsYears(first_timestep_of_each_year, 13);
|
||||
BOOST_CHECK_EQUAL(1, first_timestep_of_each_year.size());
|
||||
BOOST_CHECK_EQUAL(0, first_timestep_of_each_year.size());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user