Adds Group::getWells method
Add support for querying what wells are in a given group at a certain time step.
This commit is contained in:
@@ -318,6 +318,9 @@ namespace Opm {
|
||||
return wellSet->getWell(wellName);
|
||||
}
|
||||
|
||||
const WellSet& Group::getWells( size_t time_step ) const {
|
||||
return *this->wellMap( time_step );
|
||||
}
|
||||
|
||||
size_t Group::numWells(size_t time_step) const {
|
||||
WellSetConstPtr wellSet = wellMap(time_step);
|
||||
|
||||
@@ -101,6 +101,7 @@ namespace Opm {
|
||||
|
||||
bool hasWell(const std::string& wellName , size_t time_step) const;
|
||||
std::shared_ptr< const Well > getWell(const std::string& wellName , size_t time_step) const;
|
||||
const WellSet& getWells( size_t time_step ) const;
|
||||
size_t numWells(size_t time_step) const;
|
||||
void addWell(size_t time_step , std::shared_ptr< Well > well);
|
||||
void delWell(size_t time_step, const std::string& wellName );
|
||||
|
||||
@@ -69,4 +69,12 @@ namespace Opm {
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
WellSet::const_iterator WellSet::begin() const {
|
||||
return this->m_wells.begin();
|
||||
}
|
||||
|
||||
WellSet::const_iterator WellSet::end() const {
|
||||
return this->m_wells.end();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,8 @@ namespace Opm {
|
||||
|
||||
class WellSet {
|
||||
public:
|
||||
using const_iterator = std::map< std::string, std::shared_ptr< Well > >::const_iterator;
|
||||
|
||||
WellSet();
|
||||
size_t size() const;
|
||||
bool hasWell(const std::string& wellName) const;
|
||||
@@ -36,6 +38,10 @@ namespace Opm {
|
||||
void addWell(std::shared_ptr< Well > well);
|
||||
void delWell(const std::string& wellName);
|
||||
WellSet * shallowCopy() const;
|
||||
|
||||
const_iterator begin() const;
|
||||
const_iterator end() const;
|
||||
|
||||
private:
|
||||
std::map<std::string , std::shared_ptr< Well >> m_wells;
|
||||
};
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Well.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/WellSet.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Group.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/IOConfig/IOConfig.hpp>
|
||||
@@ -227,7 +228,40 @@ BOOST_AUTO_TEST_CASE(GroupAddAndDelWell) {
|
||||
BOOST_CHECK_THROW( group.delWell( 8 , "WELL1" ) , std::invalid_argument);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(getWells) {
|
||||
Opm::TimeMapPtr timeMap = createXDaysTimeMap(10);
|
||||
Opm::Group group("G1" , timeMap , 0);
|
||||
std::shared_ptr<const Opm::EclipseGrid> grid = std::make_shared<const Opm::EclipseGrid>(10,10,10);
|
||||
Opm::WellPtr well1(new Opm::Well("WELL1" , grid , 0, 0, Opm::Value<double>("REF_DEPTH"), Opm::Phase::OIL, timeMap, 0));
|
||||
Opm::WellPtr well2(new Opm::Well("WELL2" , grid , 0, 0, Opm::Value<double>("REF_DEPTH"), Opm::Phase::OIL, timeMap, 0));
|
||||
|
||||
group.addWell( 2 , well1 );
|
||||
group.addWell( 3 , well1 );
|
||||
group.addWell( 3 , well2 );
|
||||
group.addWell( 4 , well1 );
|
||||
|
||||
std::vector< std::string > names = { "WELL1", "WELL2" };
|
||||
std::vector< std::string > wnames;
|
||||
for( const auto& pair : group.getWells( 3 ) )
|
||||
wnames.push_back( pair.first );
|
||||
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS( names.begin(), names.end(),
|
||||
wnames.begin(), wnames.end() );
|
||||
|
||||
const auto& wells = group.getWells( 3 );
|
||||
BOOST_CHECK_EQUAL( wells.size(), 2U );
|
||||
BOOST_CHECK( wells.hasWell( "WELL1" ) );
|
||||
BOOST_CHECK( wells.hasWell( "WELL2" ) );
|
||||
|
||||
BOOST_CHECK_EQUAL( group.getWells( 0 ).size(), 0U );
|
||||
BOOST_CHECK_EQUAL( group.getWells( 2 ).size(), 1U );
|
||||
BOOST_CHECK( group.getWells( 2 ).hasWell( "WELL1" ) );
|
||||
BOOST_CHECK( !group.getWells( 2 ).hasWell( "WELL2" ) );
|
||||
BOOST_CHECK_EQUAL( group.getWells( 4 ).size(), 2U );
|
||||
BOOST_CHECK( group.getWells( 4 ).hasWell( "WELL1" ) );
|
||||
BOOST_CHECK( group.getWells( 4 ).hasWell( "WELL2" ) );
|
||||
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(createDeckWithGEFAC) {
|
||||
Opm::Parser parser;
|
||||
|
||||
@@ -90,3 +90,15 @@ BOOST_AUTO_TEST_CASE(AddWellSameName) {
|
||||
BOOST_CHECK_NO_THROW( wellSet.addWell( well1 ));
|
||||
BOOST_CHECK_THROW( wellSet.addWell( well2 ) , std::invalid_argument );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(Iterator) {
|
||||
Opm::WellSet wellSet;
|
||||
Opm::TimeMapPtr timeMap = createXDaysTimeMap(10);
|
||||
|
||||
std::shared_ptr<const Opm::EclipseGrid> grid = std::make_shared<const Opm::EclipseGrid>(10,10,10);
|
||||
Opm::WellPtr well1(new Opm::Well("WELL" , grid , 0, 0,Opm::Value<double>("REF_DEPTH"), Opm::Phase::OIL, timeMap , 0));
|
||||
Opm::WellPtr well2(new Opm::Well("WELL" , grid , 0, 0, Opm::Value<double>("REF_DEPTH"), Opm::Phase::OIL, timeMap , 0));
|
||||
|
||||
for( const auto& well : wellSet )
|
||||
BOOST_CHECK( well.second->isProducer( 0 ) );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user