Removed well property total number of connections

For the output code the total number of connections entered in the input deck is
required, we therefor keep track of the number of connections filtered out due
to inactive cells - and return the total in WellConnection::inputSize()
This commit is contained in:
Joakim Hove
2019-03-14 13:22:32 +01:00
parent 5421efd79d
commit eb15695ed0
11 changed files with 51 additions and 56 deletions

View File

@@ -28,7 +28,7 @@
namespace Opm {
WellConnections * newConnectionsWithSegments(const DeckKeyword& compsegs, const WellConnections& input_connections,
const WellSegments& segments, const EclipseGrid& grid, std::size_t& totNC);
const WellSegments& segments, const EclipseGrid& grid);
}
#endif

View File

@@ -57,9 +57,8 @@ namespace Opm {
WellCompletion::CompletionOrderEnum completionOrdering = WellCompletion::TRACK,
bool allowCrossFlow = true, bool automaticShutIn = true);
const std::string& name() const;
const size_t& seqIndex() const;
std::size_t getTotNoConn() const;
void setTotNoConn(std::size_t noConn);
const size_t& seqIndex() const;
std::size_t getTotNoConn() const;
bool hasBeenDefined(size_t timeStep) const;
const std::string getGroupName(size_t timeStep) const;
void setGroupName(size_t timeStep , const std::string& groupName);
@@ -208,9 +207,8 @@ namespace Opm {
private:
size_t m_creationTimeStep;
std::string m_name;
std::size_t m_seqIndex;
std::size_t m_totNoConn=0;
std::size_t m_seqIndex;
DynamicState< WellCommon::StatusEnum > m_status;
DynamicState< int > m_isAvailableForGroupControl;

View File

@@ -46,12 +46,13 @@ namespace Opm {
const double segDistStart= 0.0,
const double segDistEnd= 0.0,
const bool defaultSatTabId = true);
void loadCOMPDAT(const DeckRecord& record, const EclipseGrid& grid, const Eclipse3DProperties& eclipseProperties, std::size_t& totNC);
void loadCOMPDAT(const DeckRecord& record, const EclipseGrid& grid, const Eclipse3DProperties& eclipseProperties);
using const_iterator = std::vector< Connection >::const_iterator;
void add( Connection );
size_t size() const;
size_t inputSize() const;
const Connection& operator[](size_t index) const;
const Connection& get(size_t index) const;
const Connection& getFromIJK(const int i, const int j, const int k) const;
@@ -59,9 +60,6 @@ namespace Opm {
const_iterator begin() const { return this->m_connections.begin(); }
const_iterator end() const { return this->m_connections.end(); }
std::size_t totNoConn() const { return this->m_connections.size(); }
void filter(const EclipseGrid& grid);
bool allConnectionsShut() const;
/// Order connections irrespective of input order.
@@ -101,6 +99,7 @@ namespace Opm {
size_t findClosestConnection(int oi, int oj, double oz, size_t start_pos);
int headI, headJ;
size_t num_removed = 0;
std::vector< Connection > m_connections;
};
}

View File

@@ -50,7 +50,7 @@ namespace Opm {
{
}
std::vector< Compsegs > Compsegs::compsegsFromCOMPSEGSKeyword( const DeckKeyword& compsegsKeyword, const EclipseGrid& grid, std::size_t& totNC ) {
std::vector< Compsegs > Compsegs::compsegsFromCOMPSEGSKeyword( const DeckKeyword& compsegsKeyword, const EclipseGrid& grid) {
// only handle the second record here
// The first record here only contains the well name
@@ -124,19 +124,17 @@ namespace Opm {
// will decide the segment number based on the distance in a process later.
}
if (!record.getItem<ParserKeywords::COMPSEGS::END_IJK>().hasValue(0)) { // only one compsegs
if (grid.cellActive(I, J, K)) {
std::size_t seqIndex = compsegs.size();
totNC = seqIndex+1;
compsegs.emplace_back( I, J, K,
branch,
distance_start, distance_end,
direction,
center_depth,
segment_number,
seqIndex
);
}
if (grid.cellActive(I, J, K)) {
std::size_t seqIndex = compsegs.size();
compsegs.emplace_back( I, J, K,
branch,
distance_start, distance_end,
direction,
center_depth,
segment_number,
seqIndex);
}
} else { // a range is defined. genrate a range of Compsegs
throw std::runtime_error("entering COMPSEGS entries with a range is not supported yet!");
}

View File

@@ -58,7 +58,7 @@ namespace Opm {
void calculateCenterDepthWithSegments(const WellSegments& segment_set);
static std::vector< Compsegs > compsegsFromCOMPSEGSKeyword( const DeckKeyword& compsegsKeyword, const EclipseGrid& grid, std::size_t& totNC );
static std::vector< Compsegs > compsegsFromCOMPSEGSKeyword( const DeckKeyword& compsegsKeyword, const EclipseGrid& grid);
// get the segment number information and depth information based on the information from WellSegments
static void processCOMPSEGS(std::vector< Compsegs >& compsegs, const WellSegments& segment_set );

View File

@@ -27,13 +27,10 @@ namespace Opm {
WellConnections * newConnectionsWithSegments(const DeckKeyword& compsegs,
const WellConnections& input_connections,
const WellSegments& segment_set,
const EclipseGrid& grid,
std::size_t& totNC
)
const EclipseGrid& grid)
{
WellConnections * new_connection_set = new WellConnections(input_connections);
std::vector<Compsegs> compsegs_vector = Compsegs::compsegsFromCOMPSEGSKeyword( compsegs, grid, totNC );
std::vector<Compsegs> compsegs_vector = Compsegs::compsegsFromCOMPSEGSKeyword( compsegs, grid );
Compsegs::processCOMPSEGS(compsegs_vector, segment_set);
Compsegs::updateConnectionsWithSegment(compsegs_vector, grid, *new_connection_set);
return new_connection_set;

View File

@@ -402,13 +402,12 @@ namespace Opm {
}
std::size_t Well::getTotNoConn() const {
return this->m_totNoConn;
std::size_t time_step = this->timesteps;
const auto& connections = this->getConnections(time_step);
return connections.inputSize();
}
void Well::setTotNoConn(std::size_t noConn) {
m_totNoConn = noConn;
}
const std::string Well::getGroupName(size_t time_step) const {
return m_groupName.get(time_step);
}
@@ -709,11 +708,7 @@ namespace Opm {
void Well::handleCOMPDAT(size_t time_step, const DeckRecord& record, const EclipseGrid& grid, const Eclipse3DProperties& eclipseProperties) {
WellConnections * connections = new WellConnections(this->getConnections(time_step));
std::size_t totNC = 0;
connections->loadCOMPDAT(record, grid, eclipseProperties, totNC);
if (totNC > 0) {
this->setTotNoConn(totNC);
}
connections->loadCOMPDAT(record, grid, eclipseProperties);
this->updateWellConnections(time_step, connections);
}
@@ -721,11 +716,7 @@ namespace Opm {
void Well::handleCOMPSEGS(const DeckKeyword& keyword, const EclipseGrid& grid, size_t time_step) {
const auto& segment_set = this->getWellSegments(time_step);
const auto& completion_set = this->getConnections( time_step );
std::size_t totNC = 0;
WellConnections * new_connection_set = newConnectionsWithSegments(keyword, completion_set, segment_set, grid, totNC);
if (totNC > 0) {
this->setTotNoConn(totNC);
}
WellConnections * new_connection_set = newConnectionsWithSegments(keyword, completion_set, segment_set, grid);
this->updateWellConnections(time_step, new_connection_set);
}

View File

@@ -192,7 +192,7 @@ namespace {
defaultSatTabId);
}
void WellConnections::loadCOMPDAT(const DeckRecord& record, const EclipseGrid& grid, const Eclipse3DProperties& eclipseProperties, std::size_t& totNC) {
void WellConnections::loadCOMPDAT(const DeckRecord& record, const EclipseGrid& grid, const Eclipse3DProperties& eclipseProperties) {
const auto& permx = eclipseProperties.getDoubleGridProperty("PERMX").getData();
const auto& permy = eclipseProperties.getDoubleGridProperty("PERMY").getData();
const auto& permz = eclipseProperties.getDoubleGridProperty("PERMZ").getData();
@@ -298,7 +298,6 @@ namespace {
if (grid.cellActive(I, J, k)) {
if (prev == this->m_connections.end()) {
std::size_t noConn = this->m_connections.size();
totNC = noConn+1;
this->addConnection(I,J,k,
grid.getCellDepth( I,J,k ),
state,
@@ -343,6 +342,10 @@ namespace {
size_t WellConnections::inputSize() const {
return m_connections.size() + this->num_removed;
}
size_t WellConnections::size() const {
return m_connections.size();
}
@@ -464,6 +467,7 @@ namespace {
auto new_end = std::remove_if(m_connections.begin(),
m_connections.end(),
[&grid](const Connection& c) { return !grid.cellActive(c.getI(), c.getJ(), c.getK()); });
this->num_removed += std::distance(new_end, m_connections.end());
m_connections.erase(new_end, m_connections.end());
}
}

View File

@@ -150,9 +150,8 @@ Opm::WellConnections loadCOMPDAT(const std::string& compdat_keyword) {
Opm::Eclipse3DProperties props(deck, tables, grid );
const auto& keyword = deck.getKeyword("COMPDAT", 0);
Opm::WellConnections connections;
std::size_t totnc = 0;
for (const auto& rec : keyword)
connections.loadCOMPDAT(rec, grid, props, totnc);
connections.loadCOMPDAT(rec, grid, props);
return connections;
}

View File

@@ -87,8 +87,7 @@ BOOST_AUTO_TEST_CASE(MultisegmentWellTest) {
segment_set.loadWELSEGS(welsegs);
BOOST_CHECK_EQUAL(6U, segment_set.size());
std::size_t totNC = 0;
const Opm::WellConnections * new_connection_set = Opm::newConnectionsWithSegments(compsegs, connection_set, segment_set, grid, totNC);
const Opm::WellConnections * new_connection_set = Opm::newConnectionsWithSegments(compsegs, connection_set, segment_set, grid);
BOOST_CHECK_EQUAL(7U, new_connection_set->size());

View File

@@ -2601,16 +2601,26 @@ BOOST_AUTO_TEST_CASE(FilterCompletions) {
Runspec runspec (deck);
Schedule schedule(deck, grid1 , eclipseProperties, runspec);
const auto& well = schedule.getWell("OP_1");
const auto& c1_1 = well->getConnections(1);
const auto& c1_3 = well->getConnections(3);
BOOST_CHECK_EQUAL(2, c1_1.size());
BOOST_CHECK_EQUAL(9, c1_3.size());
{
const auto& c1_1 = well->getConnections(1);
const auto& c1_3 = well->getConnections(3);
BOOST_CHECK_EQUAL(2, c1_1.size());
BOOST_CHECK_EQUAL(9, c1_3.size());
}
actnum[grid1.getGlobalIndex(8,8,1)] = 0;
{
EclipseGrid grid2(grid1, actnum);
schedule.filterConnections(grid2);
const auto& c1_1 = well->getConnections(1);
const auto& c1_3 = well->getConnections(3);
BOOST_CHECK_EQUAL(1, c1_1.size());
BOOST_CHECK_EQUAL(8, c1_3.size());
BOOST_CHECK_EQUAL(2, c1_1.inputSize());
BOOST_CHECK_EQUAL(9, c1_3.inputSize());
BOOST_CHECK_EQUAL( well->getTotNoConn(), 9);
}
}