Replace connection segIndex and compSeqIndex with sort_value member

This commit is contained in:
Joakim Hove 2020-03-19 14:07:53 +01:00
parent 91841a99e1
commit 9ad8465609
5 changed files with 71 additions and 30 deletions

View File

@ -93,7 +93,7 @@ namespace RestartIO {
const int satTableId,
const Direction direction,
const CTFKind ctf_kind,
const std::size_t seqIndex,
const std::size_t sort_value,
const double segDistStart,
const double segDistEnd,
const bool defaultSatTabId);
@ -130,9 +130,8 @@ namespace RestartIO {
std::size_t compseg_insert_index,
double start,
double end);
const std::size_t& getSeqIndex() const;
std::size_t sort_value() const;
const bool& getDefaultSatTabId() const;
const std::size_t& getCompSegSeqIndex() const;
void setDefaultSatTabId(bool id);
const double& getSegDistStart() const;
const double& getSegDistEnd() const;
@ -161,11 +160,10 @@ namespace RestartIO {
serializer(ijk);
serializer(m_global_index);
serializer(m_ctfkind);
serializer(m_seqIndex);
serializer(m_sort_value);
serializer(m_segDistStart);
serializer(m_segDistEnd);
serializer(m_defaultSatTabId);
serializer(m_compSeg_seqIndex);
serializer(segment_number);
serializer(wPi);
}
@ -185,11 +183,62 @@ namespace RestartIO {
std::array<int,3> ijk;
CTFKind m_ctfkind;
std::size_t m_global_index;
std::size_t m_seqIndex;
/*
The sort_value member is a peculiar quantity. The connections are
assembled in the WellConnections class. During the lifetime of the
connections there are three different sort orders which are all
relevant:
input: This is the ordering implied be the order of the
connections in the input deck.
simulation: This is the ordering the connections have in
WellConnections container during the simulation and RFT output.
restart: This is the ordering the connections have when they are
written out to a restart file.
Exactly what consitutes input, simulation and restart ordering, and
how the connections transition between the three during application
lifetime is different from MSW and normal wells.
normal wells: For normal wells the simulation order is given by the
COMPORD keyword, and then when the connections are serialized to the
restart file they are written in input order; i.e. we have:
input == restart and simulation given COMPORD
To recover the input order when creating the restart files the
sort_value member corresponds to the insert index for normal wells.
MSW wells: For MSW wells the wells simulator order[*] is given by
COMPSEGS keyword, the COMPORD keyword is ignored. The connections are
sorted in WellConnections::order() and then retain that order for all
eternity i.e.
input and simulation == restart
Now the important point is that the COMPSEGS detail used to perform
this sorting is not available when loading from a restart file, but
then the connections are already sorted correctly. I.e. *after* a
restart we will have:
input(from restart) == simulation == restart
The sort_value member is used to sort the connections into restart
ordering. In the case of normal wells this corresponds to recovering
the input order, whereas for MSW wells this is equivalent to the
simulation order.
[*]: For MSW wells the topology is given by the segments and entered
explicitly, so the truth is probably that the storage order
during simulation makes no difference?
*/
std::size_t m_sort_value;
double m_segDistStart;
double m_segDistEnd;
bool m_defaultSatTabId;
std::size_t m_compSeg_seqIndex=0;
// related segment number
// 0 means the completion is not related to segment

View File

@ -3100,7 +3100,7 @@ bool Schedule::cmp(const Schedule& sched1, const Schedule& sched2, std::size_t r
well_count += not_equal( conn1.complnum() , conn2.complnum(), well_msg(well1.name(), "connection: complnum"));
well_count += not_equal( conn1.segment() , conn2.segment(), well_msg(well1.name(), "Connection: segment"));
well_count += not_equal( conn1.kind() , conn2.kind(), well_msg(well1.name(), "Connection: CFKind"));
well_count += not_equal( conn1.getSeqIndex(), conn2.getSeqIndex(), well_msg(well1.name(), "Connection: insertIndex"));
well_count += not_equal( conn1.sort_value(), conn2.sort_value(), well_msg(well1.name(), "Connection: sort_value"));
well_count += not_equal( conn1.CF(), conn2.CF(), well_msg(well1.name(), "Connection: CF"));

View File

@ -53,7 +53,7 @@ namespace Opm {
const int satTableId,
const Direction directionArg,
const CTFKind ctf_kind,
const std::size_t seqIndex,
const std::size_t sort_value,
const double segDistStart,
const double segDistEnd,
const bool defaultSatTabId)
@ -70,7 +70,7 @@ namespace Opm {
ijk({i,j,k}),
m_ctfkind(ctf_kind),
m_global_index(global_index),
m_seqIndex(seqIndex),
m_sort_value(sort_value),
m_segDistStart(segDistStart),
m_segDistEnd(segDistEnd),
m_defaultSatTabId(defaultSatTabId)
@ -79,7 +79,6 @@ namespace Opm {
namespace {
constexpr bool defaultSatTabId = true;
constexpr int compseg_seqIndex = 1;
constexpr double def_wellPi = 1.0;
}
@ -97,11 +96,10 @@ Connection::Connection(const RestartIO::RstConnection& rst_connection, std::size
ijk(rst_connection.ijk),
m_ctfkind(rst_connection.cf_kind),
m_global_index(grid.getGlobalIndex(this->ijk[0], this->ijk[1], this->ijk[2])),
m_seqIndex(insert_index),
m_sort_value(insert_index),
m_segDistStart(rst_connection.segdist_start),
m_segDistEnd(rst_connection.segdist_end),
m_defaultSatTabId(defaultSatTabId),
m_compSeg_seqIndex(compseg_seqIndex),
segment_number(rst_connection.segment),
wPi(def_wellPi)
{
@ -134,11 +132,9 @@ Connection::Connection(const RestartIO::RstConnection& rst_connection, std::size
result.ijk = {9, 10, 11};
result.m_ctfkind = CTFKind::Defaulted;
result.m_global_index = 12;
result.m_seqIndex = 13;
result.m_segDistStart = 14.0;
result.m_sort_value = 14;
result.m_segDistEnd = 15.0;
result.m_defaultSatTabId = true;
result.m_compSeg_seqIndex = 15;
result.segment_number = 16;
result.wPi = 17.0;
@ -173,18 +169,14 @@ Connection::Connection(const RestartIO::RstConnection& rst_connection, std::size
return (segment_number > 0);
}
const std::size_t& Connection::getSeqIndex() const {
return m_seqIndex;
std::size_t Connection::sort_value() const {
return m_sort_value;
}
const bool& Connection::getDefaultSatTabId() const {
return m_defaultSatTabId;
}
const std::size_t& Connection::getCompSegSeqIndex() const {
return m_compSeg_seqIndex;
}
Connection::Direction Connection::dir() const {
return this->direction;
}
@ -253,7 +245,7 @@ Connection::Connection(const RestartIO::RstConnection& rst_connection, std::size
double end) {
this->segment_number = segment_number_arg;
this->center_depth = center_depth_arg;
this->m_compSeg_seqIndex = compseg_insert_index;
this->m_sort_value = compseg_insert_index;
this->m_segDistStart = start;
this->m_segDistEnd = end;
}
@ -288,7 +280,7 @@ Connection::Connection(const RestartIO::RstConnection& rst_connection, std::size
ss << "CTF Source " << Connection::CTFKindToString(this->m_ctfkind) << '\n';
ss << "segment_nr " << this->segment_number << std::endl;
ss << "center_depth " << this->center_depth << std::endl;
ss << "seqIndex " << this->m_seqIndex << std::endl;
ss << "sort_value" << this->m_sort_value<< std::endl;
return ss.str();
}
@ -308,7 +300,7 @@ Connection::Connection(const RestartIO::RstConnection& rst_connection, std::size
&& this->direction == rhs.direction
&& this->segment_number == rhs.segment_number
&& this->center_depth == rhs.center_depth
&& this->m_seqIndex == rhs.m_seqIndex;
&& this->m_sort_value == rhs.m_sort_value;
}
bool Connection::operator!=( const Connection& rhs ) const {

View File

@ -175,7 +175,7 @@ inline std::array< size_t, 3> directionIndices(const Opm::Connection::Direction
if (!this->m_connections[0].attachedToSegment() && (this->m_ordering != Connection::Order::INPUT)) {
std::sort(out.begin(), out.end(), [](const Opm::Connection* conn1, const Opm::Connection* conn2)
{
return conn1->getSeqIndex() < conn2->getSeqIndex();
return conn1->sort_value() < conn2->sort_value();
});
}
return out;
@ -388,7 +388,7 @@ inline std::array< size_t, 3> directionIndices(const Opm::Connection::Direction
direction, ctf_kind,
noConn, 0., 0., defaultSatTable);
} else {
std::size_t css_ind = prev->getCompSegSeqIndex();
std::size_t css_ind = prev->sort_value();
int conSegNo = prev->segment();
double conSDStart = prev->getSegDistStart();
double conSDEnd = prev->getSegDistEnd();
@ -405,7 +405,7 @@ inline std::array< size_t, 3> directionIndices(const Opm::Connection::Direction
skin_factor,
satTableId,
direction, ctf_kind,
prev->getSeqIndex(), conSDStart, conSDEnd, defaultSatTable);
prev->sort_value(), conSDStart, conSDEnd, defaultSatTable);
prev->updateSegment(conSegNo,
depth,
@ -486,7 +486,7 @@ inline std::array< size_t, 3> directionIndices(const Opm::Connection::Direction
void WellConnections::orderMSW() {
std::sort(this->m_connections.begin(), this->m_connections.end(), [](const Opm::Connection& conn1, const Opm::Connection& conn2)
{
return conn1.getCompSegSeqIndex() < conn2.getCompSegSeqIndex();
return conn1.sort_value() < conn2.sort_value();
});
}

View File

@ -47,7 +47,7 @@ void compare_connections(const RestartIO::RstConnection& rst_conn, const Connect
BOOST_CHECK_EQUAL(rst_conn.ijk[2], sched_conn.getK());
BOOST_CHECK_EQUAL(rst_conn.segment, sched_conn.segment());
BOOST_CHECK_EQUAL(rst_conn.insert_index, static_cast<int>(sched_conn.getSeqIndex()));
BOOST_CHECK_EQUAL(rst_conn.insert_index, static_cast<int>(sched_conn.sort_value()));
BOOST_CHECK(rst_conn.state == sched_conn.state());
BOOST_CHECK(rst_conn.dir == sched_conn.dir());
BOOST_CHECK_CLOSE( rst_conn.cf, sched_conn.CF() , 1e-6);