diff --git a/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.cpp b/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.cpp index 984afb860c..d125d4de23 100644 --- a/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.cpp +++ b/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.cpp @@ -20,6 +20,8 @@ #include "RiaApplication.h" +#include "RigEclipseCaseData.h" + #include "Rim3dView.h" #include "RimEclipseCase.h" #include "RimEclipseCaseCollection.h" @@ -51,12 +53,10 @@ RiaCompletionTypeCalculationScheduler* RiaCompletionTypeCalculationScheduler::in //-------------------------------------------------------------------------------------------------- void RiaCompletionTypeCalculationScheduler::scheduleRecalculateCompletionTypeAndRedrawAllViews() { - for (RimEclipseCase* eclipseCase : RiaApplication::instance()->project()->activeOilField()->analysisModels->cases()) - { - m_eclipseCasesToRecalculate.push_back(eclipseCase); - } + std::vector eclipseCases = + RiaApplication::instance()->project()->activeOilField()->analysisModels->cases().childObjects(); - startTimer(); + scheduleRecalculateCompletionTypeAndRedrawEclipseCases(eclipseCases); } //-------------------------------------------------------------------------------------------------- @@ -64,7 +64,29 @@ void RiaCompletionTypeCalculationScheduler::scheduleRecalculateCompletionTypeAnd //-------------------------------------------------------------------------------------------------- void RiaCompletionTypeCalculationScheduler::scheduleRecalculateCompletionTypeAndRedrawEclipseCase(RimEclipseCase* eclipseCase) { - m_eclipseCasesToRecalculate.push_back(eclipseCase); + std::vector eclipseCases; + eclipseCases.push_back(eclipseCase); + + scheduleRecalculateCompletionTypeAndRedrawEclipseCases(eclipseCases); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaCompletionTypeCalculationScheduler::scheduleRecalculateCompletionTypeAndRedrawEclipseCases( + const std::vector& eclipseCases) +{ + for (RimEclipseCase* eclipseCase : eclipseCases) + { + CVF_ASSERT(eclipseCase); + + if (eclipseCase->eclipseCaseData()) + { + eclipseCase->eclipseCaseData()->setVirtualPerforationTransmissibilities(nullptr); + } + + m_eclipseCasesToRecalculate.push_back(eclipseCase); + } startTimer(); } @@ -111,7 +133,7 @@ RiaCompletionTypeCalculationScheduler::~RiaCompletionTypeCalculationScheduler() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RiaCompletionTypeCalculationScheduler::startTimer() { diff --git a/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.h b/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.h index 7a72bde95d..ecc58a91ae 100644 --- a/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.h +++ b/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.h @@ -45,6 +45,8 @@ private: RiaCompletionTypeCalculationScheduler(const RiaCompletionTypeCalculationScheduler& o) = delete; void operator=(const RiaCompletionTypeCalculationScheduler& o) = delete; + void scheduleRecalculateCompletionTypeAndRedrawEclipseCases(const std::vector& eclipseCases); + void startTimer(); private: diff --git a/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.cpp b/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.cpp index 8a3cc450b9..6f5df15e0b 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.cpp @@ -21,11 +21,13 @@ #include "RiaDefines.h" #include "RigCellGeometryTools.h" +#include "RigCompletionData.h" #include "RigEclipseCaseData.h" #include "RigFractureCell.h" #include "RigFractureGrid.h" #include "RigHexIntersectionTools.h" #include "RigMainGrid.h" +#include "RigVirtualPerforationTransmissibilities.h" #include "RigWellPath.h" #include "RigWellPathIntersectionTools.h" @@ -49,6 +51,7 @@ #include "RimWellPathFracture.h" #include "RimWellPathFractureCollection.h" +#include "RiaApplication.h" #include //-------------------------------------------------------------------------------------------------- @@ -77,6 +80,93 @@ void RimCompletionCellIntersectionCalc::calculateCompletionTypeResult(const RimP // NOTE : Never compute completion type result for simulation well fractures, as these are defined per view } +std::vector fromCompletionData(const std::vector& data) +{ + std::vector appCompletionTypes; + + for (const auto& d : data) + { + switch (d.completionType()) + { + case RigCompletionData::FRACTURE: + appCompletionTypes.push_back(RiaDefines::FRACTURE); + break; + case RigCompletionData::PERFORATION: + appCompletionTypes.push_back(RiaDefines::PERFORATION_INTERVAL); + break; + case RigCompletionData::FISHBONES: + appCompletionTypes.push_back(RiaDefines::FISHBONES); + break; + default: + break; + } + } + + return appCompletionTypes; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCompletionCellIntersectionCalc::calculateCompletionTypeResult(RimEclipseCase* eclipseCase, + std::vector& completionTypeCellResult, + size_t timeStep) +{ + CVF_ASSERT(eclipseCase && eclipseCase->eclipseCaseData()); + + RimProject* project = nullptr; + eclipseCase->firstAncestorOrThisOfTypeAsserted(project); + + if (project->activeOilField()->wellPathCollection->isActive) + { + const RigEclipseCaseData* eclipseCaseData = eclipseCase->eclipseCaseData(); + + for (const RimWellPath* wellPath : project->activeOilField()->wellPathCollection->wellPaths) + { + if (wellPath->showWellPath() && wellPath->wellPathGeometry()) + { + auto intersectedCells = RigWellPathIntersectionTools::findIntersectedGlobalCellIndices( + eclipseCaseData, wellPath->wellPathGeometry()->m_wellPathPoints); + + for (auto& intersection : intersectedCells) + { + completionTypeCellResult[intersection] = RiaDefines::WELL_PATH; + } + + auto conn = eclipseCase->computeAndGetVirtualPerforationTransmissibilities(); + if (conn) + { + for (const auto& connForWell : conn->multipleCompletionsPerEclipseCell(wellPath, timeStep)) + { + RiaDefines::CompletionType appCompletionType = RiaDefines::WELL_PATH; + + auto appCompletionTypes = fromCompletionData(connForWell.second); + + if (std::find(appCompletionTypes.begin(), appCompletionTypes.end(), RiaDefines::FISHBONES) != + appCompletionTypes.end()) + { + appCompletionType = RiaDefines::FISHBONES; + } + else if (std::find(appCompletionTypes.begin(), appCompletionTypes.end(), RiaDefines::FRACTURE) != + appCompletionTypes.end()) + { + appCompletionType = RiaDefines::FRACTURE; + } + else if (std::find(appCompletionTypes.begin(), + appCompletionTypes.end(), + RiaDefines::PERFORATION_INTERVAL) != appCompletionTypes.end()) + { + appCompletionType = RiaDefines::PERFORATION_INTERVAL; + } + + completionTypeCellResult[connForWell.first.globalCellIndex()] = appCompletionType; + } + } + } + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -175,9 +265,9 @@ void RimCompletionCellIntersectionCalc::calculatePerforationIntersections(const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimCompletionCellIntersectionCalc::calculateFractureIntersections(const RigMainGrid* mainGrid, - const RimWellPathFracture* fracture, - std::vector& values) +void RimCompletionCellIntersectionCalc::calculateFractureIntersections(const RigMainGrid* mainGrid, + const RimWellPathFracture* fracture, + std::vector& values) { if (!fracture->fractureTemplate()) return; if (!fracture->fractureTemplate()->fractureGrid()) return; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.h b/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.h index 98da985a44..c6852ea4a9 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.h @@ -43,6 +43,10 @@ public: std::vector& completionTypeCellResult, const QDateTime& fromDate); + static void calculateCompletionTypeResult(RimEclipseCase* eclipseCase, + std::vector& completionTypeCellResult, + size_t timeStep); + private: static void calculateWellPathIntersections(const RimWellPath* wellPath, const RigEclipseCaseData* eclipseCaseData, diff --git a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp index 3561ca9f00..fe4e457b3e 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp @@ -2254,12 +2254,7 @@ void RigCaseCellResultsData::computeCompletionTypeForTimeStep(size_t timeStep) if (!eclipseCase) return; - RimProject* project; - eclipseCase->firstAncestorOrThisOfTypeAsserted(project); - - QDateTime timeStepDate = this->timeStepDates()[timeStep]; - - RimCompletionCellIntersectionCalc::calculateCompletionTypeResult(project, eclipseCase, completionTypeResult, timeStepDate); + RimCompletionCellIntersectionCalc::calculateCompletionTypeResult(eclipseCase, completionTypeResult, timeStep); }