From 31a64e50acb2321a38e2d9395b54e17eda9a1889 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rnar=20Grip=20Fj=C3=A6r?= Date: Fri, 16 Jun 2017 09:44:39 +0200 Subject: [PATCH] #1602 Completion Type : Add fracture category --- ApplicationCode/Application/RiaDefines.cpp | 1 + ApplicationCode/Application/RiaDefines.h | 3 +- .../RimCompletionCellIntersectionCalc.cpp | 77 +++++++++++++++++++ .../RimCompletionCellIntersectionCalc.h | 2 + .../Completions/RimFracture.cpp | 8 +- .../Completions/RimWellPathFracture.cpp | 2 +- .../ProjectDataModel/RimEclipseCellColors.cpp | 2 + .../ProjectDataModel/RimWellPath.cpp | 10 +++ .../ProjectDataModel/RimWellPath.h | 13 ++-- 9 files changed, 105 insertions(+), 13 deletions(-) diff --git a/ApplicationCode/Application/RiaDefines.cpp b/ApplicationCode/Application/RiaDefines.cpp index 65b29bf2af..378744bf11 100644 --- a/ApplicationCode/Application/RiaDefines.cpp +++ b/ApplicationCode/Application/RiaDefines.cpp @@ -71,6 +71,7 @@ namespace caf addItem(RiaDefines::WELL_PATH, "WELL_PATH", "Well Path"); addItem(RiaDefines::PERFORATION_INTERVAL, "PERFORATION_INTERVAL", "Perforation Interval"); addItem(RiaDefines::FISHBONES, "FISHBONES", "Fishbones"); + addItem(RiaDefines::FRACTURE, "FRACTURE", "Fracture"); setDefault(RiaDefines::WELL_PATH); } diff --git a/ApplicationCode/Application/RiaDefines.h b/ApplicationCode/Application/RiaDefines.h index 734d09e99b..7884b37087 100644 --- a/ApplicationCode/Application/RiaDefines.h +++ b/ApplicationCode/Application/RiaDefines.h @@ -46,7 +46,8 @@ public: enum CompletionType { WELL_PATH, PERFORATION_INTERVAL, - FISHBONES + FISHBONES, + FRACTURE, }; static bool isPerCellFaceResult(const QString& resultName); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.cpp b/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.cpp index 7f881581db..f488aca2cd 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.cpp @@ -28,10 +28,17 @@ #include "RimFishbonesMultipleSubs.h" #include "RimPerforationCollection.h" #include "RimPerforationInterval.h" +#include "RimFracture.h" +#include "RimWellPathFracture.h" +#include "RimFractureTemplate.h" +#include "RimWellPathFractureCollection.h" #include "RigMainGrid.h" #include "RigWellPath.h" #include "RigWellPathIntersectionTools.h" +#include "RigFractureGrid.h" +#include "RigFractureCell.h" +#include "RigCellGeometryTools.h" #include @@ -66,6 +73,11 @@ void RimCompletionCellIntersectionCalc::calculateWellPathIntersections(const Rim calculateFishbonesIntersections(fishbones, grid, values); } + for (const RimWellPathFracture* fracture : wellPath->fractureCollection()->fractures()) + { + calculateFractureIntersections(grid, fracture, values); + } + for (const RimPerforationInterval* perforationInterval : wellPath->perforationIntervalCollection()->perforations()) { if (perforationInterval->isActiveOnDate(fromDate)) @@ -104,3 +116,68 @@ void RimCompletionCellIntersectionCalc::calculatePerforationIntersections(const values[intersection.m_hexIndex] = RiaDefines::PERFORATION_INTERVAL; } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCompletionCellIntersectionCalc::calculateFractureIntersections(const RigMainGrid* mainGrid, const RimFracture* fracture, std::vector& values) +{ + for (const RigFractureCell& fractureCell : fracture->fractureTemplate()->fractureGrid()->fractureCells()) + { + std::vector fractureCellTransformed; + for (const auto& v : fractureCell.getPolygon()) + { + cvf::Vec3f polygonNode = cvf::Vec3f(v); + polygonNode.transformPoint(fracture->transformMatrix()); + fractureCellTransformed.push_back(cvf::Vec3d(polygonNode)); + } + + std::vector potentialCells; + + { + cvf::BoundingBox boundingBox; + + for (cvf::Vec3d nodeCoord : fractureCellTransformed) + { + boundingBox.add(nodeCoord); + } + + mainGrid->findIntersectingCells(boundingBox, &potentialCells); + } + + for (size_t cellIndex : potentialCells) + { + std::array hexCorners; + mainGrid->cellCornerVertices(cellIndex, hexCorners.data()); + + std::vector< std::vector > planeCellPolygons; + bool isPlaneIntersected = RigHexIntersectionTools::planeHexIntersectionPolygons(hexCorners, fracture->transformMatrix(), planeCellPolygons); + if (!isPlaneIntersected || planeCellPolygons.empty()) continue; + + { + cvf::Mat4d invertedTransformMatrix = cvf::Mat4d(fracture->transformMatrix().getInverted()); + for (std::vector& planeCellPolygon : planeCellPolygons) + { + for (cvf::Vec3d& v : planeCellPolygon) + { + v.transformPoint(invertedTransformMatrix); + } + } + } + + for (const std::vector& planeCellPolygon : planeCellPolygons) + { + std::vector< std::vector > clippedPolygons = RigCellGeometryTools::intersectPolygons(planeCellPolygon, fractureCell.getPolygon()); + for (const auto& clippedPolygon : clippedPolygons) + { + if (!clippedPolygon.empty()) + { + values[cellIndex] = RiaDefines::FRACTURE; + break; + } + } + } + } + + } +} diff --git a/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.h b/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.h index 24491eeac7..9ff011ddb8 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.h @@ -24,6 +24,7 @@ class RimProject; class RimWellPath; class RimFishbonesMultipleSubs; class RimPerforationInterval; +class RimFracture; class RigMainGrid; class QDateTime; @@ -41,4 +42,5 @@ private: static void calculateWellPathIntersections(const RimWellPath* wellPath, const RigMainGrid* grid, std::vector& values, const QDateTime& fromDate); static void calculateFishbonesIntersections(const RimFishbonesMultipleSubs* fishbonesSubs, const RigMainGrid* grid, std::vector& values); static void calculatePerforationIntersections(const RimWellPath* wellPath, const RimPerforationInterval* perforationInterval, const RigMainGrid* grid, std::vector& values); + static void calculateFractureIntersections(const RigMainGrid* mainGrid, const RimFracture* fracture, std::vector& values); }; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp index 2ac58bbeb3..63035082a9 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp @@ -180,11 +180,9 @@ void RimFracture::fieldChangedByUi(const caf::PdmFieldHandle* changedField, cons else { // Can be triggered from well path, find active view - RimView* activeView = RiaApplication::instance()->activeReservoirView(); - if (activeView) - { - activeView->createDisplayModelAndRedraw(); - } + RimProject* proj; + this->firstAncestorOrThisOfTypeAsserted(proj); + proj->reloadCompletionTypeResultsInAllViews(); } } diff --git a/ApplicationCode/ProjectDataModel/Completions/RimWellPathFracture.cpp b/ApplicationCode/ProjectDataModel/Completions/RimWellPathFracture.cpp index bd6d25ac31..788192b639 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimWellPathFracture.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimWellPathFracture.cpp @@ -80,7 +80,7 @@ void RimWellPathFracture::fieldChangedByUi(const caf::PdmFieldHandle* changedFie RimProject* proj = nullptr; this->firstAncestorOrThisOfType(proj); - if (proj) proj->createDisplayModelAndRedrawAllViews(); + if (proj) proj->reloadCompletionTypeResultsInAllViews(); } } diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp b/ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp index 731e26c3d7..aacc1e13af 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp @@ -389,10 +389,12 @@ void RimEclipseCellColors::updateLegendData(size_t currentTimeStep) caf::AppEnum wellPath(RiaDefines::WELL_PATH); caf::AppEnum fishbone(RiaDefines::FISHBONES); caf::AppEnum perforationInterval(RiaDefines::PERFORATION_INTERVAL); + caf::AppEnum fracture(RiaDefines::FRACTURE); categories.push_back(std::make_tuple(wellPath.uiText(), static_cast(wellPath.index()), cvf::Color3::RED)); categories.push_back(std::make_tuple(fishbone.uiText(), static_cast(fishbone.index()), cvf::Color3::DARK_GREEN)); categories.push_back(std::make_tuple(perforationInterval.uiText(), static_cast(perforationInterval.index()), cvf::Color3::GREEN)); + categories.push_back(std::make_tuple(fracture.uiText(), static_cast(fracture.index()), cvf::Color3::YELLOW_GREEN)); legendConfig()->setCategoryItems(categories); } diff --git a/ApplicationCode/ProjectDataModel/RimWellPath.cpp b/ApplicationCode/ProjectDataModel/RimWellPath.cpp index d8c28f5fcd..21d8aaf288 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPath.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPath.cpp @@ -223,6 +223,16 @@ RimWellPathFractureCollection* RimWellPath::fractureCollection() return m_completions->fractureCollection(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RimWellPathFractureCollection * RimWellPath::fractureCollection() const +{ + CVF_ASSERT(m_completions); + + return m_completions->fractureCollection(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimWellPath.h b/ApplicationCode/ProjectDataModel/RimWellPath.h index 6bf46222b5..7f3c6f837f 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPath.h +++ b/ApplicationCode/ProjectDataModel/RimWellPath.h @@ -80,12 +80,13 @@ public: caf::PdmChildField m_wellLogFile; - RimFishbonesCollection* fishbonesCollection(); - const RimFishbonesCollection* fishbonesCollection() const; - RimPerforationCollection* perforationIntervalCollection(); - const RimPerforationCollection* perforationIntervalCollection() const; - const RimWellPathCompletions* completions() const; - RimWellPathFractureCollection* fractureCollection(); + RimFishbonesCollection* fishbonesCollection(); + const RimFishbonesCollection* fishbonesCollection() const; + RimPerforationCollection* perforationIntervalCollection(); + const RimPerforationCollection* perforationIntervalCollection() const; + const RimWellPathCompletions* completions() const; + RimWellPathFractureCollection* fractureCollection(); + const RimWellPathFractureCollection* fractureCollection() const; RigWellPath* wellPathGeometry(); const RigWellPath* wellPathGeometry() const;