Merge pull request #2005 from bska/wellconnections-empty
Add Convenience Predicate WellConnections::empty
This commit is contained in:
commit
cc4f8faa4c
@ -61,6 +61,7 @@ namespace Opm {
|
|||||||
|
|
||||||
void add( Connection );
|
void add( Connection );
|
||||||
size_t size() const;
|
size_t size() const;
|
||||||
|
bool empty() const;
|
||||||
const Connection& operator[](size_t index) const;
|
const Connection& operator[](size_t index) const;
|
||||||
const Connection& get(size_t index) const;
|
const Connection& get(size_t index) const;
|
||||||
const Connection& getFromIJK(const int i, const int j, const int k) const;
|
const Connection& getFromIJK(const int i, const int j, const int k) const;
|
||||||
|
@ -664,7 +664,7 @@ bool Well::updateConnections(std::shared_ptr<WellConnections> connections_arg) {
|
|||||||
|
|
||||||
bool Well::updateConnections(std::shared_ptr<WellConnections> connections_arg, const EclipseGrid& grid, const std::vector<int>& pvtnum) {
|
bool Well::updateConnections(std::shared_ptr<WellConnections> connections_arg, const EclipseGrid& grid, const std::vector<int>& pvtnum) {
|
||||||
bool update = this->updateConnections(connections_arg);
|
bool update = this->updateConnections(connections_arg);
|
||||||
if (this->pvt_table == 0 && this->connections->size() > 0) {
|
if (this->pvt_table == 0 && !this->connections->empty()) {
|
||||||
const auto& lowest = this->connections->lowest();
|
const auto& lowest = this->connections->lowest();
|
||||||
auto active_index = grid.activeIndex(lowest.global_index());
|
auto active_index = grid.activeIndex(lowest.global_index());
|
||||||
this->pvt_table = pvtnum[active_index];
|
this->pvt_table = pvtnum[active_index];
|
||||||
@ -778,7 +778,7 @@ double Well::getRefDepth() const {
|
|||||||
return this->ref_depth;
|
return this->ref_depth;
|
||||||
|
|
||||||
// ref depth was defaulted and we get the depth of the first completion
|
// ref depth was defaulted and we get the depth of the first completion
|
||||||
if( this->connections->size() == 0 ) {
|
if( this->connections->empty() ) {
|
||||||
throw std::invalid_argument( "No completions defined for well: "
|
throw std::invalid_argument( "No completions defined for well: "
|
||||||
+ name()
|
+ name()
|
||||||
+ ". Can not infer reference depth" );
|
+ ". Can not infer reference depth" );
|
||||||
|
@ -417,6 +417,10 @@ inline std::array< size_t, 3> directionIndices(const Opm::Connection::Direction
|
|||||||
return m_connections.size();
|
return m_connections.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool WellConnections::empty() const {
|
||||||
|
return this->size() == size_t{0};
|
||||||
|
}
|
||||||
|
|
||||||
const Connection& WellConnections::get(size_t index) const {
|
const Connection& WellConnections::get(size_t index) const {
|
||||||
return (*this)[index];
|
return (*this)[index];
|
||||||
}
|
}
|
||||||
@ -466,7 +470,7 @@ inline std::array< size_t, 3> directionIndices(const Opm::Connection::Direction
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool WellConnections::allConnectionsShut( ) const {
|
bool WellConnections::allConnectionsShut( ) const {
|
||||||
if (this->size() == 0)
|
if (this->empty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
||||||
|
@ -61,6 +61,7 @@ inline std::ostream& operator<<( std::ostream& stream, const WellConnections& cs
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(CreateWellConnectionsOK) {
|
BOOST_AUTO_TEST_CASE(CreateWellConnectionsOK) {
|
||||||
Opm::WellConnections completionSet(Opm::Connection::Order::TRACK, 1,1);
|
Opm::WellConnections completionSet(Opm::Connection::Order::TRACK, 1,1);
|
||||||
|
BOOST_CHECK_MESSAGE( completionSet.empty(), "Default-constructed completion set must be empty" );
|
||||||
BOOST_CHECK_EQUAL( 0U , completionSet.size() );
|
BOOST_CHECK_EQUAL( 0U , completionSet.size() );
|
||||||
BOOST_CHECK(!completionSet.allConnectionsShut());
|
BOOST_CHECK(!completionSet.allConnectionsShut());
|
||||||
}
|
}
|
||||||
@ -75,6 +76,7 @@ BOOST_AUTO_TEST_CASE(AddCompletionSizeCorrect) {
|
|||||||
Opm::Connection completion2( 10,10,11, 102, 1, 0.0, Opm::Connection::State::SHUT , 99.88, 355.113, 0.25, 0.0, 0.0, 0, dir, kind, 0, true);
|
Opm::Connection completion2( 10,10,11, 102, 1, 0.0, Opm::Connection::State::SHUT , 99.88, 355.113, 0.25, 0.0, 0.0, 0, dir, kind, 0, true);
|
||||||
completionSet.add( completion1 );
|
completionSet.add( completion1 );
|
||||||
BOOST_CHECK_EQUAL( 1U , completionSet.size() );
|
BOOST_CHECK_EQUAL( 1U , completionSet.size() );
|
||||||
|
BOOST_CHECK_MESSAGE( !completionSet.empty(), "Non-empty completion set must not be empty" );
|
||||||
|
|
||||||
completionSet.add( completion2 );
|
completionSet.add( completion2 );
|
||||||
BOOST_CHECK_EQUAL( 2U , completionSet.size() );
|
BOOST_CHECK_EQUAL( 2U , completionSet.size() );
|
||||||
|
Loading…
Reference in New Issue
Block a user