From f6572e876ded81ac670f5c86998fee229171d6ba Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 26 Nov 2018 12:46:32 +0100 Subject: [PATCH] #3704 : Export completions : WELSPECL - one line per well --- ...ellPathExportCompletionDataFeatureImpl.cpp | 66 +++++++++++-------- ...cWellPathExportCompletionDataFeatureImpl.h | 5 +- 2 files changed, 43 insertions(+), 28 deletions(-) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp index d487e3bfb2..c6d26579f7 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp @@ -1260,7 +1260,7 @@ void RicWellPathExportCompletionDataFeatureImpl::exportWelspecsToFile(RimEclipse std::set wellPathSet; // Build list of unique RimWellPath - for (const auto completion : completions) + for (const auto& completion : completions) { const auto wellPath = findWellPathFromExportName(completion.wellName()); if (wellPath) @@ -1272,13 +1272,13 @@ void RicWellPathExportCompletionDataFeatureImpl::exportWelspecsToFile(RimEclipse // Export for (const auto wellPath : wellPathSet) { - auto rimCcompletions = wellPath->completions(); - cvf::Vec2i ijIntersection = wellPathUpperGridIntersectionIJ(gridCase, wellPath); + auto rimCcompletions = wellPath->completions(); + auto ijIntersection = wellPathUpperGridIntersectionIJ(gridCase, wellPath); formatter.add(rimCcompletions->wellNameForExport()) .add(rimCcompletions->wellGroupNameForExport()) - .addOneBasedCellIndex(ijIntersection.x()) - .addOneBasedCellIndex(ijIntersection.y()) + .addOneBasedCellIndex(ijIntersection.second.x()) + .addOneBasedCellIndex(ijIntersection.second.y()) .add(rimCcompletions->referenceDepthForExport()) .add(rimCcompletions->wellTypeNameForExport()) .rowCompleted(); @@ -1311,32 +1311,44 @@ void RicWellPathExportCompletionDataFeatureImpl::exportWelspeclToFile( formatter.keyword("WELSPECL"); formatter.header(header); - std::map> wellPathMap; + std::map> wellPathToLgrNameMap; - // Build list of unique RimWellPath for each LGR - for (const auto completionsForLgr : completions) + for (const auto& completionsForLgr : completions) { - wellPathMap.insert(std::make_pair(completionsForLgr.first, std::set())); - - for (const auto completion : completionsForLgr.second) + for (const auto& completion : completionsForLgr.second) { const auto wellPath = findWellPathFromExportName(completion.wellName()); - if (wellPath) - { - wellPathMap[completionsForLgr.first].insert(wellPath); - } + auto item = wellPathToLgrNameMap.find(wellPath); + wellPathToLgrNameMap[wellPath].insert(completionsForLgr.first); } } - for (const auto wellPathsForLgr : wellPathMap) + for (const auto& wellPathsForLgr : wellPathToLgrNameMap) { - QString lgrName = wellPathsForLgr.first; + const RimWellPath* wellPath = wellPathsForLgr.first; - // Export - for (const auto wellPath : wellPathsForLgr.second) + std::tuple itemWithLowestMD = + std::make_tuple(std::numeric_limits::max(), cvf::Vec2i(), ""); + + // Find first LGR-intersection along the well path + + for (const auto& lgrName : wellPathsForLgr.second) { - auto rimCompletions = wellPath->completions(); - cvf::Vec2i ijIntersection = wellPathUpperGridIntersectionIJ(gridCase, wellPath, lgrName); + auto ijIntersection = wellPathUpperGridIntersectionIJ(gridCase, wellPath, lgrName); + if (ijIntersection.first < std::get<0>(itemWithLowestMD)) + { + itemWithLowestMD = std::make_tuple(ijIntersection.first, ijIntersection.second, lgrName); + } + } + + { + double measuredDepth = 0.0; + cvf::Vec2i ijIntersection; + QString lgrName; + + std::tie(measuredDepth, ijIntersection, lgrName) = itemWithLowestMD; + + auto rimCompletions = wellPath->completions(); formatter.add(rimCompletions->wellNameForExport()) .add(rimCompletions->wellGroupNameForExport()) @@ -1348,7 +1360,6 @@ void RicWellPathExportCompletionDataFeatureImpl::exportWelspeclToFile( .rowCompleted(); } } - formatter.tableCompleted(); } @@ -2529,9 +2540,10 @@ double RicWellPathExportCompletionDataFeatureImpl::calculateTransmissibilityAsEc //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::Vec2i RicWellPathExportCompletionDataFeatureImpl::wellPathUpperGridIntersectionIJ(const RimEclipseCase* gridCase, - const RimWellPath* wellPath, - const QString& gridName) +std::pair + RicWellPathExportCompletionDataFeatureImpl::wellPathUpperGridIntersectionIJ(const RimEclipseCase* gridCase, + const RimWellPath* wellPath, + const QString& gridName) { const RigEclipseCaseData* caseData = gridCase->eclipseCaseData(); const RigMainGrid* mainGrid = caseData->mainGrid(); @@ -2562,11 +2574,11 @@ cvf::Vec2i RicWellPathExportCompletionDataFeatureImpl::wellPathUpperGridIntersec size_t i, j, k; if (grid->ijkFromCellIndex(gridLocalCellIndex, &i, &j, &k)) { - return cvf::Vec2i((int)i, (int)j); + return std::make_pair(intersection.startMD, cvf::Vec2i((int)i, (int)j)); } } } - return cvf::Vec2i(); + return std::make_pair(cvf::UNDEFINED_DOUBLE, cvf::Vec2i()); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h index 16e8d96df6..176fdb70c4 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h @@ -28,6 +28,7 @@ #include "cvfBase.h" #include "cvfVector3.h" +#include "cvfVector2.h" #include #include @@ -268,7 +269,9 @@ private: static void appendCompletionData(std::map>* completionData, const std::vector& data); - static cvf::Vec2i wellPathUpperGridIntersectionIJ(const RimEclipseCase* gridCase, const RimWellPath* wellPath, const QString& gridName = ""); + static std::pair wellPathUpperGridIntersectionIJ(const RimEclipseCase* gridCase, + const RimWellPath* wellPath, + const QString& gridName = ""); static void exportWellSegments(RimEclipseCase* eclipseCase, QFilePtr exportFile,