From 6391fad0187e0cbde6a192c8ca1467d253189e14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rnar=20Grip=20Fj=C3=A6r?= Date: Mon, 12 Jun 2017 12:03:42 +0200 Subject: [PATCH] #1559 Use common export completions command for well paths and simulation wells --- .../RicExportCompletionDataSettingsUi.cpp | 38 ++++++++ .../RicExportCompletionDataSettingsUi.h | 9 +- .../RicExportFractureCompletionsImpl.cpp | 82 ++++++++++++++--- .../RicExportFractureCompletionsImpl.h | 22 ++++- ...RicWellPathExportCompletionDataFeature.cpp | 90 +++++++++++++++++-- .../RicWellPathExportCompletionDataFeature.h | 4 +- .../Completions/RimSimWellFracture.h | 1 + .../ProjectDataModel/RimEclipseWell.cpp | 2 +- .../ProjectDataModel/RimEclipseWell.h | 2 +- .../RigSimulationWellCenterLineCalculator.cpp | 4 +- .../RigSimulationWellCenterLineCalculator.h | 2 +- 11 files changed, 230 insertions(+), 26 deletions(-) diff --git a/ApplicationCode/Commands/CompletionCommands/RicExportCompletionDataSettingsUi.cpp b/ApplicationCode/Commands/CompletionCommands/RicExportCompletionDataSettingsUi.cpp index abf2d3a72b..e7b71b4484 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicExportCompletionDataSettingsUi.cpp +++ b/ApplicationCode/Commands/CompletionCommands/RicExportCompletionDataSettingsUi.cpp @@ -40,6 +40,22 @@ RicExportCompletionDataSettingsUi::RicExportCompletionDataSettingsUi() } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicExportCompletionDataSettingsUi::showForSimWells() +{ + m_displayForSimWell = true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicExportCompletionDataSettingsUi::showForWellPath() +{ + m_displayForSimWell = false; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -66,3 +82,25 @@ QList RicExportCompletionDataSettingsUi::calculateValueO } return options; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicExportCompletionDataSettingsUi::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) +{ + uiOrdering.add(&fileName); + uiOrdering.add(&caseToApply); + uiOrdering.add(&timeStep); + uiOrdering.add(&computeTransmissibility); + uiOrdering.add(&includeWpimult); + + if (!m_displayForSimWell) + { + uiOrdering.add(&includePerforations); + uiOrdering.add(&includeFishbones); + uiOrdering.add(&includeFractures); + uiOrdering.add(&removeLateralsInMainBoreCells); + } + + uiOrdering.skipRemainingFields(); +} diff --git a/ApplicationCode/Commands/CompletionCommands/RicExportCompletionDataSettingsUi.h b/ApplicationCode/Commands/CompletionCommands/RicExportCompletionDataSettingsUi.h index 023b157099..cc12574d8f 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicExportCompletionDataSettingsUi.h +++ b/ApplicationCode/Commands/CompletionCommands/RicExportCompletionDataSettingsUi.h @@ -43,6 +43,13 @@ public: caf::PdmField timeStep; + void showForSimWells(); + void showForWellPath(); + protected: - virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override; + virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override; + virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; + +private: + bool m_displayForSimWell; }; diff --git a/ApplicationCode/Commands/CompletionCommands/RicExportFractureCompletionsImpl.cpp b/ApplicationCode/Commands/CompletionCommands/RicExportFractureCompletionsImpl.cpp index f02d8350b8..38a28b9a51 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicExportFractureCompletionsImpl.cpp +++ b/ApplicationCode/Commands/CompletionCommands/RicExportFractureCompletionsImpl.cpp @@ -18,33 +18,96 @@ #include "RicExportFractureCompletionsImpl.h" -#include -#include "RimEclipseCase.h" #include "RicExportCompletionDataSettingsUi.h" + +#include "RimEclipseCase.h" #include "RimFracture.h" #include "RimWellPath.h" +#include "RimFractureTemplate.h" +#include "RimEclipseWell.h" +#include "RimSimWellFractureCollection.h" +#include "RimSimWellFracture.h" + #include "RigEclipseCaseData.h" #include "RigTransmissibilityCondenser.h" #include "RigFractureCell.h" #include "RigFractureGrid.h" -#include "RimFractureTemplate.h" #include "RigEclipseToStimPlanCellTransmissibilityCalculator.h" #include "RigFractureTransmissibilityEquations.h" #include "RigWellPathStimplanIntersector.h" #include "RigMainGrid.h" +#include "RigSingleWellResultsData.h" +#include "RigSimulationWellCoordsAndMD.h" +#include "RigWellPath.h" + +#include //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RicExportFractureCompletionsImpl::generateFracturesCompdatValues(const RimWellPath* wellPath, - const RicExportCompletionDataSettingsUi& settings, - QTextStream* outputStreamForIntermediateResultsText) +std::vector RicExportFractureCompletionsImpl::generateCompdatValuesForWellPath(const RimWellPath* wellPath, + const RicExportCompletionDataSettingsUi& settings, + QTextStream* outputStreamForIntermediateResultsText) { const RimEclipseCase* caseToApply = settings.caseToApply(); std::vector fracturesAlongWellPath; wellPath->descendantsIncludingThisOfType(fracturesAlongWellPath); + return generateCompdatValues(caseToApply, + wellPath->name(), + wellPath->wellPathGeometry(), + fracturesAlongWellPath, + outputStreamForIntermediateResultsText); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RicExportFractureCompletionsImpl::generateCompdatValuesForSimWell(const RimEclipseCase* eclipseCase, + const RimEclipseWell* well, + size_t timeStep, + QTextStream* outputStreamForIntermediateResultsText) +{ + std::vector completionData; + + std::vector< std::vector > pipeBranchesCLCoords; + std::vector< std::vector > pipeBranchesCellIds; + well->calculateWellPipeDynamicCenterLine(timeStep, pipeBranchesCLCoords, pipeBranchesCellIds); + + for (size_t branchIndex = 0; branchIndex < pipeBranchesCLCoords.size(); ++branchIndex) + { + RigSimulationWellCoordsAndMD coordsAndMD(pipeBranchesCLCoords[branchIndex]); + RigWellPath wellPathGeometry; + wellPathGeometry.m_wellPathPoints = coordsAndMD.wellPathPoints(); + wellPathGeometry.m_measuredDepths = coordsAndMD.measuredDepths(); + + std::vector fractures; + for (RimSimWellFracture* fracture : well->simwellFractureCollection->simwellFractures()) + { + if (static_cast(fracture->branchIndex()) == branchIndex) + { + fractures.push_back(fracture); + } + } + + std::vector branchCompletions = generateCompdatValues(eclipseCase, well->name(), &wellPathGeometry, fractures, outputStreamForIntermediateResultsText); + + completionData.insert(completionData.end(), branchCompletions.begin(), branchCompletions.end()); + } + + return completionData; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RicExportFractureCompletionsImpl::generateCompdatValues(const RimEclipseCase* caseToApply, + const QString& wellPathName, + const RigWellPath* wellPathGeometry, + const std::vector fractures, + QTextStream* outputStreamForIntermediateResultsText) +{ double cDarcyInCorrectUnit = caseToApply->eclipseCaseData()->darchysValue(); const RigMainGrid* mainGrid = caseToApply->eclipseCaseData()->mainGrid(); @@ -54,7 +117,7 @@ std::vector RicExportFractureCompletionsImpl::generateFractur std::map > eclCellIdxToTransPrFractureMap; std::vector fractureCompletions; - for (RimFracture* fracture : fracturesAlongWellPath) + for (RimFracture* fracture : fractures) { bool fractureFiniteCond = (fracture->fractureTemplate()->conductivityType() == RimFractureTemplate::FINITE_CONDUCTIVITY); @@ -193,7 +256,7 @@ std::vector RicExportFractureCompletionsImpl::generateFractur //If fracture has orientation along well, linear inflow along well and radial flow at endpoints else if (fracture->fractureTemplate()->orientationType() == RimFractureTemplate::ALONG_WELL_PATH) { - RigWellPathStimplanIntersector wellFractureIntersector(wellPath->wellPathGeometry(), fracture); + RigWellPathStimplanIntersector wellFractureIntersector(wellPathGeometry, fracture); const std::map& fractureWellCells = wellFractureIntersector.intersections(); for (const auto& fracCellIdxIsectDataPair : fractureWellCells) @@ -250,7 +313,7 @@ std::vector RicExportFractureCompletionsImpl::generateFractur size_t i, j, k; mainGrid->ijkFromCellIndex(externalCell.m_globalCellIdx, &i, &j, &k); - RigCompletionData compDat(wellPath->name(), {i,j,k} ); + RigCompletionData compDat(wellPathName, {i,j,k} ); compDat.setFromFracture(trans, fracture->fractureTemplate()->skinFactor()); compDat.addMetadata(fracture->name(), QString::number(trans)); fractureCompletions.push_back(compDat); @@ -268,7 +331,6 @@ std::vector RicExportFractureCompletionsImpl::generateFractur } return fractureCompletions; - } diff --git a/ApplicationCode/Commands/CompletionCommands/RicExportFractureCompletionsImpl.h b/ApplicationCode/Commands/CompletionCommands/RicExportFractureCompletionsImpl.h index 1465d9e332..dd60dd4e7e 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicExportFractureCompletionsImpl.h +++ b/ApplicationCode/Commands/CompletionCommands/RicExportFractureCompletionsImpl.h @@ -21,13 +21,29 @@ class RicExportCompletionDataSettingsUi; #include #include "RigCompletionData.h" + class QTextStream; +class RigWellPath; +class RimEclipseCase; +class RimEclipseWell; +class RimFracture; class RicExportFractureCompletionsImpl { public: - static std::vector generateFracturesCompdatValues(const RimWellPath* wellPath, - const RicExportCompletionDataSettingsUi& settings, - QTextStream* outputStreamForIntermediateResultsText); + static std::vector generateCompdatValuesForWellPath(const RimWellPath* wellPath, + const RicExportCompletionDataSettingsUi& settings, + QTextStream* outputStreamForIntermediateResultsText); + static std::vector generateCompdatValuesForSimWell(const RimEclipseCase* eclipseCase, + const RimEclipseWell* well, + size_t timeStep, + QTextStream* outputStreamForIntermediateResultsText); + +private: + static std::vector generateCompdatValues(const RimEclipseCase* caseToApply, + const QString& wellPathName, + const RigWellPath* wellPathGeometry, + const std::vector fractures, + QTextStream* outputStreamForIntermediateResultsText); }; diff --git a/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp b/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp index 1598c433a1..60dc1cf9a7 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp +++ b/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp @@ -31,6 +31,8 @@ #include "RimPerforationInterval.h" #include "RimPerforationCollection.h" #include "RimReservoirCellResultsStorage.h" +#include "RimEclipseWell.h" +#include "RimEclipseWellCollection.h" #include "RicExportCompletionDataSettingsUi.h" @@ -61,7 +63,32 @@ CAF_CMD_SOURCE_INIT(RicWellPathExportCompletionDataFeature, "RicWellPathExportCo //-------------------------------------------------------------------------------------------------- bool RicWellPathExportCompletionDataFeature::isCommandEnabled() { - return !selectedWellPaths().empty(); + std::vector wellPaths = selectedWellPaths(); + std::vector simWells = selectedSimWells(); + + if (wellPaths.empty() && simWells.empty()) + { + return false; + } + + if (!wellPaths.empty() && !simWells.empty()) + { + return false; + } + + std::set eclipseCases; + for (auto simWell : simWells) + { + RimEclipseCase* eclipseCase; + simWell->firstAncestorOrThisOfType(eclipseCase); + eclipseCases.insert(eclipseCase); + } + if (eclipseCases.size() > 1) + { + return false; + } + + return true; } //-------------------------------------------------------------------------------------------------- @@ -70,8 +97,9 @@ bool RicWellPathExportCompletionDataFeature::isCommandEnabled() void RicWellPathExportCompletionDataFeature::onActionTriggered(bool isChecked) { std::vector wellPaths = selectedWellPaths(); + std::vector simWells = selectedSimWells(); - CVF_ASSERT(wellPaths.size() > 0); + CVF_ASSERT(wellPaths.size() > 0 || simWells.size() > 0); RiaApplication* app = RiaApplication::instance(); @@ -79,6 +107,16 @@ void RicWellPathExportCompletionDataFeature::onActionTriggered(bool isChecked) QString defaultDir = RiaApplication::instance()->lastUsedDialogDirectoryWithFallback("COMPLETIONS", projectFolder); RicExportCompletionDataSettingsUi exportSettings; + + if (wellPaths.empty()) + { + exportSettings.showForSimWells(); + } + else + { + exportSettings.showForWellPath(); + } + std::vector cases; app->project()->allCases(cases); for (auto c : cases) @@ -98,7 +136,7 @@ void RicWellPathExportCompletionDataFeature::onActionTriggered(bool isChecked) { RiaApplication::instance()->setLastUsedDialogDirectory("COMPLETIONS", QFileInfo(exportSettings.fileName).absolutePath()); - exportCompletions(wellPaths, exportSettings); + exportCompletions(wellPaths, simWells, exportSettings); } } @@ -137,7 +175,32 @@ std::vector RicWellPathExportCompletionDataFeature::selectedWellPa //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeature::exportCompletions(const std::vector& wellPaths, const RicExportCompletionDataSettingsUi& exportSettings) +std::vector RicWellPathExportCompletionDataFeature::selectedSimWells() +{ + std::vector simWells; + caf::SelectionManager::instance()->objectsByType(&simWells); + + std::vector simWellCollections; + caf::SelectionManager::instance()->objectsByType(&simWellCollections); + + for (auto simWellCollection : simWellCollections) + { + for (auto simWell : simWellCollection->wells()) + { + simWells.push_back(simWell); + } + } + + std::set uniqueSimWells(simWells.begin(), simWells.end()); + simWells.assign(uniqueSimWells.begin(), uniqueSimWells.end()); + + return simWells; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicWellPathExportCompletionDataFeature::exportCompletions(const std::vector& wellPaths, const std::vector& simWells, const RicExportCompletionDataSettingsUi& exportSettings) { QFile exportFile(exportSettings.fileName()); @@ -168,6 +231,16 @@ void RicWellPathExportCompletionDataFeature::exportCompletions(const std::vector break; } } + for (const RimEclipseWell* simWell : simWells) + { + RimEclipseCase* eclipseCase; + simWell->firstAncestorOrThisOfType(eclipseCase); + if (exportSettings.caseToApply->eclipseCaseData()->unitsType() != eclipseCase->eclipseCaseData()->unitsType()) + { + unitSystemMismatch = true; + break; + } + } if (unitSystemMismatch) { RiaLogging::error("Well path unit systems must match unit system of chosen eclipse case."); @@ -199,13 +272,18 @@ void RicWellPathExportCompletionDataFeature::exportCompletions(const std::vector if (exportSettings.includeFractures()) { - std::vector fractureCompletionData = - RicExportFractureCompletionsImpl::generateFracturesCompdatValues(wellPath, exportSettings, &stream); + std::vector fractureCompletionData = RicExportFractureCompletionsImpl::generateCompdatValuesForWellPath(wellPath, exportSettings, &stream); appendCompletionData(&completionData, fractureCompletionData); } } + for (auto simWell : simWells) + { + std::vector fractureCompletionData = RicExportFractureCompletionsImpl::generateCompdatValuesForSimWell(exportSettings.caseToApply(), simWell, exportSettings.timeStep(), &stream); + appendCompletionData(&completionData, fractureCompletionData); + } + // Merge map into a vector of values std::vector completions; for (auto& data : completionData) diff --git a/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.h b/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.h index 711c4e5c31..a9465dc948 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.h +++ b/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.h @@ -33,6 +33,7 @@ class RimWellPath; class RimEclipseCase; +class RimEclipseWell; class RigEclipseCaseData; class RigMainGrid; class RigCell; @@ -126,13 +127,14 @@ protected: virtual void setupActionLook(QAction* actionToSetup) override; std::vector selectedWellPaths(); + std::vector selectedSimWells(); public: static std::vector findWellSegmentLocations(const RimEclipseCase* caseToApply, const RimWellPath* wellPath); static std::vector findWellSegmentLocations(const RimEclipseCase* caseToApply, const RimWellPath* wellPath, const std::vector& fishbonesSubs); private: - static void exportCompletions(const std::vector& wellPaths, const RicExportCompletionDataSettingsUi& exportSettings); + static void exportCompletions(const std::vector& wellPaths, const std::vector& simWells, const RicExportCompletionDataSettingsUi& exportSettings); static void generateCompdatTable(RifEclipseDataTableFormatter& formatter, const std::vector& completionData); static void generateWpimultTable(RifEclipseDataTableFormatter& formatter, const std::vector& completionData); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimSimWellFracture.h b/ApplicationCode/ProjectDataModel/Completions/RimSimWellFracture.h index 914c36c86b..02b30f3284 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimSimWellFracture.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimSimWellFracture.h @@ -47,6 +47,7 @@ public: double wellAzimuthAtFracturePosition() override; double wellDipAtFracturePosition(); + int branchIndex() const { return m_branchIndex(); } protected: virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseWell.cpp b/ApplicationCode/ProjectDataModel/RimEclipseWell.cpp index 01f7c739f7..5bf8739dd2 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseWell.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseWell.cpp @@ -166,7 +166,7 @@ void RimEclipseWell::calculateWellPipeStaticCenterLine(std::vector< std::vector //-------------------------------------------------------------------------------------------------- void RimEclipseWell::calculateWellPipeDynamicCenterLine(size_t timeStepIdx, std::vector< std::vector >& pipeBranchesCLCoords, - std::vector< std::vector >& pipeBranchesCellIds) + std::vector< std::vector >& pipeBranchesCellIds) const { RigSimulationWellCenterLineCalculator::calculateWellPipeDynamicCenterline(this, timeStepIdx, pipeBranchesCLCoords, pipeBranchesCellIds); } diff --git a/ApplicationCode/ProjectDataModel/RimEclipseWell.h b/ApplicationCode/ProjectDataModel/RimEclipseWell.h index 3cc51304c6..94211cd0ea 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseWell.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseWell.h @@ -70,7 +70,7 @@ public: void calculateWellPipeDynamicCenterLine(size_t timeStepIdx, std::vector< std::vector >& pipeBranchesCLCoords, - std::vector< std::vector >& pipeBranchesCellIds); + std::vector< std::vector >& pipeBranchesCellIds) const; void wellHeadTopBottomPosition(size_t frameIndex, cvf::Vec3d* top, cvf::Vec3d* bottom); double pipeRadius(); diff --git a/ApplicationCode/ReservoirDataModel/RigSimulationWellCenterLineCalculator.cpp b/ApplicationCode/ReservoirDataModel/RigSimulationWellCenterLineCalculator.cpp index 7ca0b0b0e4..1364048f24 100644 --- a/ApplicationCode/ReservoirDataModel/RigSimulationWellCenterLineCalculator.cpp +++ b/ApplicationCode/ReservoirDataModel/RigSimulationWellCenterLineCalculator.cpp @@ -45,14 +45,14 @@ void RigSimulationWellCenterLineCalculator::calculateWellPipeStaticCenterline(Ri //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigSimulationWellCenterLineCalculator::calculateWellPipeDynamicCenterline(RimEclipseWell* rimWell, +void RigSimulationWellCenterLineCalculator::calculateWellPipeDynamicCenterline(const RimEclipseWell* rimWell, size_t timeStepIndex, std::vector< std::vector >& pipeBranchesCLCoords, std::vector< std::vector >& pipeBranchesCellIds) { CVF_ASSERT(rimWell); - RigSingleWellResultsData* wellResults = rimWell->wellResults(); + const RigSingleWellResultsData* wellResults = rimWell->wellResults(); RimEclipseView* eclipseView; rimWell->firstAncestorOrThisOfType(eclipseView); diff --git a/ApplicationCode/ReservoirDataModel/RigSimulationWellCenterLineCalculator.h b/ApplicationCode/ReservoirDataModel/RigSimulationWellCenterLineCalculator.h index 00d1c88305..628c5ad7ef 100644 --- a/ApplicationCode/ReservoirDataModel/RigSimulationWellCenterLineCalculator.h +++ b/ApplicationCode/ReservoirDataModel/RigSimulationWellCenterLineCalculator.h @@ -32,7 +32,7 @@ public: std::vector< std::vector >& pipeBranchesCLCoords, std::vector< std::vector >& pipeBranchesCellIds) ; - static void calculateWellPipeDynamicCenterline(RimEclipseWell* rimWell, + static void calculateWellPipeDynamicCenterline(const RimEclipseWell* rimWell, size_t timeStepIndex, std::vector< std::vector >& pipeBranchesCLCoords, std::vector< std::vector >& pipeBranchesCellIds) ;