From 403bf1890c697fcfff3324a700cfee20346b1921 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rnar=20Grip=20Fj=C3=A6r?= Date: Thu, 15 Jun 2017 09:11:55 +0200 Subject: [PATCH] #1607 Record completion type of completion data and combine after all completions are calculated --- ...RicWellPathExportCompletionDataFeature.cpp | 10 ++--- .../RicWellPathExportCompletionDataFeature.h | 2 +- .../ReservoirDataModel/RigCompletionData.cpp | 45 ++++++++++++------- .../ReservoirDataModel/RigCompletionData.h | 11 ++++- 4 files changed, 46 insertions(+), 22 deletions(-) diff --git a/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp b/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp index d80282ef1f..7fa6ad98dd 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp +++ b/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp @@ -179,7 +179,7 @@ void RicWellPathExportCompletionDataFeature::exportCompletions(const std::vector QTextStream stream(&exportFile); RifEclipseDataTableFormatter formatter(stream); - std::map completionData; + std::map > completionData; for (auto wellPath : wellPaths) { @@ -207,7 +207,7 @@ void RicWellPathExportCompletionDataFeature::exportCompletions(const std::vector std::vector completions; for (auto& data : completionData) { - completions.push_back(data.second); + completions.push_back(RigCompletionData::combine(data.second)); } // Sort by well name / cell index std::sort(completions.begin(), completions.end()); @@ -525,18 +525,18 @@ void RicWellPathExportCompletionDataFeature::assignBranchAndSegmentNumbers(const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeature::appendCompletionData(std::map* completionData, const std::vector& data) +void RicWellPathExportCompletionDataFeature::appendCompletionData(std::map >* completionData, const std::vector& data) { for (auto& completion : data) { auto it = completionData->find(completion.cellIndex()); if (it != completionData->end()) { - it->second = RigCompletionData::combine(it->second, completion); + it->second.push_back(completion); } else { - completionData->insert(std::pair(completion.cellIndex(), completion)); + completionData->insert(std::pair >(completion.cellIndex(), std::vector {completion})); } } } diff --git a/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.h b/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.h index a1bc6acbc5..7add6e336d 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.h +++ b/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.h @@ -150,7 +150,7 @@ private: static void calculateLateralIntersections(const RimEclipseCase* caseToApply, WellSegmentLocation* location, int* branchNum, int* segmentNum); static void assignBranchAndSegmentNumbers(const RimEclipseCase* caseToApply, std::vector* locations); - static void appendCompletionData(std::map* completionData, const std::vector& data); + static void appendCompletionData(std::map >* completionData, const std::vector& data); }; diff --git a/ApplicationCode/ReservoirDataModel/RigCompletionData.cpp b/ApplicationCode/ReservoirDataModel/RigCompletionData.cpp index ddf5b3a33f..a89c809453 100644 --- a/ApplicationCode/ReservoirDataModel/RigCompletionData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCompletionData.cpp @@ -21,7 +21,7 @@ #include "RiaLogging.h" #include -#include // Needed for HUGE_VAL on linux +#include // Needed for HUGE_VAL on Linux //================================================================================================== /// @@ -59,25 +59,35 @@ RigCompletionData::RigCompletionData(const RigCompletionData& other) //================================================================================================== /// //================================================================================================== -RigCompletionData RigCompletionData::combine(const RigCompletionData& first, const RigCompletionData& second) +RigCompletionData RigCompletionData::combine(const std::vector& completions) { - RigCompletionData result(first); - CVF_ASSERT(result.m_wellName == second.m_wellName); - CVF_ASSERT(result.m_cellIndex == second.m_cellIndex); + CVF_ASSERT(!completions.empty()); - if (onlyOneIsDefaulted(result.m_transmissibility, second.m_transmissibility)) + auto it = completions.cbegin(); + RigCompletionData result(*it); + ++it; + + for (; it != completions.cend(); ++it) { - RiaLogging::error("Transmissibility defaulted in one but not both, will produce erroneous result"); - } - else - { - result.m_transmissibility += second.m_transmissibility; - } + if (it->completionType() != result.completionType()) + { + RiaLogging::error(QString("Cannot combine completions of different types in same cell [%1, %2, %3]").arg(result.m_cellIndex.i).arg(result.m_cellIndex.j).arg(result.m_cellIndex.k)); + continue; + } + if (onlyOneIsDefaulted(result.m_transmissibility, it->m_transmissibility)) + { + RiaLogging::error("Transmissibility defaulted in one but not both, will produce erroneous result"); + } + else + { + result.m_transmissibility += it->m_transmissibility; + } - result.m_metadata.reserve(result.m_metadata.size() + second.m_metadata.size()); - result.m_metadata.insert(result.m_metadata.end(), second.m_metadata.begin(), second.m_metadata.end()); + result.m_metadata.reserve(result.m_metadata.size() + it->m_metadata.size()); + result.m_metadata.insert(result.m_metadata.end(), it->m_metadata.begin(), it->m_metadata.end()); - result.m_count += second.m_count; + result.m_count += it->m_count; + } return result; } @@ -112,6 +122,7 @@ RigCompletionData& RigCompletionData::operator=(const RigCompletionData& other) //================================================================================================== void RigCompletionData::setFromFracture(double transmissibility, double skinFactor) { + m_completionType = FRACTURE; m_transmissibility = transmissibility; m_skinFactor = skinFactor; } @@ -121,6 +132,7 @@ void RigCompletionData::setFromFracture(double transmissibility, double skinFact //================================================================================================== void RigCompletionData::setFromFishbone(double diameter, CellDirection direction) { + m_completionType = FISHBONES; m_diameter = diameter; m_direction = direction; } @@ -130,6 +142,7 @@ void RigCompletionData::setFromFishbone(double diameter, CellDirection direction //================================================================================================== void RigCompletionData::setFromFishbone(double transmissibility, double skinFactor) { + m_completionType = FISHBONES; m_transmissibility = transmissibility; m_skinFactor = skinFactor; } @@ -139,6 +152,7 @@ void RigCompletionData::setFromFishbone(double transmissibility, double skinFact //================================================================================================== void RigCompletionData::setFromPerforation(double diameter, CellDirection direction) { + m_completionType = PERFORATION; m_diameter = diameter; m_direction = direction; } @@ -204,4 +218,5 @@ void RigCompletionData::copy(RigCompletionData& target, const RigCompletionData& target.m_dFactor = from.m_dFactor; target.m_direction = from.m_direction; target.m_count = from.m_count; + target.m_completionType = from.m_completionType; } diff --git a/ApplicationCode/ReservoirDataModel/RigCompletionData.h b/ApplicationCode/ReservoirDataModel/RigCompletionData.h index 7033ccac3a..7a82d4793a 100644 --- a/ApplicationCode/ReservoirDataModel/RigCompletionData.h +++ b/ApplicationCode/ReservoirDataModel/RigCompletionData.h @@ -91,11 +91,17 @@ struct RigCompletionMetaData { class RigCompletionData : public cvf::Object { public: + enum CompletionType { + FISHBONES, + FRACTURE, + PERFORATION, + }; + RigCompletionData(const QString wellName, const IJKCellIndex& cellIndex); ~RigCompletionData(); RigCompletionData(const RigCompletionData& other); - static RigCompletionData combine(const RigCompletionData& first, const RigCompletionData& second); + static RigCompletionData combine(const std::vector& completions); bool operator<(const RigCompletionData& other) const; RigCompletionData& operator=(const RigCompletionData& other); @@ -119,6 +125,7 @@ public: double dFactor() const { return m_dFactor; } CellDirection direction() const { return m_direction; } size_t count() const { return m_count; } + CompletionType completionType() const { return m_completionType; } private: std::vector m_metadata; @@ -136,6 +143,8 @@ private: // Number of parts that have contributed to this completion size_t m_count; + CompletionType m_completionType; + private: static bool onlyOneIsDefaulted(double first, double second); static void copy(RigCompletionData& target, const RigCompletionData& from);