Merge pull request #2102 from bska/cxl-support-dynamic-connections

CxL: Account for Dynamically Changing Set of Connections
This commit is contained in:
Joakim Hove 2020-11-11 19:31:15 +01:00 committed by GitHub
commit 2374ae2127
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 111 additions and 2 deletions

View File

@ -26,6 +26,7 @@
#include <opm/common/utility/ActiveGridCells.hpp>
#include <cstddef>
#include <optional>
#include <vector>
#include <stddef.h>
@ -163,6 +164,10 @@ namespace Opm {
int headI, headJ;
std::vector< Connection > m_connections;
};
std::optional<int>
getCompletionNumberFromGlobalConnectionIndex(const WellConnections& connections,
const std::size_t global_index);
}

View File

@ -579,9 +579,13 @@ inline quantity cratel( const fn_args& args ) {
const auto& well_data = args.wells.at( name );
if (well_data.current_control.isProducer == injection) return zero;
const auto complnum = getCompletionNumberFromGlobalConnectionIndex(well.getConnections(), args.num - 1);
if (!complnum.has_value())
// Connection might not yet have come online.
return zero;
double sum = 0;
const auto& conn0 = well.getConnections().getFromGlobalIndex( args.num - 1);
const auto& connections = well.getConnections(conn0.complnum()) ;
const auto& connections = well.getConnections(*complnum);
for (const auto& conn_ptr : connections) {
const size_t global_index = conn_ptr->global_index();
const auto& conn_data = std::find_if(well_data.connections.begin(),

View File

@ -633,4 +633,20 @@ inline std::array< size_t, 3> directionIndices(const Opm::Connection::Direction
}
std::optional<int>
getCompletionNumberFromGlobalConnectionIndex(const WellConnections& connections,
const std::size_t global_index)
{
auto connPos = std::find_if(connections.begin(), connections.end(),
[global_index](const Connection& conn)
{
return conn.global_index() == global_index;
});
if (connPos == connections.end())
// No connection exists with the requisite 'global_index'
return {};
return { connPos->complnum() };
}
}

View File

@ -518,3 +518,87 @@ END
BOOST_CHECK_CLOSE(connP[2].CF(), 50.0*cp_rm3_per_db(), 1.0e-10);
}
}
BOOST_AUTO_TEST_CASE(Completion_From_Global_Connection_Index) {
const auto deck = Opm::Parser{}.parseString(R"(RUNSPEC
START
7 OCT 2020 /
DIMENS
10 10 3 /
GRID
DXV
10*100.0 /
DYV
10*100.0 /
DZV
3*10.0 /
DEPTHZ
121*2000.0 /
PERMX
300*100.0 /
PERMY
300*100.0 /
PERMZ
300*10.0 /
PORO
300*0.3 /
SCHEDULE
WELSPECS
'P' 'G' 10 10 2005 'LIQ' /
/
COMPDAT
'P' 0 0 1 1 OPEN 1 100 /
/
TSTEP
10
/
COMPDAT
'P' 0 0 2 2 OPEN 1 50 /
/
TSTEP
10
/
END
)");
const auto es = Opm::EclipseState{ deck };
const auto sched = Opm::Schedule{ deck, es };
{
const auto connP = sched.getWell("P", 0).getConnections();
const auto complnum_100 =
getCompletionNumberFromGlobalConnectionIndex(connP, 100 - 1);
const auto complnum_200 =
getCompletionNumberFromGlobalConnectionIndex(connP, 200 - 1);
BOOST_CHECK_MESSAGE( complnum_100.has_value(), "Completion number must be defined at time 0 for connection in cell (10,10,1)");
BOOST_CHECK_MESSAGE(! complnum_200.has_value(), "Completion number must NOT be defined at time 0 for connection in cell (10,10,2)");
BOOST_CHECK_EQUAL(complnum_100.value(), 1);
}
{
const auto connP = sched.getWell("P", 1).getConnections();
const auto complnum_100 =
getCompletionNumberFromGlobalConnectionIndex(connP, 100 - 1);
const auto complnum_200 =
getCompletionNumberFromGlobalConnectionIndex(connP, 200 - 1);
BOOST_CHECK_MESSAGE(complnum_100.has_value(), "Completion number must be defined at time 0 for connection in cell (10,10,1)");
BOOST_CHECK_MESSAGE(complnum_200.has_value(), "Completion number must be defined at time 0 for connection in cell (10,10,2)");
BOOST_CHECK_EQUAL(complnum_100.value(), 1);
BOOST_CHECK_EQUAL(complnum_200.value(), 2);
}
}