2017-05-15 09:04:11 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2017-05-16 07:50:54 -05:00
|
|
|
// Copyright (C) 2017 Statoil ASA
|
2017-05-15 09:04:11 -05:00
|
|
|
//
|
|
|
|
// ResInsight is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RicWellPathExportCompletionDataFeature.h"
|
|
|
|
|
|
|
|
#include "RiaApplication.h"
|
|
|
|
#include "RiaLogging.h"
|
|
|
|
|
|
|
|
#include "RimProject.h"
|
|
|
|
#include "RimWellPath.h"
|
2017-05-29 08:52:35 -05:00
|
|
|
#include "RimWellPathCollection.h"
|
2017-05-15 09:04:11 -05:00
|
|
|
#include "RimFishbonesMultipleSubs.h"
|
2017-05-19 08:44:32 -05:00
|
|
|
#include "RimFishbonesCollection.h"
|
2017-05-30 02:26:45 -05:00
|
|
|
#include "RimFishboneWellPath.h"
|
|
|
|
#include "RimFishboneWellPathCollection.h"
|
2017-05-29 06:13:25 -05:00
|
|
|
#include "RimPerforationInterval.h"
|
|
|
|
#include "RimPerforationCollection.h"
|
2017-05-30 07:37:51 -05:00
|
|
|
#include "RicExportCompletionDataSettingsUi.h"
|
2017-05-15 09:04:11 -05:00
|
|
|
|
|
|
|
#include "RiuMainWindow.h"
|
|
|
|
|
|
|
|
#include "RigWellLogExtractionTools.h"
|
2017-05-29 06:13:25 -05:00
|
|
|
#include "RigWellPathIntersectionTools.h"
|
2017-05-15 09:04:11 -05:00
|
|
|
#include "RigEclipseCaseData.h"
|
|
|
|
#include "RigMainGrid.h"
|
|
|
|
#include "RigWellPath.h"
|
|
|
|
|
|
|
|
#include "cafSelectionManager.h"
|
|
|
|
#include "cafPdmUiPropertyViewDialog.h"
|
|
|
|
|
2017-05-19 04:28:02 -05:00
|
|
|
#include "cvfPlane.h"
|
|
|
|
|
2017-05-15 09:04:11 -05:00
|
|
|
#include <QAction>
|
|
|
|
#include <QFileDialog>
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
2017-05-16 07:50:54 -05:00
|
|
|
CAF_CMD_SOURCE_INIT(RicWellPathExportCompletionDataFeature, "RicWellPathExportCompletionDataFeature");
|
2017-05-15 09:04:11 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RicWellPathExportCompletionDataFeature::isCommandEnabled()
|
|
|
|
{
|
2017-05-29 08:52:35 -05:00
|
|
|
return !selectedWellPaths().empty();
|
2017-05-15 09:04:11 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RicWellPathExportCompletionDataFeature::onActionTriggered(bool isChecked)
|
|
|
|
{
|
2017-05-29 08:52:35 -05:00
|
|
|
std::vector<RimWellPath*> wellPaths = selectedWellPaths();
|
2017-05-15 09:04:11 -05:00
|
|
|
|
2017-05-29 08:52:35 -05:00
|
|
|
CVF_ASSERT(wellPaths.size() > 0);
|
2017-05-15 09:04:11 -05:00
|
|
|
|
|
|
|
RiaApplication* app = RiaApplication::instance();
|
|
|
|
|
|
|
|
QString projectFolder = app->currentProjectPath();
|
|
|
|
QString defaultDir = RiaApplication::instance()->lastUsedDialogDirectoryWithFallback("COMPLETIONS", projectFolder);
|
|
|
|
|
2017-05-30 07:37:51 -05:00
|
|
|
RicExportCompletionDataSettingsUi exportSettings;
|
2017-05-19 04:09:36 -05:00
|
|
|
std::vector<RimCase*> cases;
|
|
|
|
app->project()->allCases(cases);
|
|
|
|
for (auto c : cases)
|
|
|
|
{
|
|
|
|
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>(c);
|
|
|
|
if (eclipseCase != nullptr)
|
|
|
|
{
|
|
|
|
exportSettings.caseToApply = eclipseCase;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2017-05-15 09:04:11 -05:00
|
|
|
|
|
|
|
exportSettings.fileName = QDir(defaultDir).filePath("Completions");
|
|
|
|
|
|
|
|
caf::PdmUiPropertyViewDialog propertyDialog(RiuMainWindow::instance(), &exportSettings, "Export Completion Data", "");
|
|
|
|
if (propertyDialog.exec() == QDialog::Accepted)
|
|
|
|
{
|
|
|
|
RiaApplication::instance()->setLastUsedDialogDirectory("COMPLETIONS", QFileInfo(exportSettings.fileName).absolutePath());
|
|
|
|
|
2017-05-29 08:52:35 -05:00
|
|
|
exportCompletions(wellPaths, exportSettings);
|
2017-05-15 09:04:11 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RicWellPathExportCompletionDataFeature::setupActionLook(QAction* actionToSetup)
|
|
|
|
{
|
|
|
|
actionToSetup->setText("Export Completion Data");
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-05-29 08:52:35 -05:00
|
|
|
std::vector<RimWellPath*> RicWellPathExportCompletionDataFeature::selectedWellPaths()
|
|
|
|
{
|
|
|
|
std::vector<RimWellPath*> wellPaths;
|
|
|
|
caf::SelectionManager::instance()->objectsByType(&wellPaths);
|
|
|
|
|
|
|
|
std::vector<RimWellPathCollection*> wellPathCollections;
|
|
|
|
caf::SelectionManager::instance()->objectsByType(&wellPathCollections);
|
|
|
|
|
|
|
|
for (auto wellPathCollection : wellPathCollections)
|
|
|
|
{
|
|
|
|
for (auto wellPath : wellPathCollection->wellPaths())
|
|
|
|
{
|
|
|
|
wellPaths.push_back(wellPath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
std::set<RimWellPath*> uniqueWellPaths(wellPaths.begin(), wellPaths.end());
|
|
|
|
wellPaths.assign(uniqueWellPaths.begin(), uniqueWellPaths.end());
|
|
|
|
return wellPaths;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-05-30 07:37:51 -05:00
|
|
|
void RicWellPathExportCompletionDataFeature::exportCompletions(const std::vector<RimWellPath*>& wellPaths, const RicExportCompletionDataSettingsUi& exportSettings)
|
2017-05-15 09:04:11 -05:00
|
|
|
{
|
2017-05-19 09:45:07 -05:00
|
|
|
QFile exportFile(exportSettings.fileName());
|
2017-05-16 02:43:41 -05:00
|
|
|
|
2017-05-19 09:45:07 -05:00
|
|
|
if (exportSettings.caseToApply() == nullptr)
|
2017-05-16 02:43:41 -05:00
|
|
|
{
|
|
|
|
RiaLogging::error("Export Completions Data: Cannot export completions data without specified eclipse case");
|
|
|
|
return;
|
|
|
|
}
|
2017-05-16 08:17:19 -05:00
|
|
|
|
2017-05-15 09:04:11 -05:00
|
|
|
if (!exportFile.open(QIODevice::WriteOnly))
|
|
|
|
{
|
2017-05-19 09:45:07 -05:00
|
|
|
RiaLogging::error(QString("Export Completions Data: Could not open the file: %1").arg(exportSettings.fileName()));
|
2017-05-15 09:04:11 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-05-29 08:52:35 -05:00
|
|
|
QTextStream stream(&exportFile);
|
2017-05-30 08:00:14 -05:00
|
|
|
RifEclipseDataTableFormatter formatter(stream);
|
2017-05-19 09:45:07 -05:00
|
|
|
|
2017-06-01 10:21:46 -05:00
|
|
|
std::map<IJKCellIndex, RigCompletionData> completionData;
|
|
|
|
|
2017-05-29 08:52:35 -05:00
|
|
|
for (auto wellPath : wellPaths)
|
2017-05-29 06:13:25 -05:00
|
|
|
{
|
2017-05-29 08:52:35 -05:00
|
|
|
// Generate completion data
|
2017-05-19 09:45:07 -05:00
|
|
|
|
2017-05-29 08:52:35 -05:00
|
|
|
if (exportSettings.includePerforations)
|
|
|
|
{
|
|
|
|
std::vector<RigCompletionData> perforationCompletionData = generatePerforationsCompdatValues(wellPath, exportSettings);
|
|
|
|
appendCompletionData(&completionData, perforationCompletionData);
|
|
|
|
}
|
|
|
|
if (exportSettings.includeFishbones)
|
|
|
|
{
|
|
|
|
std::vector<RigCompletionData> fishbonesCompletionData = generateFishbonesCompdatValues(wellPath, exportSettings);
|
|
|
|
appendCompletionData(&completionData, fishbonesCompletionData);
|
2017-05-30 02:26:45 -05:00
|
|
|
std::vector<RigCompletionData> fishbonesWellPathCompletionData = generateFishbonesWellPathCompdatValues(wellPath, exportSettings);
|
|
|
|
appendCompletionData(&completionData, fishbonesWellPathCompletionData);
|
2017-05-29 08:52:35 -05:00
|
|
|
}
|
2017-06-01 10:21:46 -05:00
|
|
|
}
|
2017-05-19 09:45:07 -05:00
|
|
|
|
2017-06-01 10:21:46 -05:00
|
|
|
// Merge map into a vector of values
|
|
|
|
std::vector<RigCompletionData> completions;
|
|
|
|
for (auto& data : completionData)
|
|
|
|
{
|
|
|
|
completions.push_back(data.second);
|
|
|
|
}
|
|
|
|
// Sort by well name / cell index
|
|
|
|
std::sort(completions.begin(), completions.end());
|
|
|
|
// Print completion data
|
|
|
|
generateCompdatTable(formatter, completions);
|
|
|
|
if (exportSettings.includeWpimult)
|
|
|
|
{
|
|
|
|
generateWpimultTable(formatter, completions);
|
2017-05-16 08:17:19 -05:00
|
|
|
}
|
2017-05-19 09:45:07 -05:00
|
|
|
}
|
2017-05-15 09:04:11 -05:00
|
|
|
|
2017-05-19 09:45:07 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-05-30 08:00:14 -05:00
|
|
|
void RicWellPathExportCompletionDataFeature::generateCompdatTable(RifEclipseDataTableFormatter& formatter, const std::vector<RigCompletionData>& completionData)
|
2017-05-19 09:45:07 -05:00
|
|
|
{
|
|
|
|
std::vector<RifEclipseOutputTableColumn> header = {
|
2017-05-29 06:13:25 -05:00
|
|
|
RifEclipseOutputTableColumn("Well"),
|
|
|
|
RifEclipseOutputTableColumn("I"),
|
|
|
|
RifEclipseOutputTableColumn("J"),
|
|
|
|
RifEclipseOutputTableColumn("K1"),
|
|
|
|
RifEclipseOutputTableColumn("K2"),
|
|
|
|
RifEclipseOutputTableColumn("Status"),
|
|
|
|
RifEclipseOutputTableColumn("SAT"),
|
|
|
|
RifEclipseOutputTableColumn("TR"),
|
|
|
|
RifEclipseOutputTableColumn("DIAM"),
|
|
|
|
RifEclipseOutputTableColumn("KH"),
|
|
|
|
RifEclipseOutputTableColumn("S"),
|
|
|
|
RifEclipseOutputTableColumn("Df"),
|
|
|
|
RifEclipseOutputTableColumn("DIR"),
|
|
|
|
RifEclipseOutputTableColumn("r0")
|
2017-05-19 09:45:07 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
formatter.keyword("COMPDAT");
|
|
|
|
formatter.header(header);
|
|
|
|
|
2017-05-29 06:13:25 -05:00
|
|
|
for (const RigCompletionData& data : completionData)
|
|
|
|
{
|
|
|
|
for (const RigCompletionMetaData& metadata : data.metadata())
|
|
|
|
{
|
|
|
|
formatter.comment(QString("%1 : %2").arg(metadata.name).arg(metadata.comment));
|
|
|
|
}
|
|
|
|
formatter.add(data.wellName());
|
|
|
|
formatter.addZeroBasedCellIndex(data.cellIndex().i).addZeroBasedCellIndex(data.cellIndex().j).addZeroBasedCellIndex(data.cellIndex().k).addZeroBasedCellIndex(data.cellIndex().k);
|
|
|
|
switch (data.connectionState())
|
|
|
|
{
|
|
|
|
case OPEN:
|
|
|
|
formatter.add("OPEN");
|
|
|
|
break;
|
|
|
|
case SHUT:
|
|
|
|
formatter.add("SHUT");
|
|
|
|
break;
|
|
|
|
case AUTO:
|
|
|
|
formatter.add("AUTO");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (RigCompletionData::isDefaultValue(data.saturation())) formatter.add("1*"); else formatter.add(data.saturation());
|
|
|
|
if (RigCompletionData::isDefaultValue(data.transmissibility()))
|
|
|
|
{
|
|
|
|
formatter.add("1*"); // Transmissibility
|
|
|
|
|
|
|
|
if (RigCompletionData::isDefaultValue(data.diameter())) formatter.add("1*"); else formatter.add(data.diameter());
|
|
|
|
if (RigCompletionData::isDefaultValue(data.kh())) formatter.add("1*"); else formatter.add(data.kh());
|
|
|
|
if (RigCompletionData::isDefaultValue(data.skinFactor())) formatter.add("1*"); else formatter.add(data.skinFactor());
|
|
|
|
if (RigCompletionData::isDefaultValue(data.dFactor())) formatter.add("1*"); else formatter.add(data.dFactor());
|
|
|
|
|
|
|
|
switch (data.direction())
|
|
|
|
{
|
|
|
|
case DIR_I:
|
|
|
|
formatter.add("'X'");
|
|
|
|
break;
|
|
|
|
case DIR_J:
|
|
|
|
formatter.add("'Y'");
|
|
|
|
break;
|
|
|
|
case DIR_K:
|
|
|
|
formatter.add("'Z'");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
formatter.add("'Z'");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
formatter.add(data.transmissibility());
|
|
|
|
}
|
|
|
|
|
|
|
|
formatter.rowCompleted();
|
|
|
|
}
|
|
|
|
formatter.tableCompleted();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-05-30 08:00:14 -05:00
|
|
|
void RicWellPathExportCompletionDataFeature::generateWpimultTable(RifEclipseDataTableFormatter& formatter, const std::vector<RigCompletionData>& completionData)
|
2017-05-29 06:13:25 -05:00
|
|
|
{
|
|
|
|
std::vector<RifEclipseOutputTableColumn> header = {
|
|
|
|
RifEclipseOutputTableColumn("Well"),
|
|
|
|
RifEclipseOutputTableColumn("Mult"),
|
|
|
|
RifEclipseOutputTableColumn("I"),
|
|
|
|
RifEclipseOutputTableColumn("J"),
|
|
|
|
RifEclipseOutputTableColumn("K"),
|
|
|
|
};
|
|
|
|
formatter.keyword("WPIMULT");
|
|
|
|
formatter.header(header);
|
|
|
|
|
|
|
|
for (auto& completion : completionData)
|
|
|
|
{
|
|
|
|
formatter.add(completion.wellName());
|
|
|
|
formatter.add(completion.count());
|
|
|
|
formatter.addZeroBasedCellIndex(completion.cellIndex().i).addZeroBasedCellIndex(completion.cellIndex().j).addZeroBasedCellIndex(completion.cellIndex().k);
|
|
|
|
formatter.rowCompleted();
|
|
|
|
}
|
|
|
|
|
|
|
|
formatter.tableCompleted();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-05-30 07:37:51 -05:00
|
|
|
std::vector<RigCompletionData> RicWellPathExportCompletionDataFeature::generateFishbonesCompdatValues(const RimWellPath* wellPath, const RicExportCompletionDataSettingsUi& settings)
|
2017-05-29 06:13:25 -05:00
|
|
|
{
|
|
|
|
// Generate data
|
|
|
|
const RigEclipseCaseData* caseData = settings.caseToApply()->eclipseCaseData();
|
|
|
|
std::vector<WellSegmentLocation> locations = findWellSegmentLocations(settings.caseToApply, wellPath);
|
|
|
|
|
|
|
|
// Filter out cells where main bore is present
|
|
|
|
if (settings.removeLateralsInMainBoreCells())
|
|
|
|
{
|
|
|
|
std::vector<size_t> wellPathCells = findIntersectingCells(caseData, wellPath->wellPathGeometry()->m_wellPathPoints);
|
|
|
|
markWellPathCells(wellPathCells, &locations);
|
|
|
|
}
|
|
|
|
|
|
|
|
RigMainGrid* grid = settings.caseToApply->eclipseCaseData()->mainGrid();
|
|
|
|
|
|
|
|
std::vector<RigCompletionData> completionData;
|
|
|
|
|
2017-05-19 09:45:07 -05:00
|
|
|
for (const WellSegmentLocation& location : locations)
|
|
|
|
{
|
|
|
|
for (const WellSegmentLateral& lateral : location.laterals)
|
|
|
|
{
|
|
|
|
for (const WellSegmentLateralIntersection& intersection : lateral.intersections)
|
|
|
|
{
|
2017-05-29 06:13:25 -05:00
|
|
|
if (intersection.mainBoreCell && settings.removeLateralsInMainBoreCells()) continue;
|
2017-05-19 09:45:07 -05:00
|
|
|
|
2017-05-22 06:23:48 -05:00
|
|
|
size_t i, j, k;
|
|
|
|
grid->ijkFromCellIndex(intersection.cellIndex, &i, &j, &k);
|
2017-05-29 06:13:25 -05:00
|
|
|
RigCompletionData completion(wellPath->name(), IJKCellIndex(i, j, k));
|
|
|
|
completion.addMetadata(location.fishbonesSubs->name(), QString("Sub: %1 Lateral: %2").arg(location.subIndex).arg(lateral.lateralIndex));
|
2017-05-30 02:49:58 -05:00
|
|
|
double diameter = location.fishbonesSubs->holeDiameter() / 1000;
|
2017-05-30 02:31:37 -05:00
|
|
|
CellDirection direction = wellPathCellDirectionToCellDirection(intersection.direction);
|
2017-05-30 02:26:45 -05:00
|
|
|
completion.setFromFishbone(diameter, direction);
|
2017-05-29 06:13:25 -05:00
|
|
|
completionData.push_back(completion);
|
2017-05-19 09:45:07 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-29 06:13:25 -05:00
|
|
|
return completionData;
|
2017-05-19 09:45:07 -05:00
|
|
|
}
|
|
|
|
|
2017-05-30 02:26:45 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-05-30 07:37:51 -05:00
|
|
|
std::vector<RigCompletionData> RicWellPathExportCompletionDataFeature::generateFishbonesWellPathCompdatValues(const RimWellPath* wellPath, const RicExportCompletionDataSettingsUi & settings)
|
2017-05-30 02:26:45 -05:00
|
|
|
{
|
|
|
|
std::vector<RigCompletionData> completionData;
|
|
|
|
|
2017-05-30 02:49:58 -05:00
|
|
|
double diameter = wellPath->fishbonesCollection()->wellPathCollection()->holeDiameter() / 1000;
|
2017-05-30 02:26:45 -05:00
|
|
|
for (const RimFishboneWellPath* fishbonesPath : wellPath->fishbonesCollection()->wellPathCollection()->wellPaths())
|
|
|
|
{
|
|
|
|
std::vector<WellPathCellIntersectionInfo> intersectedCells = RigWellPathIntersectionTools::findCellsIntersectedByPath(settings.caseToApply->eclipseCaseData(), fishbonesPath->coordinates());
|
|
|
|
for (auto& cell : intersectedCells)
|
|
|
|
{
|
|
|
|
size_t i, j, k;
|
|
|
|
settings.caseToApply->eclipseCaseData()->mainGrid()->ijkFromCellIndex(cell.cellIndex, &i, &j, &k);
|
|
|
|
RigCompletionData completion(wellPath->name(), IJKCellIndex(i, j, k));
|
|
|
|
completion.addMetadata(fishbonesPath->name(), "");
|
|
|
|
CellDirection direction = wellPathCellDirectionToCellDirection(cell.direction);
|
|
|
|
completion.setFromFishbone(diameter, direction);
|
|
|
|
completionData.push_back(completion);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return completionData;
|
|
|
|
}
|
|
|
|
|
2017-05-19 09:45:07 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-05-30 07:37:51 -05:00
|
|
|
std::vector<RigCompletionData> RicWellPathExportCompletionDataFeature::generatePerforationsCompdatValues(const RimWellPath* wellPath, const RicExportCompletionDataSettingsUi& settings)
|
2017-05-19 09:45:07 -05:00
|
|
|
{
|
2017-05-29 06:13:25 -05:00
|
|
|
std::vector<RigCompletionData> completionData;
|
2017-05-19 09:45:07 -05:00
|
|
|
|
2017-05-29 06:13:25 -05:00
|
|
|
for (const RimPerforationInterval* interval : wellPath->perforationIntervalCollection()->perforations())
|
2017-05-19 09:45:07 -05:00
|
|
|
{
|
2017-05-30 08:42:05 -05:00
|
|
|
if (!interval->isActiveOnDate(settings.caseToApply->timeStepDates()[settings.timeStep])) continue;
|
|
|
|
|
2017-05-29 06:13:25 -05:00
|
|
|
std::vector<cvf::Vec3d> perforationPoints = wellPath->wellPathGeometry()->clippedPointSubset(interval->startMD(), interval->endMD());
|
|
|
|
std::vector<WellPathCellIntersectionInfo> intersectedCells = RigWellPathIntersectionTools::findCellsIntersectedByPath(settings.caseToApply->eclipseCaseData(), perforationPoints);
|
|
|
|
for (auto& cell : intersectedCells)
|
|
|
|
{
|
|
|
|
size_t i, j, k;
|
|
|
|
settings.caseToApply->eclipseCaseData()->mainGrid()->ijkFromCellIndex(cell.cellIndex, &i, &j, &k);
|
|
|
|
RigCompletionData completion(wellPath->name(), IJKCellIndex(i, j, k));
|
|
|
|
completion.addMetadata("Perforation", QString("StartMD: %1 - EndMD: %2").arg(interval->startMD()).arg(interval->endMD()));
|
2017-05-30 02:49:58 -05:00
|
|
|
double diameter = interval->diameter();
|
2017-05-30 02:26:45 -05:00
|
|
|
CellDirection direction = wellPathCellDirectionToCellDirection(cell.direction);
|
|
|
|
completion.setFromPerforation(diameter, direction);
|
2017-05-29 06:13:25 -05:00
|
|
|
completionData.push_back(completion);
|
|
|
|
}
|
2017-05-19 09:45:07 -05:00
|
|
|
}
|
|
|
|
|
2017-05-29 06:13:25 -05:00
|
|
|
return completionData;
|
2017-05-19 09:45:07 -05:00
|
|
|
}
|
|
|
|
|
2017-05-15 09:04:11 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
std::vector<size_t> RicWellPathExportCompletionDataFeature::findIntersectingCells(const RigEclipseCaseData* caseData, const std::vector<cvf::Vec3d>& coords)
|
|
|
|
{
|
2017-05-16 07:50:54 -05:00
|
|
|
std::set<size_t> cells;
|
2017-05-15 09:04:11 -05:00
|
|
|
|
2017-05-29 06:13:25 -05:00
|
|
|
std::vector<HexIntersectionInfo> intersections = RigWellPathIntersectionTools::getIntersectedCells(caseData->mainGrid(), coords);
|
2017-05-19 04:28:02 -05:00
|
|
|
for (auto intersection : intersections)
|
|
|
|
{
|
|
|
|
cells.insert(intersection.m_hexIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Ensure only unique cells are included
|
|
|
|
std::vector<size_t> cellsVector;
|
|
|
|
cellsVector.assign(cells.begin(), cells.end());
|
|
|
|
// Sort cells
|
|
|
|
std::sort(cellsVector.begin(), cellsVector.end());
|
|
|
|
return cellsVector;
|
|
|
|
}
|
|
|
|
|
2017-05-15 09:04:11 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-05-16 07:50:54 -05:00
|
|
|
///
|
2017-05-15 09:04:11 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-05-19 09:45:07 -05:00
|
|
|
void RicWellPathExportCompletionDataFeature::markWellPathCells(const std::vector<size_t>& wellPathCells, std::vector<WellSegmentLocation>* locations)
|
2017-05-15 09:04:11 -05:00
|
|
|
{
|
2017-05-19 09:45:07 -05:00
|
|
|
std::set<size_t> wellPathCellSet(wellPathCells.begin(), wellPathCells.end());
|
|
|
|
for (WellSegmentLocation& location : *locations)
|
2017-05-16 02:43:41 -05:00
|
|
|
{
|
2017-05-19 09:45:07 -05:00
|
|
|
for (WellSegmentLateral& lateral : location.laterals)
|
2017-05-16 02:43:41 -05:00
|
|
|
{
|
2017-05-19 09:45:07 -05:00
|
|
|
for (WellSegmentLateralIntersection& intersection : lateral.intersections)
|
|
|
|
{
|
|
|
|
if (wellPathCellSet.find(intersection.cellIndex) != wellPathCellSet.end())
|
|
|
|
{
|
|
|
|
intersection.mainBoreCell = true;
|
|
|
|
}
|
|
|
|
}
|
2017-05-16 02:43:41 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-05-19 04:28:02 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RicWellPathExportCompletionDataFeature::wellSegmentLocationOrdering(const WellSegmentLocation& first, const WellSegmentLocation& second)
|
|
|
|
{
|
|
|
|
return first.measuredDepth < second.measuredDepth;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RicWellPathExportCompletionDataFeature::isPointBetween(const cvf::Vec3d& pointA, const cvf::Vec3d& pointB, const cvf::Vec3d& needle)
|
|
|
|
{
|
|
|
|
cvf::Plane plane;
|
|
|
|
plane.setFromPointAndNormal(needle, pointB - pointA);
|
|
|
|
return plane.side(pointA) != plane.side(pointB);
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-05-29 06:13:25 -05:00
|
|
|
std::vector<WellSegmentLocation> RicWellPathExportCompletionDataFeature::findWellSegmentLocations(const RimEclipseCase* caseToApply, const RimWellPath* wellPath)
|
2017-05-19 04:28:02 -05:00
|
|
|
{
|
2017-05-29 08:39:37 -05:00
|
|
|
std::vector<RimFishbonesMultipleSubs*> fishbonesSubs;
|
2017-05-19 08:44:32 -05:00
|
|
|
for (RimFishbonesMultipleSubs* subs : wellPath->fishbonesCollection()->fishbonesSubs())
|
2017-05-29 08:39:37 -05:00
|
|
|
{
|
|
|
|
fishbonesSubs.push_back(subs);
|
|
|
|
}
|
|
|
|
return findWellSegmentLocations(caseToApply, wellPath, fishbonesSubs);
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
std::vector<WellSegmentLocation> RicWellPathExportCompletionDataFeature::findWellSegmentLocations(const RimEclipseCase* caseToApply, const RimWellPath* wellPath, const std::vector<RimFishbonesMultipleSubs*>& fishbonesSubs)
|
|
|
|
{
|
|
|
|
std::vector<WellSegmentLocation> wellSegmentLocations;
|
|
|
|
for (RimFishbonesMultipleSubs* subs : fishbonesSubs)
|
2017-05-19 04:28:02 -05:00
|
|
|
{
|
2017-06-02 03:16:16 -05:00
|
|
|
for (auto& sub : subs->installedLateralIndices())
|
2017-05-19 04:28:02 -05:00
|
|
|
{
|
2017-06-02 03:16:16 -05:00
|
|
|
double measuredDepth = subs->measuredDepth(sub.subIndex);
|
2017-05-19 04:28:02 -05:00
|
|
|
cvf::Vec3d position = wellPath->wellPathGeometry()->interpolatedPointAlongWellPath(measuredDepth);
|
2017-06-02 03:16:16 -05:00
|
|
|
WellSegmentLocation location = WellSegmentLocation(subs, measuredDepth, -position.z(), sub.subIndex);
|
|
|
|
for (size_t lateralIndex : sub.lateralIndices)
|
2017-05-19 04:28:02 -05:00
|
|
|
{
|
|
|
|
location.laterals.push_back(WellSegmentLateral(lateralIndex));
|
|
|
|
}
|
|
|
|
wellSegmentLocations.push_back(location);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
std::sort(wellSegmentLocations.begin(), wellSegmentLocations.end(), wellSegmentLocationOrdering);
|
|
|
|
|
2017-05-19 09:45:07 -05:00
|
|
|
assignBranchAndSegmentNumbers(caseToApply, &wellSegmentLocations);
|
|
|
|
|
2017-05-19 04:28:02 -05:00
|
|
|
return wellSegmentLocations;
|
|
|
|
}
|
|
|
|
|
2017-05-19 09:45:07 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RicWellPathExportCompletionDataFeature::calculateLateralIntersections(const RimEclipseCase* caseToApply, WellSegmentLocation* location, int* branchNum, int* segmentNum)
|
|
|
|
{
|
|
|
|
for (WellSegmentLateral& lateral : location->laterals)
|
|
|
|
{
|
|
|
|
lateral.branchNumber = ++(*branchNum);
|
|
|
|
std::vector<cvf::Vec3d> coords = location->fishbonesSubs->coordsForLateral(location->subIndex, lateral.lateralIndex);
|
2017-05-29 06:13:25 -05:00
|
|
|
std::vector<WellPathCellIntersectionInfo> intersections = RigWellPathIntersectionTools::findCellsIntersectedByPath(caseToApply->eclipseCaseData(), coords);
|
2017-05-19 09:45:07 -05:00
|
|
|
|
2017-05-29 06:13:25 -05:00
|
|
|
auto intersection = intersections.cbegin();
|
|
|
|
double length = 0;
|
|
|
|
double depth = 0;
|
|
|
|
cvf::Vec3d startPoint = coords[0];
|
2017-06-02 05:50:16 -05:00
|
|
|
int attachedSegmentNumber = location->icdSegmentNumber;
|
2017-05-19 09:45:07 -05:00
|
|
|
|
2017-05-29 06:13:25 -05:00
|
|
|
for (size_t i = 1; i < coords.size() && intersection != intersections.cend(); ++i)
|
2017-05-19 09:45:07 -05:00
|
|
|
{
|
2017-05-29 06:13:25 -05:00
|
|
|
if (isPointBetween(startPoint, coords[i], intersection->endPoint))
|
2017-05-19 09:45:07 -05:00
|
|
|
{
|
2017-05-29 06:13:25 -05:00
|
|
|
length += (intersection->endPoint - startPoint).length();
|
|
|
|
depth += intersection->endPoint.z() - startPoint.z();
|
|
|
|
|
|
|
|
WellSegmentLateralIntersection lateralIntersection(++(*segmentNum), attachedSegmentNumber, intersection->cellIndex, length, depth);
|
|
|
|
lateralIntersection.direction = intersection->direction;
|
|
|
|
lateral.intersections.push_back(lateralIntersection);
|
|
|
|
|
|
|
|
length = 0;
|
|
|
|
depth = 0;
|
2017-06-02 04:43:03 -05:00
|
|
|
startPoint = intersection->endPoint;
|
2017-05-29 06:13:25 -05:00
|
|
|
attachedSegmentNumber = *segmentNum;
|
|
|
|
++intersection;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
length += (coords[i] - startPoint).length();
|
|
|
|
depth += coords[i].z() - startPoint.z();
|
|
|
|
startPoint = coords[i];
|
2017-05-19 09:45:07 -05:00
|
|
|
}
|
2017-05-22 06:23:48 -05:00
|
|
|
}
|
2017-05-19 09:45:07 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RicWellPathExportCompletionDataFeature::assignBranchAndSegmentNumbers(const RimEclipseCase* caseToApply, std::vector<WellSegmentLocation>* locations)
|
|
|
|
{
|
|
|
|
int segmentNumber = 1;
|
|
|
|
int branchNumber = 1;
|
|
|
|
// First loop over the locations so that each segment on the main stem is an incremental number
|
|
|
|
for (WellSegmentLocation& location : *locations)
|
|
|
|
{
|
|
|
|
location.segmentNumber = ++segmentNumber;
|
2017-06-02 05:50:16 -05:00
|
|
|
location.icdBranchNumber = ++branchNumber;
|
|
|
|
location.icdSegmentNumber = ++segmentNumber;
|
2017-05-19 09:45:07 -05:00
|
|
|
}
|
|
|
|
// Then assign branch and segment numbers to each lateral parts
|
|
|
|
for (WellSegmentLocation& location : *locations)
|
|
|
|
{
|
|
|
|
calculateLateralIntersections(caseToApply, &location, &branchNumber, &segmentNumber);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-22 06:23:48 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-05-29 06:13:25 -05:00
|
|
|
void RicWellPathExportCompletionDataFeature::appendCompletionData(std::map<IJKCellIndex, RigCompletionData>* completionData, const std::vector<RigCompletionData>& data)
|
2017-05-22 06:23:48 -05:00
|
|
|
{
|
2017-05-29 06:13:25 -05:00
|
|
|
for (auto& completion : data)
|
2017-05-22 06:23:48 -05:00
|
|
|
{
|
2017-05-29 06:13:25 -05:00
|
|
|
auto it = completionData->find(completion.cellIndex());
|
|
|
|
if (it != completionData->end())
|
2017-05-22 06:23:48 -05:00
|
|
|
{
|
2017-05-30 07:12:51 -05:00
|
|
|
it->second = RigCompletionData::combine(it->second, completion);
|
2017-05-22 06:23:48 -05:00
|
|
|
}
|
2017-05-29 06:13:25 -05:00
|
|
|
else
|
2017-05-22 06:23:48 -05:00
|
|
|
{
|
2017-05-29 06:13:25 -05:00
|
|
|
completionData->insert(std::pair<IJKCellIndex, RigCompletionData>(completion.cellIndex(), completion));
|
2017-05-22 06:23:48 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-05-30 02:26:45 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
CellDirection RicWellPathExportCompletionDataFeature::wellPathCellDirectionToCellDirection(WellPathCellDirection direction)
|
|
|
|
{
|
|
|
|
switch (direction)
|
|
|
|
{
|
|
|
|
case POS_I:
|
|
|
|
case NEG_I:
|
2017-05-30 02:31:37 -05:00
|
|
|
return CellDirection::DIR_I;
|
2017-05-30 02:26:45 -05:00
|
|
|
case POS_J:
|
|
|
|
case NEG_J:
|
2017-05-30 02:31:37 -05:00
|
|
|
return CellDirection::DIR_J;
|
2017-05-30 02:26:45 -05:00
|
|
|
case POS_K:
|
|
|
|
case NEG_K:
|
2017-05-30 02:31:37 -05:00
|
|
|
return CellDirection::DIR_K;
|
2017-05-30 02:26:45 -05:00
|
|
|
default:
|
2017-05-30 02:31:37 -05:00
|
|
|
return CellDirection::DIR_UNDEF;
|
2017-05-30 02:26:45 -05:00
|
|
|
}
|
|
|
|
}
|