diff --git a/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp b/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp index fe42546ca..020164cd0 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp +++ b/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp @@ -133,7 +133,7 @@ namespace Opm { } if (!hasWell(wellName)) { - addWell(wellName); + addWell(wellName , currentStep); } WellPtr well = getWell(wellName); @@ -272,8 +272,8 @@ namespace Opm { return m_rootGroupTree->get(timeStep); } - void Schedule::addWell(const std::string& wellName) { - WellPtr well(new Well(wellName, m_timeMap)); + void Schedule::addWell(const std::string& wellName, size_t timeStep) { + WellPtr well(new Well(wellName, m_timeMap , timeStep)); m_wells[ wellName ] = well; } diff --git a/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp b/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp index 0a02f4e63..986c861f9 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp +++ b/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp @@ -62,7 +62,7 @@ namespace Opm void iterateScheduleSection(DeckConstPtr deck); bool handleGroupFromWELSPECS(const std::string& groupName, GroupTreePtr newTree) const; void addGroup(const std::string& groupName); - void addWell(const std::string& wellName); + void addWell(const std::string& wellName , size_t timeStep); void handleWELSPECS(DeckKeywordConstPtr keyword, size_t currentStep); void handleWCONProducer(DeckKeywordConstPtr keyword, size_t currentStep, bool isPredictionMode); void handleWCONHIST(DeckKeywordConstPtr keyword , size_t currentStep); diff --git a/opm/parser/eclipse/EclipseState/Schedule/Well.cpp b/opm/parser/eclipse/EclipseState/Schedule/Well.cpp index c49b1a1b5..c8cd979fd 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/Well.cpp +++ b/opm/parser/eclipse/EclipseState/Schedule/Well.cpp @@ -29,7 +29,7 @@ namespace Opm { - Well::Well(const std::string& name , TimeMapConstPtr timeMap) + Well::Well(const std::string& name , TimeMapConstPtr timeMap , size_t createTimeStep) : m_oilRate( new DynamicState( timeMap , 0.0)) , m_gasRate(new DynamicState(timeMap, 0.0)), m_waterRate(new DynamicState(timeMap, 0.0)), @@ -40,6 +40,7 @@ namespace Opm { m_groupName( new DynamicState( timeMap , "" )) { m_name = name; + m_createTimeStep = createTimeStep; } const std::string& Well::name() const { @@ -47,6 +48,14 @@ namespace Opm { } + bool Well::hasBeenDefined(size_t timeStep) const { + if (timeStep < m_createTimeStep) + return false; + else + return true; + } + + double Well::getOilRate(size_t timeStep) const { return m_oilRate->get(timeStep); } diff --git a/opm/parser/eclipse/EclipseState/Schedule/Well.hpp b/opm/parser/eclipse/EclipseState/Schedule/Well.hpp index d008c52a5..6668576dd 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/Well.hpp +++ b/opm/parser/eclipse/EclipseState/Schedule/Well.hpp @@ -33,9 +33,10 @@ namespace Opm { class Well { public: - Well(const std::string& name, TimeMapConstPtr timeMap); + Well(const std::string& name, TimeMapConstPtr timeMap , size_t createTimeStep); const std::string& name() const; + bool hasBeenDefined(size_t timeStep) const; const std::string getGroupName(size_t timeStep) const; void setGroupName(size_t timeStep , const std::string& groupName); @@ -59,6 +60,7 @@ namespace Opm { void switch2Producer(size_t timeStep ); void switch2Injector(size_t timeStep ); + size_t m_createTimeStep; std::string m_name; boost::shared_ptr > m_oilRate; boost::shared_ptr > m_gasRate; diff --git a/opm/parser/eclipse/EclipseState/Schedule/tests/GroupTests.cpp b/opm/parser/eclipse/EclipseState/Schedule/tests/GroupTests.cpp index e51da3333..ece430d81 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/tests/GroupTests.cpp +++ b/opm/parser/eclipse/EclipseState/Schedule/tests/GroupTests.cpp @@ -117,8 +117,8 @@ BOOST_AUTO_TEST_CASE(GroupAddWell) { Opm::TimeMapPtr timeMap = createXDaysTimeMap(10); Opm::Group group("G1" , timeMap); - Opm::WellPtr well1(new Opm::Well("WELL1" , timeMap)); - Opm::WellPtr well2(new Opm::Well("WELL2" , timeMap)); + Opm::WellPtr well1(new Opm::Well("WELL1" , timeMap , 0)); + Opm::WellPtr well2(new Opm::Well("WELL2" , timeMap , 0)); BOOST_CHECK_EQUAL(0U , group.numWells(2)); group.addWell( 3 , well1 ); @@ -154,8 +154,8 @@ BOOST_AUTO_TEST_CASE(GroupAddAndDelWell) { Opm::TimeMapPtr timeMap = createXDaysTimeMap(10); Opm::Group group("G1" , timeMap); - Opm::WellPtr well1(new Opm::Well("WELL1" , timeMap)); - Opm::WellPtr well2(new Opm::Well("WELL2" , timeMap)); + Opm::WellPtr well1(new Opm::Well("WELL1" , timeMap , 0)); + Opm::WellPtr well2(new Opm::Well("WELL2" , timeMap , 0)); BOOST_CHECK_EQUAL(0U , group.numWells(2)); group.addWell( 3 , well1 ); diff --git a/opm/parser/eclipse/EclipseState/Schedule/tests/WellSetTests.cpp b/opm/parser/eclipse/EclipseState/Schedule/tests/WellSetTests.cpp index 3985df4b2..442e1a76d 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/tests/WellSetTests.cpp +++ b/opm/parser/eclipse/EclipseState/Schedule/tests/WellSetTests.cpp @@ -53,8 +53,8 @@ BOOST_AUTO_TEST_CASE(AddAndDeleteWell) { Opm::WellSet wellSet; Opm::TimeMapPtr timeMap = createXDaysTimeMap(10); - Opm::WellPtr well(new Opm::Well("WELL1" , timeMap)); - Opm::WellPtr well2(new Opm::Well("WELL2" , timeMap)); + Opm::WellPtr well(new Opm::Well("WELL1" , timeMap , 0)); + Opm::WellPtr well2(new Opm::Well("WELL2" , timeMap , 0)); wellSet.addWell( well ); BOOST_CHECK_EQUAL(true , wellSet.hasWell("WELL1")); @@ -78,8 +78,8 @@ BOOST_AUTO_TEST_CASE(AddWellSameName) { Opm::WellSet wellSet; Opm::TimeMapPtr timeMap = createXDaysTimeMap(10); - Opm::WellPtr well1(new Opm::Well("WELL" , timeMap)); - Opm::WellPtr well2(new Opm::Well("WELL" , timeMap)); + Opm::WellPtr well1(new Opm::Well("WELL" , timeMap, 0)); + Opm::WellPtr well2(new Opm::Well("WELL" , timeMap , 0)); wellSet.addWell( well1 ); BOOST_CHECK_EQUAL(true , wellSet.hasWell("WELL")); diff --git a/opm/parser/eclipse/EclipseState/Schedule/tests/WellTests.cpp b/opm/parser/eclipse/EclipseState/Schedule/tests/WellTests.cpp index e49857700..22c6fc884 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/tests/WellTests.cpp +++ b/opm/parser/eclipse/EclipseState/Schedule/tests/WellTests.cpp @@ -40,14 +40,25 @@ Opm::TimeMapPtr createXDaysTimeMap(size_t numDays) { BOOST_AUTO_TEST_CASE(CreateWell_CorrectNameAndDefaultValues) { Opm::TimeMapPtr timeMap = createXDaysTimeMap(10); - Opm::Well well("WELL1" , timeMap); + Opm::Well well("WELL1" , timeMap , 0); BOOST_CHECK_EQUAL( "WELL1" , well.name() ); BOOST_CHECK_EQUAL(0.0 , well.getOilRate( 5 )); } +BOOST_AUTO_TEST_CASE(CreateWellCreateTimeStepOK) { + Opm::TimeMapPtr timeMap = createXDaysTimeMap(10); + Opm::Well well("WELL1" , timeMap , 5); + BOOST_CHECK_EQUAL( false , well.hasBeenDefined(0) ); + BOOST_CHECK_EQUAL( false , well.hasBeenDefined(4) ); + BOOST_CHECK_EQUAL( true , well.hasBeenDefined(5) ); + BOOST_CHECK_EQUAL( true , well.hasBeenDefined(7) ); + +} + + BOOST_AUTO_TEST_CASE(setOilRate_RateSetCorrect) { Opm::TimeMapPtr timeMap = createXDaysTimeMap(10); - Opm::Well well("WELL1" , timeMap); + Opm::Well well("WELL1" , timeMap , 0); BOOST_CHECK_EQUAL(0.0 , well.getOilRate( 5 )); well.setOilRate( 5 , 99 ); @@ -57,7 +68,7 @@ BOOST_AUTO_TEST_CASE(setOilRate_RateSetCorrect) { BOOST_AUTO_TEST_CASE(setPredictionMode_ModeSetCorrect) { Opm::TimeMapPtr timeMap = createXDaysTimeMap(10); - Opm::Well well("WELL1" , timeMap); + Opm::Well well("WELL1" , timeMap , 0); BOOST_CHECK_EQUAL( true, well.isInPredictionMode( 5 )); well.setInPredictionMode( 5 , false ); // Go to history mode @@ -69,7 +80,7 @@ BOOST_AUTO_TEST_CASE(setPredictionMode_ModeSetCorrect) { BOOST_AUTO_TEST_CASE(NewWellZeroCompletions) { Opm::TimeMapPtr timeMap = createXDaysTimeMap(10); - Opm::Well well("WELL1" , timeMap); + Opm::Well well("WELL1" , timeMap , 0); Opm::CompletionSetConstPtr completions = well.getCompletions( 0 ); BOOST_CHECK_EQUAL( 0U , completions->size()); } @@ -77,7 +88,7 @@ BOOST_AUTO_TEST_CASE(NewWellZeroCompletions) { BOOST_AUTO_TEST_CASE(UpdateCompletions) { Opm::TimeMapPtr timeMap = createXDaysTimeMap(10); - Opm::Well well("WELL1" , timeMap); + Opm::Well well("WELL1" , timeMap , 0); Opm::CompletionSetConstPtr completions = well.getCompletions( 0 ); BOOST_CHECK_EQUAL( 0U , completions->size()); @@ -115,7 +126,7 @@ BOOST_AUTO_TEST_CASE(UpdateCompletions) { BOOST_AUTO_TEST_CASE(setGasRate_RateSetCorrect) { Opm::TimeMapPtr timeMap = createXDaysTimeMap(10); - Opm::Well well("WELL1" , timeMap); + Opm::Well well("WELL1" , timeMap , 0); BOOST_CHECK_EQUAL(0.0 , well.getGasRate( 5 )); well.setGasRate( 5 , 108 ); @@ -127,7 +138,7 @@ BOOST_AUTO_TEST_CASE(setGasRate_RateSetCorrect) { BOOST_AUTO_TEST_CASE(setWaterRate_RateSetCorrect) { Opm::TimeMapPtr timeMap = createXDaysTimeMap(10); - Opm::Well well("WELL1" , timeMap); + Opm::Well well("WELL1" , timeMap , 0); BOOST_CHECK_EQUAL(0.0 , well.getWaterRate( 5 )); well.setWaterRate( 5 , 108 ); @@ -138,7 +149,7 @@ BOOST_AUTO_TEST_CASE(setWaterRate_RateSetCorrect) { BOOST_AUTO_TEST_CASE(setInjectionRate_RateSetCorrect) { Opm::TimeMapPtr timeMap = createXDaysTimeMap(10); - Opm::Well well("WELL1" , timeMap); + Opm::Well well("WELL1" , timeMap , 0); BOOST_CHECK_EQUAL(0.0 , well.getInjectionRate( 5 )); well.setInjectionRate( 5 , 108 ); @@ -149,7 +160,7 @@ BOOST_AUTO_TEST_CASE(setInjectionRate_RateSetCorrect) { BOOST_AUTO_TEST_CASE(isProducerCorrectlySet) { Opm::TimeMapPtr timeMap = createXDaysTimeMap(10); - Opm::Well well("WELL1" , timeMap); + Opm::Well well("WELL1" , timeMap ,0); /* 1: Well is created as producer */ BOOST_CHECK_EQUAL( false , well.isInjector(0)); @@ -186,7 +197,7 @@ BOOST_AUTO_TEST_CASE(isProducerCorrectlySet) { BOOST_AUTO_TEST_CASE(GroupnameCorretlySet) { Opm::TimeMapPtr timeMap = createXDaysTimeMap(10); - Opm::Well well("WELL1" , timeMap); + Opm::Well well("WELL1" , timeMap ,0); BOOST_CHECK_EQUAL("" , well.getGroupName(2));