Skip to content

Commit e6ccaa4

Browse files
committed
WIP: fix depth/length handling
1 parent 17be30b commit e6ccaa4

File tree

9 files changed

+48
-30
lines changed

9 files changed

+48
-30
lines changed

opm/input/eclipse/Schedule/MSW/Compsegs.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ namespace {
361361
}
362362

363363
std::pair<WellConnections, WellSegments>
364-
processCOMPSEGS(const std::vector<std::pair<double, double>>& intersection_depths,
364+
processCOMPSEGS(const std::vector<std::pair<double, double>>& intersections_md,
365365
const std::vector<std::array<int, 3>>& intersections_ijk,
366366
const WellSegments& segments,
367367
const WellConnections& input_connections,
@@ -370,9 +370,9 @@ namespace {
370370
{
371371
std::vector<Record> compsegs;
372372

373-
for (size_t is = 0; is < intersection_depths.size(); ++is) {
374-
const auto startMD = intersection_depths[is].first;
375-
const auto endMD = intersection_depths[is].second;
373+
for (size_t is = 0; is < intersections_md.size(); ++is) {
374+
const auto startMD = intersections_md[is].first;
375+
const auto endMD = intersections_md[is].second;
376376
const auto ijk = intersections_ijk[is];
377377

378378
// Defaulted values:

opm/input/eclipse/Schedule/MSW/Compsegs.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ namespace Compsegs {
5959
ErrorGuard& errors);
6060

6161
std::pair<WellConnections, WellSegments>
62-
processCOMPSEGS(const std::vector<std::pair<double, double>>& intersection_depths,
62+
processCOMPSEGS(const std::vector<std::pair<double, double>>& intersections_md,
6363
const std::vector<std::array<int, 3>>& intersections_ijk,
6464
const WellSegments& segments,
6565
const WellConnections& input_connections,

opm/input/eclipse/Schedule/MSW/WellSegments.cpp

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,13 @@ namespace Opm {
6464

6565

6666
WellSegments::WellSegments(const std::string &wname, double length_top,
67-
const std::vector<std::pair<double, double>>& intersections,
67+
const std::vector<std::pair<double, double>>& intersections_md,
68+
const std::vector<std::pair<double, double>>& intersections_tvd,
6869
double diameter, const UnitSystem& unit_system)
6970
{
70-
this->addWellSegmentsFromIntersections(wname, length_top, intersections, diameter, unit_system);
71+
this->addWellSegmentsFromIntersections(
72+
wname, length_top, intersections_md, intersections_tvd, diameter, unit_system
73+
);
7174
}
7275

7376

@@ -194,7 +197,8 @@ namespace Opm {
194197

195198

196199
void WellSegments::addWellSegmentsFromIntersections(const std::string &wname, double length_top,
197-
const std::vector<std::pair<double, double>>& intersections,
200+
const std::vector<std::pair<double, double>>& intersections_md,
201+
const std::vector<std::pair<double, double>>& intersections_tvd,
198202
double diameter, const UnitSystem& unit_system)
199203
{
200204
// Meaningless value to indicate unspecified values.
@@ -221,28 +225,33 @@ namespace Opm {
221225
const double volume = invalid_value;
222226

223227
// If necessary add an extra segment at the top:
224-
if (intersections[0].first > length_top) {
225-
const auto startMD = intersections[0].first;
226-
const auto length = (startMD - length_top) / 2.0 + length_top;
227-
const auto depth = length;
228+
if (intersections_md[0].first > length_top) {
229+
const auto startMD = intersections_md[0].first;
230+
const auto startTVD = intersections_tvd[0].first;
231+
const auto length = 0.5 * (startMD + length_top);
232+
const auto depth = 0.5 * (startTVD + length_top);
228233
const auto outletSegmendID = segmentID - 1;
229234
this->addSegment(
230235
segmentID, branchID, outletSegmendID,
231-
length, depth, diameter,
236+
depth, length, diameter,
232237
roughness, area, volume, true,
233238
0.0, 0.0
234239
);
235240
segmentID += 1;
236241
}
237242

238243
// Add a segment for each cell:
239-
for (const auto& [startMD, endMD] : intersections) {
240-
const auto length = (endMD - startMD) / 2.0 + startMD;
241-
const auto depth = length;
244+
for (auto it_md = intersections_md.begin(), it_tvd = intersections_tvd.begin();
245+
it_md != intersections_md.end() && it_tvd != intersections_tvd.end();
246+
++it_md, ++it_tvd) {
247+
const auto& [startMD, endMD] = *it_md;
248+
const auto& [startTVD, endTVD] = *it_tvd;
249+
const auto length = 0.5 * (startMD + endMD);
250+
const auto depth = 0.5 * (startTVD + endTVD);
242251
const auto outletSegmendID = segmentID - 1;
243252
this->addSegment(
244253
segmentID, branchID, outletSegmendID,
245-
length, depth, diameter,
254+
depth, length, diameter,
246255
roughness, area, volume, true,
247256
0.0, 0.0
248257
);

opm/input/eclipse/Schedule/MSW/WellSegments.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,12 @@ namespace Opm {
7272
const std::vector<Segment>& segments);
7373
void loadWELSEGS( const DeckKeyword& welsegsKeyword, const UnitSystem& unit_system);
7474
explicit WellSegments(const std::string &wname, double length_top,
75-
const std::vector<std::pair<double, double>>& intersections,
75+
const std::vector<std::pair<double, double>>& intersections_md,
76+
const std::vector<std::pair<double, double>>& intersections_tvd,
7677
double diameter, const UnitSystem& unit_system);
7778
void addWellSegmentsFromIntersections(const std::string &wname, double length_top,
78-
const std::vector<std::pair<double, double>>& intersections,
79+
const std::vector<std::pair<double, double>>& intersections_md,
80+
const std::vector<std::pair<double, double>>& intersections_tvd,
7981
double diameter, const UnitSystem& unit_system);
8082

8183
static WellSegments serializationTestObject();

opm/input/eclipse/Schedule/Well/Well.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1808,17 +1808,18 @@ bool Well::handleWELSEGS(const DeckKeyword& keyword)
18081808
}
18091809

18101810
void Well::addWellSegmentsFromIntersections(double length_top,
1811-
const std::vector<std::pair<double, double>>& intersections,
1811+
const std::vector<std::pair<double, double>>& intersections_md,
1812+
const std::vector<std::pair<double, double>>& intersection_tvd,
18121813
double diameter)
18131814
{
18141815
if (this->segments != nullptr) {
18151816
auto new_segments = std::make_shared<WellSegments>(*this->segments);
1816-
new_segments->addWellSegmentsFromIntersections(this->name(), length_top, intersections, diameter, *unit_system);
1817+
new_segments->addWellSegmentsFromIntersections(this->name(), length_top, intersections_md, intersection_tvd, diameter, *unit_system);
18171818

18181819
this->updateSegments(std::move(new_segments));
18191820
}
18201821
else {
1821-
this->updateSegments(std::make_shared<WellSegments>(this->name(), length_top, intersections, diameter, *unit_system));
1822+
this->updateSegments(std::make_shared<WellSegments>(this->name(), length_top, intersections_md, intersection_tvd, diameter, *unit_system));
18221823
}
18231824
}
18241825

opm/input/eclipse/Schedule/Well/Well.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,8 @@ class Well {
564564
double evalFilterConc(const SummaryState& summary_sate) const;
565565
bool applyGlobalWPIMULT(double scale_factor);
566566
void addWellSegmentsFromIntersections(double length_top,
567-
const std::vector<std::pair<double, double>>& intersections,
567+
const std::vector<std::pair<double, double>>& intersections_md,
568+
const std::vector<std::pair<double, double>>& intersections_tvd,
568569
double diameter);
569570

570571
void filterConnections(const ActiveGridCells& grid);

opm/input/eclipse/Schedule/Well/WellCompletionKeywordHandlers.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,14 +172,16 @@ void handleCOMPTRAJ(HandlerContext& handlerContext)
172172
// cellsearchTree is calculated only once and is used to
173173
// calculated cell intersections of the perforations
174174
// specified in COMPTRAJ
175-
std::vector<std::pair<double, double>> intersection_depths;
175+
std::vector<std::pair<double, double>> intersections_md;
176+
std::vector<std::pair<double, double>> intersections_tvd;
176177
std::vector<std::array<int, 3>> intersection_ijk;
177178
connections->loadCOMPTRAJ(record,
178179
handlerContext.grid,
179180
name,
180181
handlerContext.keyword.location(),
181182
cellSearchTree,
182-
intersection_depths,
183+
intersections_md,
184+
intersections_tvd,
183185
intersection_ijk);
184186

185187
// In the case that defaults are used in WELSPECS for
@@ -208,15 +210,15 @@ Well {} is not connected to grid - will remain SHUT)",
208210
const auto& diameter = record.getItem("DIAMETER").getSIDouble(0);
209211

210212
auto well = handlerContext.state().wells.get(name);
211-
well.addWellSegmentsFromIntersections(perf_top, intersection_depths, diameter);
213+
well.addWellSegmentsFromIntersections(perf_top, intersections_md, intersections_tvd, diameter);
212214
handlerContext.state().wells.update(std::move(well));
213215
handlerContext.record_well_structure_change();
214216
}
215217

216218
if (add_msw) { // Generate COMPSEGS data:
217219
auto well = handlerContext.state().wells.get(name);
218220
auto [new_connections, new_segments] = Compsegs::processCOMPSEGS(
219-
intersection_depths, intersection_ijk, well.getSegments(), well.getConnections(), well.getSegments(), handlerContext.grid
221+
intersections_md, intersection_ijk, well.getSegments(), well.getConnections(), well.getSegments(), handlerContext.grid
220222
);
221223

222224
well.updateConnections(std::make_shared<WellConnections>(std::move(new_connections)), false);

opm/input/eclipse/Schedule/Well/WellConnections.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,8 @@ The cell ({},{},{}) in well {} is not active and the connection will be ignored)
587587
const std::string& wname,
588588
const KeywordLocation& location,
589589
external::cvf::ref<external::cvf::BoundingBoxTree>& cellSearchTree,
590-
std::vector<std::pair<double, double>>& intersection_depths,
590+
std::vector<std::pair<double, double>>& intersections_md,
591+
std::vector<std::pair<double, double>>& intersections_tvd,
591592
std::vector<std::array<int, 3>>& intersection_ijk)
592593
{
593594
const auto& perf_top = record.getItem("PERF_TOP");
@@ -667,7 +668,8 @@ The cell ({},{},{}) in well {} is not active and the connection will be ignored)
667668

668669
for (size_t is = 0; is < intersections.size(); ++is) {
669670
const auto ijk = ecl_grid->getIJK(intersections[is].globCellIndex);
670-
intersection_depths.emplace_back(intersections[is].startMD, intersections[is].endMD);
671+
intersections_md.emplace_back(intersections[is].startMD, intersections[is].endMD);
672+
intersections_tvd.emplace_back(intersections[is].startPoint[2], intersections[is].endPoint[2]);
671673
intersection_ijk.push_back(ijk);
672674

673675
// When using WELTRAJ & COMPTRAJ one may use default settings in

opm/input/eclipse/Schedule/Well/WellConnections.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ namespace Opm {
104104
const std::string& wname,
105105
const KeywordLocation& location,
106106
external::cvf::ref<external::cvf::BoundingBoxTree>& cellSearchTree,
107-
std::vector<std::pair<double, double>>& intersection_depths,
107+
std::vector<std::pair<double, double>>& intersections_md,
108+
std::vector<std::pair<double, double>>& intersections_tvd,
108109
std::vector<std::array<int, 3>>& intersection_ijk);
109110

110111
void loadWELTRAJ(const DeckRecord& record,

0 commit comments

Comments
 (0)