implement == for Well

This commit is contained in:
Pål Grønås Drange
2017-01-09 14:09:34 +01:00
parent 36d2e1349d
commit 67e2199a68
3 changed files with 34 additions and 0 deletions

View File

@@ -88,6 +88,17 @@ namespace Opm {
}
bool Well::operator==(const Well& other) const {
return this->m_creationTimeStep == other.m_creationTimeStep
&& this->m_name == other.m_name
&& this->m_preferredPhase == other.m_preferredPhase
&& this->timesteps == other.timesteps;
}
bool Well::operator!=(const Well& other) const {
return !(*this == other);
}
double Well::production_rate( Phase phase, size_t timestep ) const {
if( !this->isProducer( timestep ) ) return 0.0;

View File

@@ -105,6 +105,9 @@ namespace Opm {
double production_rate( Phase phase, size_t timestep ) const;
double injection_rate( Phase phase, size_t timestep ) const;
bool operator==(const Well&) const;
bool operator!=(const Well&) const;
bool setProductionProperties(size_t timeStep , const WellProductionProperties properties);
WellProductionProperties getProductionPropertiesCopy(size_t timeStep) const;
const WellProductionProperties& getProductionProperties(size_t timeStep) const;

View File

@@ -55,6 +55,9 @@ namespace Opm {
inline std::ostream& operator<<( std::ostream& stream, const Completion& c ) {
return stream << "(" << c.getI() << "," << c.getJ() << "," << c.getK() << ")";
}
inline std::ostream& operator<<( std::ostream& stream, const Well& well ) {
return stream << "(" << well.name() << ")";
}
}
BOOST_AUTO_TEST_CASE(CreateWell_CorrectNameAndDefaultValues) {
@@ -64,6 +67,23 @@ BOOST_AUTO_TEST_CASE(CreateWell_CorrectNameAndDefaultValues) {
BOOST_CHECK_EQUAL(0.0 , well.getProductionPropertiesCopy(5).OilRate);
}
BOOST_AUTO_TEST_CASE(CreateWell_Equals) {
auto timeMap = createXDaysTimeMap(10);
auto timeMap2 = createXDaysTimeMap(11);
Opm::Well well1("WELL1" , 0, 0, 0.0, Opm::Phase::OIL, timeMap , 0);
Opm::Well well2("WELL1" , 0, 0, 0.0, Opm::Phase::OIL, timeMap , 0);
Opm::Well well3("WELL3" , 0, 0, 0.0, Opm::Phase::OIL, timeMap , 0);
Opm::Well well4("WELL3" , 0, 0, 0.0, Opm::Phase::OIL, timeMap2 , 0);
BOOST_CHECK_EQUAL( well1, well1 );
BOOST_CHECK_EQUAL( well2, well1 );
BOOST_CHECK( well1 == well2 );
BOOST_CHECK( well1 != well3 );
BOOST_CHECK( well3 != well2 );
BOOST_CHECK( well3 == well3 );
BOOST_CHECK( well4 != well3 );
}
BOOST_AUTO_TEST_CASE(CreateWell_GetProductionPropertiesShouldReturnSameObject) {
auto timeMap = createXDaysTimeMap(10);
Opm::Well well("WELL1" , 0, 0, 0.0, Opm::Phase::OIL, timeMap , 0);