From ec1cf83b4e722041517b031725dc64005022ab46 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 5 Aug 2019 21:53:48 +0200 Subject: [PATCH] #4483 Summary Plot: Data source for well segment number and completions --- .../Tools/RiaSummaryCurveAnalyzer.cpp | 107 +++++++- .../Tools/RiaSummaryCurveAnalyzer.h | 25 +- .../RifEclipseSummaryAddress.cpp | 24 +- .../FileInterface/RifEclipseSummaryAddress.h | 4 +- .../Summary/RimSummaryPlotNameHelper.cpp | 73 +++++- .../Summary/RimSummaryPlotNameHelper.h | 6 + .../Summary/RimSummaryPlotSourceStepping.cpp | 228 +++++++++++------- .../Summary/RimSummaryPlotSourceStepping.h | 7 +- .../UnitTests/CMakeLists_files.cmake | 1 + .../RiaSummaryCurveAnalyzer-Test.cpp | 134 ++++++++++ 10 files changed, 488 insertions(+), 121 deletions(-) create mode 100644 ApplicationCode/UnitTests/RiaSummaryCurveAnalyzer-Test.cpp diff --git a/ApplicationCode/Application/Tools/RiaSummaryCurveAnalyzer.cpp b/ApplicationCode/Application/Tools/RiaSummaryCurveAnalyzer.cpp index 9b0f7f973a..35feb92961 100644 --- a/ApplicationCode/Application/Tools/RiaSummaryCurveAnalyzer.cpp +++ b/ApplicationCode/Application/Tools/RiaSummaryCurveAnalyzer.cpp @@ -26,8 +26,6 @@ #include -#include - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -125,6 +123,50 @@ std::set RiaSummaryCurveAnalyzer::regionNumbers() const return m_regionNumbers; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::set RiaSummaryCurveAnalyzer::wellCompletions(const std::string& wellName) const +{ + std::set connections; + + for (const auto& conn : m_wellCompletions) + { + if (conn.first == wellName) + { + connections.insert(conn.second); + } + } + + return connections; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::set RiaSummaryCurveAnalyzer::wellSegmentNumbers(const std::string& wellName) const +{ + std::set segmentNumberForWell; + + for (const auto& wellSegment : m_wellSegmentNumbers) + { + if (wellName.empty() || std::get<0>(wellSegment) == wellName) + { + segmentNumberForWell.insert(std::get<1>(wellSegment)); + } + } + + return segmentNumberForWell; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::set RiaSummaryCurveAnalyzer::blocks() const +{ + return m_blocks; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -136,33 +178,57 @@ std::set RiaSummaryCurveAnalyzer:: //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RiaSummaryCurveAnalyzer::identifierTexts(RifEclipseSummaryAddress::SummaryVarCategory category) const +std::vector RiaSummaryCurveAnalyzer::identifierTexts(RifEclipseSummaryAddress::SummaryVarCategory category, + const std::string& secondaryIdentifier) const { - std::vector stringSet; + std::vector identifierStrings; if (category == RifEclipseSummaryAddress::SUMMARY_REGION) { for (const auto& regionNumber : m_regionNumbers) { - stringSet.push_back(QString::number(regionNumber)); + identifierStrings.push_back(QString::number(regionNumber)); } } else if (category == RifEclipseSummaryAddress::SUMMARY_WELL) { for (const auto& wellName : m_wellNames) { - stringSet.push_back(QString::fromStdString(wellName)); + identifierStrings.push_back(QString::fromStdString(wellName)); } } else if (category == RifEclipseSummaryAddress::SUMMARY_WELL_GROUP) { for (const auto& wellGroupName : m_wellGroupNames) { - stringSet.push_back(QString::fromStdString(wellGroupName)); + identifierStrings.push_back(QString::fromStdString(wellGroupName)); + } + } + else if (category == RifEclipseSummaryAddress::SUMMARY_BLOCK) + { + for (const auto& ijkBlock : m_blocks) + { + identifierStrings.push_back(QString::fromStdString(ijkBlock)); + } + } + else if (category == RifEclipseSummaryAddress::SUMMARY_WELL_SEGMENT) + { + auto segmentNumbers = wellSegmentNumbers(secondaryIdentifier); + for (const auto& segment : segmentNumbers) + { + identifierStrings.push_back(QString::number(segment)); + } + } + else if (category == RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION) + { + auto connections = wellCompletions(secondaryIdentifier); + for (const auto& conn : connections) + { + identifierStrings.push_back(QString::fromStdString(conn)); } } - return stringSet; + return identifierStrings; } //-------------------------------------------------------------------------------------------------- @@ -213,6 +279,9 @@ void RiaSummaryCurveAnalyzer::clear() m_wellGroupNames.clear(); m_regionNumbers.clear(); m_categories.clear(); + m_wellCompletions.clear(); + m_wellSegmentNumbers.clear(); + m_blocks.clear(); } //-------------------------------------------------------------------------------------------------- @@ -267,9 +336,11 @@ void RiaSummaryCurveAnalyzer::computeQuantityNamesWithHistory() const //-------------------------------------------------------------------------------------------------- void RiaSummaryCurveAnalyzer::analyzeSingleAddress(const RifEclipseSummaryAddress& address) { - if (!address.wellName().empty()) + const std::string& wellName = address.wellName(); + + if (!wellName.empty()) { - m_wellNames.insert(address.wellName()); + m_wellNames.insert(wellName); } if (!address.quantityName().empty()) @@ -287,6 +358,22 @@ void RiaSummaryCurveAnalyzer::analyzeSingleAddress(const RifEclipseSummaryAddres m_regionNumbers.insert(address.regionNumber()); } + if (address.category() == RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION) + { + auto wellNameAndCompletion = std::make_pair(wellName, address.blockAsString()); + m_wellCompletions.insert(wellNameAndCompletion); + } + else if (address.category() == RifEclipseSummaryAddress::SUMMARY_WELL_SEGMENT) + { + auto wellNameAndSegment = std::make_pair(wellName, address.wellSegmentNumber()); + m_wellSegmentNumbers.insert(wellNameAndSegment); + } + else if (address.category() == RifEclipseSummaryAddress::SUMMARY_BLOCK) + { + auto text = address.blockAsString(); + m_blocks.insert(text); + } + if (address.category() != RifEclipseSummaryAddress::SUMMARY_INVALID) { m_categories.insert(address.category()); diff --git a/ApplicationCode/Application/Tools/RiaSummaryCurveAnalyzer.h b/ApplicationCode/Application/Tools/RiaSummaryCurveAnalyzer.h index fea237f115..4e1070eea0 100644 --- a/ApplicationCode/Application/Tools/RiaSummaryCurveAnalyzer.h +++ b/ApplicationCode/Application/Tools/RiaSummaryCurveAnalyzer.h @@ -22,6 +22,7 @@ #include #include +#include #include class RimSummaryCurveCollection; @@ -44,18 +45,23 @@ public: std::set quantities() const; std::set quantityNamesWithHistory() const; std::set quantityNamesNoHistory() const; - + std::string quantityNameForTitle() const; std::set wellNames() const; std::set wellGroupNames() const; std::set regionNumbers() const; + std::set wellCompletions(const std::string& wellName) const; + std::set wellSegmentNumbers(const std::string& wellName) const; + std::set blocks() const; + std::set categories() const; - std::vector identifierTexts(RifEclipseSummaryAddress::SummaryVarCategory category) const; + std::vector identifierTexts(RifEclipseSummaryAddress::SummaryVarCategory category, + const std::string& secondaryIdentifier) const; - static std::vector addressesForCategory(const std::set& addresses, + static std::vector addressesForCategory(const std::set& addresses, RifEclipseSummaryAddress::SummaryVarCategory category); static std::string correspondingHistorySummaryCurveName(const std::string& curveName); @@ -67,13 +73,16 @@ private: void analyzeSingleAddress(const RifEclipseSummaryAddress& address); private: - std::set m_quantities; + std::set m_quantities; mutable std::set m_quantitiesWithMatchingHistory; mutable std::set m_quantitiesNoMatchingHistory; - - std::set m_wellNames; - std::set m_wellGroupNames; - std::set m_regionNumbers; + + std::set m_wellNames; + std::set m_wellGroupNames; + std::set m_regionNumbers; + std::set> m_wellCompletions; + std::set> m_wellSegmentNumbers; + std::set m_blocks; std::set m_categories; }; diff --git a/ApplicationCode/FileInterface/RifEclipseSummaryAddress.cpp b/ApplicationCode/FileInterface/RifEclipseSummaryAddress.cpp index ea8c0fd9d0..d1bdd2a451 100644 --- a/ApplicationCode/FileInterface/RifEclipseSummaryAddress.cpp +++ b/ApplicationCode/FileInterface/RifEclipseSummaryAddress.cpp @@ -581,7 +581,7 @@ std::string RifEclipseSummaryAddress::uiText() const case SUMMARY_WELL_COMPLETION: { text += ":" + this->wellName(); - text += ":" + formatUiTextIJK(); + text += ":" + blockAsString(); } break; case SUMMARY_WELL_LGR: @@ -594,7 +594,7 @@ std::string RifEclipseSummaryAddress::uiText() const { text += ":" + this->lgrName(); text += ":" + this->wellName(); - text += ":" + formatUiTextIJK(); + text += ":" + blockAsString(); } break; case SUMMARY_WELL_SEGMENT: @@ -605,13 +605,13 @@ std::string RifEclipseSummaryAddress::uiText() const break; case SUMMARY_BLOCK: { - text += ":" + formatUiTextIJK(); + text += ":" + blockAsString(); } break; case SUMMARY_BLOCK_LGR: { text += ":" + this->lgrName(); - text += ":" + formatUiTextIJK(); + text += ":" + blockAsString(); } break; case SUMMARY_AQUIFER: @@ -635,7 +635,7 @@ std::string RifEclipseSummaryAddress::uiText(RifEclipseSummaryAddress::SummaryId case INPUT_REGION_2_REGION: return formatUiTextRegionToRegion(); case INPUT_WELL_NAME: return wellName(); case INPUT_WELL_GROUP_NAME: return wellGroupName(); - case INPUT_CELL_IJK: return formatUiTextIJK(); + case INPUT_CELL_IJK: return blockAsString(); case INPUT_LGR_NAME: return lgrName(); case INPUT_SEGMENT_NUMBER: return std::to_string(wellSegmentNumber()); case INPUT_AQUIFER_NUMBER: return std::to_string(aquiferNumber()); @@ -719,6 +719,18 @@ bool RifEclipseSummaryAddress::isValid() const return true; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifEclipseSummaryAddress::setCellIjk(const std::string& uiText) +{ + auto vec = RifEclipseSummaryAddress::ijkTupleFromUiText(uiText); + + m_cellI = std::get<0>(vec); + m_cellJ = std::get<1>(vec); + m_cellK = std::get<2>(vec); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -770,7 +782,7 @@ std::string RifEclipseSummaryAddress::baseQuantityName(const std::string& quanti //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::string RifEclipseSummaryAddress::formatUiTextIJK() const +std::string RifEclipseSummaryAddress::blockAsString() const { return std::to_string(this->cellI()) + ", " + std::to_string(this->cellJ()) + ", " diff --git a/ApplicationCode/FileInterface/RifEclipseSummaryAddress.h b/ApplicationCode/FileInterface/RifEclipseSummaryAddress.h index b321d648bf..8635f029da 100644 --- a/ApplicationCode/FileInterface/RifEclipseSummaryAddress.h +++ b/ApplicationCode/FileInterface/RifEclipseSummaryAddress.h @@ -162,6 +162,7 @@ public: int cellJ() const { return m_cellJ; } int cellK() const { return m_cellK; } int aquiferNumber() const { return m_aquiferNumber; } + std::string blockAsString() const; const std::string ensembleStatisticsQuantityName() const; @@ -176,6 +177,8 @@ public: void setWellGroupName(const std::string& wellGroupName) { m_wellGroupName = wellGroupName; } void setRegion(int region) { m_regionNumber = (int16_t)region; } void setAquiferNumber(int aquiferNumber) { m_aquiferNumber = (int16_t)aquiferNumber; } + void setCellIjk(const std::string& uiText); + void setWellSegmentNumber(int segment) { m_wellSegmentNumber = (int16_t)segment; } void setAsErrorResult() { m_isErrorResult = true; } bool isErrorResult() const { return m_isErrorResult; } @@ -184,7 +187,6 @@ public: private: bool isValidEclipseCategory() const; static std::string baseQuantityName(const std::string& quantityName); - std::string formatUiTextIJK() const; static std::tuple ijkTupleFromUiText(const std::string &s); std::string formatUiTextRegionToRegion() const; std::pair regionToRegionPairFromUiText(const std::string &s); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.cpp index 367f19f6cb..e20b651947 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.cpp @@ -117,6 +117,24 @@ QString RimSummaryPlotNameHelper::plotTitle() const title += "Region : " + QString::fromStdString(m_titleRegion); } + if (!m_titleBlock.empty()) + { + if (!title.isEmpty()) title += ", "; + title += "Block : " + QString::fromStdString(m_titleBlock); + } + + if (!m_titleSegment.empty()) + { + if (!title.isEmpty()) title += ", "; + title += "Segment : " + QString::fromStdString(m_titleSegment); + } + + if (!m_titleCompletion.empty()) + { + if (!title.isEmpty()) title += ", "; + title += "Completion : " + QString::fromStdString(m_titleCompletion); + } + if (!m_titleQuantity.empty()) { if (!title.isEmpty()) title += ", "; @@ -171,6 +189,30 @@ bool RimSummaryPlotNameHelper::isCaseInTitle() const return !m_titleCaseName.isEmpty(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimSummaryPlotNameHelper::isBlockInTitle() const +{ + return !m_titleBlock.empty(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimSummaryPlotNameHelper::isSegmentInTitle() const +{ + return !m_titleSegment.empty(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimSummaryPlotNameHelper::isCompletionInTitle() const +{ + return !m_titleCompletion.empty(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -180,6 +222,9 @@ void RimSummaryPlotNameHelper::clearTitleSubStrings() m_titleRegion.clear(); m_titleWellName.clear(); m_titleRegion.clear(); + m_titleBlock.clear(); + m_titleSegment.clear(); + m_titleCompletion.clear(); m_titleCaseName.clear(); } @@ -195,6 +240,7 @@ void RimSummaryPlotNameHelper::extractPlotTitleSubStrings() auto wellNames = m_analyzer.wellNames(); auto wellGroupNames = m_analyzer.wellGroupNames(); auto regions = m_analyzer.regionNumbers(); + auto blocks = m_analyzer.blocks(); auto categories = m_analyzer.categories(); if (categories.size() == 1) @@ -207,6 +253,22 @@ void RimSummaryPlotNameHelper::extractPlotTitleSubStrings() if (wellNames.size() == 1) { m_titleWellName = *(wellNames.begin()); + + { + auto segments = m_analyzer.wellSegmentNumbers(m_titleWellName); + if (segments.size() == 1) + { + m_titleSegment = std::to_string(*(segments.begin())); + } + } + + { + auto completions = m_analyzer.wellCompletions(m_titleWellName); + if (completions.size() == 1) + { + m_titleCompletion = *(completions.begin()); + } + } } if (wellGroupNames.size() == 1) @@ -218,9 +280,14 @@ void RimSummaryPlotNameHelper::extractPlotTitleSubStrings() { m_titleRegion = std::to_string(*(regions.begin())); } + + if (blocks.size() == 1) + { + m_titleBlock = *(blocks.begin()); + } } - auto summaryCases = setOfSummaryCases(); + auto summaryCases = setOfSummaryCases(); auto ensembleCases = setOfEnsembleCases(); if (summaryCases.size() == 1 && ensembleCases.empty()) @@ -243,7 +310,7 @@ void RimSummaryPlotNameHelper::extractPlotTitleSubStrings() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- std::set RimSummaryPlotNameHelper::setOfSummaryCases() const { @@ -258,7 +325,7 @@ std::set RimSummaryPlotNameHelper::setOfSummaryCases() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- std::set RimSummaryPlotNameHelper::setOfEnsembleCases() const { diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.h index 6c4bc4d237..b9c5d372d9 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.h @@ -54,6 +54,9 @@ public: bool isWellGroupNameInTitle() const; bool isRegionInTitle() const; bool isCaseInTitle() const; + bool isBlockInTitle() const; + bool isSegmentInTitle() const; + bool isCompletionInTitle() const; private: void clearTitleSubStrings(); @@ -73,6 +76,9 @@ private: std::string m_titleWellName; std::string m_titleWellGroupName; std::string m_titleRegion; + std::string m_titleBlock; + std::string m_titleSegment; + std::string m_titleCompletion; QString m_titleCaseName; }; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.cpp index 0712440fcb..5ed60b46a4 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.cpp @@ -67,7 +67,11 @@ RimSummaryPlotSourceStepping::RimSummaryPlotSourceStepping() CAF_PDM_InitFieldNoDefault(&m_wellGroupName, "GroupName", "Group Name", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_region, "Region", "Region", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_quantity, "Quantities", "Quantity", "", "", ""); - + + CAF_PDM_InitFieldNoDefault(&m_cellBlock, "CellBlock", "Block", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_segment, "Segment", "Segment", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_completion, "Completion", "Completion", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_ensemble, "Ensemble", "Ensemble", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_placeholderForLabel, "Placeholder", "", "", "", ""); @@ -284,6 +288,7 @@ QList RimSummaryPlotSourceStepping::calculateValueOption else { RifEclipseSummaryAddress::SummaryVarCategory category = RifEclipseSummaryAddress::SUMMARY_INVALID; + std::string secondaryIdentifier; if (fieldNeedingOptions == &m_wellName) { @@ -297,8 +302,22 @@ QList RimSummaryPlotSourceStepping::calculateValueOption { category = RifEclipseSummaryAddress::SUMMARY_WELL_GROUP; } + else if (fieldNeedingOptions == &m_cellBlock) + { + category = RifEclipseSummaryAddress::SUMMARY_BLOCK; + } + else if (fieldNeedingOptions == &m_segment) + { + secondaryIdentifier = m_wellName().toStdString(); + category = RifEclipseSummaryAddress::SUMMARY_WELL_SEGMENT; + } + else if (fieldNeedingOptions == &m_completion) + { + secondaryIdentifier = m_wellName().toStdString(); + category = RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION; + } - std::set identifierTexts; + std::vector identifierTexts; if (category != RifEclipseSummaryAddress::SUMMARY_INVALID) { @@ -308,10 +327,7 @@ QList RimSummaryPlotSourceStepping::calculateValueOption if (analyzer) { - for (const auto& t : analyzer->identifierTexts(category)) - { - identifierTexts.insert(t); - } + identifierTexts = analyzer->identifierTexts(category, secondaryIdentifier); } } } @@ -432,68 +448,6 @@ void RimSummaryPlotSourceStepping::fieldChangedByUi(const caf::PdmFieldHandle* c m_region.uiCapability()->updateConnectedEditors(); m_quantity.uiCapability()->updateConnectedEditors(); } - else if (changedField == &m_wellName) - { - for (auto curve : curves) - { - if (isYAxisStepping()) - { - RifEclipseSummaryAddress adr = curve->summaryAddressY(); - updateAddressIfMatching(oldValue, newValue, RifEclipseSummaryAddress::SUMMARY_WELL, &adr); - curve->setSummaryAddressY(adr); - } - - if (isXAxisStepping()) - { - RifEclipseSummaryAddress adr = curve->summaryAddressX(); - updateAddressIfMatching(oldValue, newValue, RifEclipseSummaryAddress::SUMMARY_WELL, &adr); - curve->setSummaryAddressX(adr); - } - } - - if (ensembleCurveColl) - { - for (auto curveSet : ensembleCurveColl->curveSets()) - { - auto adr = curveSet->summaryAddress(); - updateAddressIfMatching(oldValue, newValue, RifEclipseSummaryAddress::SUMMARY_WELL, &adr); - curveSet->setSummaryAddress(adr); - } - } - - triggerLoadDataAndUpdate = true; - } - else if (changedField == &m_region) - { - for (auto curve : curves) - { - if (isYAxisStepping()) - { - RifEclipseSummaryAddress adr = curve->summaryAddressY(); - updateAddressIfMatching(oldValue, newValue, RifEclipseSummaryAddress::SUMMARY_REGION, &adr); - curve->setSummaryAddressY(adr); - } - - if (isXAxisStepping()) - { - RifEclipseSummaryAddress adr = curve->summaryAddressX(); - updateAddressIfMatching(oldValue, newValue, RifEclipseSummaryAddress::SUMMARY_REGION, &adr); - curve->setSummaryAddressX(adr); - } - } - - if (ensembleCurveColl) - { - for (auto curveSet : ensembleCurveColl->curveSets()) - { - auto adr = curveSet->summaryAddress(); - updateAddressIfMatching(oldValue, newValue, RifEclipseSummaryAddress::SUMMARY_REGION, &adr); - curveSet->setSummaryAddress(adr); - } - } - - triggerLoadDataAndUpdate = true; - } else if (changedField == &m_quantity) { for (auto curve : curves) @@ -525,36 +479,65 @@ void RimSummaryPlotSourceStepping::fieldChangedByUi(const caf::PdmFieldHandle* c triggerLoadDataAndUpdate = true; } - else if (changedField == &m_wellGroupName) + { - for (auto curve : curves) + RifEclipseSummaryAddress::SummaryVarCategory summaryCategoryToModify = RifEclipseSummaryAddress::SUMMARY_INVALID; + if (changedField == &m_wellName) { - if (isYAxisStepping()) - { - RifEclipseSummaryAddress adr = curve->summaryAddressY(); - updateAddressIfMatching(oldValue, newValue, RifEclipseSummaryAddress::SUMMARY_WELL_GROUP, &adr); - curve->setSummaryAddressY(adr); - } - - if (isXAxisStepping()) - { - RifEclipseSummaryAddress adr = curve->summaryAddressX(); - updateAddressIfMatching(oldValue, newValue, RifEclipseSummaryAddress::SUMMARY_WELL_GROUP, &adr); - curve->setSummaryAddressX(adr); - } + summaryCategoryToModify = RifEclipseSummaryAddress::SUMMARY_WELL; + } + else if (changedField == &m_region) + { + summaryCategoryToModify = RifEclipseSummaryAddress::SUMMARY_REGION; + } + else if (changedField == &m_wellGroupName) + { + summaryCategoryToModify = RifEclipseSummaryAddress::SUMMARY_WELL_GROUP; + } + else if (changedField == &m_cellBlock) + { + summaryCategoryToModify = RifEclipseSummaryAddress::SUMMARY_BLOCK; + } + else if (changedField == &m_segment) + { + summaryCategoryToModify = RifEclipseSummaryAddress::SUMMARY_WELL_SEGMENT; + } + else if (changedField == &m_completion) + { + summaryCategoryToModify = RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION; } - if (ensembleCurveColl) + if (summaryCategoryToModify != RifEclipseSummaryAddress::SUMMARY_INVALID) { - for (auto curveSet : ensembleCurveColl->curveSets()) + for (auto curve : curves) { - auto adr = curveSet->summaryAddress(); - updateAddressIfMatching(oldValue, newValue, RifEclipseSummaryAddress::SUMMARY_WELL_GROUP, &adr); - curveSet->setSummaryAddress(adr); - } - } + if (isYAxisStepping()) + { + RifEclipseSummaryAddress adr = curve->summaryAddressY(); + updateAddressIfMatching(oldValue, newValue, summaryCategoryToModify, &adr); + curve->setSummaryAddressY(adr); + } - triggerLoadDataAndUpdate = true; + if (isXAxisStepping()) + { + RifEclipseSummaryAddress adr = curve->summaryAddressX(); + updateAddressIfMatching(oldValue, newValue, summaryCategoryToModify, &adr); + curve->setSummaryAddressX(adr); + } + } + + if (ensembleCurveColl) + { + for (auto curveSet : ensembleCurveColl->curveSets()) + { + auto adr = curveSet->summaryAddress(); + updateAddressIfMatching(oldValue, newValue, summaryCategoryToModify, &adr); + curveSet->setSummaryAddress(adr); + } + } + + triggerLoadDataAndUpdate = true; + } } if (triggerLoadDataAndUpdate) @@ -654,6 +637,21 @@ caf::PdmValueField* RimSummaryPlotSourceStepping::fieldToModify() return &m_region; } + if (analyzer.blocks().size() == 1) + { + return &m_cellBlock; + } + + if (analyzer.wellNames().size() == 1) + { + auto wellName = *(analyzer.wellNames().begin()); + + if (analyzer.wellSegmentNumbers(wellName).size() == 1) + { + return &m_segment; + } + } + return nullptr; } @@ -833,6 +831,30 @@ std::vector RimSummaryPlotSourceStepping::computeVisibleFi fieldsCommonForAllCurves.push_back(&m_region); } + if (analyzer.wellSegmentNumbers(m_wellName().toStdString()).size() == 1) + { + QString txt = QString::number(*(analyzer.wellSegmentNumbers(m_wellName().toStdString()).begin())); + m_segment = txt; + + fieldsCommonForAllCurves.push_back(&m_segment); + } + + if (analyzer.blocks().size() == 1) + { + QString txt = QString::fromStdString(*(analyzer.blocks().begin())); + m_cellBlock = txt; + + fieldsCommonForAllCurves.push_back(&m_cellBlock); + } + + if (analyzer.wellCompletions(m_wellName().toStdString()).size() == 1) + { + QString txt = QString::fromStdString(*(analyzer.wellCompletions(m_wellName().toStdString()).begin())); + m_completion = txt; + + fieldsCommonForAllCurves.push_back(&m_completion); + } + if (!analyzer.quantityNameForTitle().empty()) { QString txt = QString::fromStdString(analyzer.quantityNameForTitle()); @@ -959,7 +981,7 @@ bool RimSummaryPlotSourceStepping::updateAddressIfMatching(const QVariant& return true; } } - else if (RifEclipseSummaryAddress::isDependentOnWellName(category)) + else if (category == RifEclipseSummaryAddress::SUMMARY_WELL) { std::string oldString = oldValue.toString().toStdString(); std::string newString = newValue.toString().toStdString(); @@ -971,6 +993,28 @@ bool RimSummaryPlotSourceStepping::updateAddressIfMatching(const QVariant& return true; } } + else if (category == RifEclipseSummaryAddress::SUMMARY_BLOCK || RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION) + { + std::string oldString = oldValue.toString().toStdString(); + std::string newString = newValue.toString().toStdString(); + if (adr->blockAsString() == oldString) + { + adr->setCellIjk(newString); + + return true; + } + } + else if (category == RifEclipseSummaryAddress::SUMMARY_WELL_SEGMENT) + { + int oldInt = oldValue.toInt(); + int newInt = newValue.toInt(); + if (adr->wellSegmentNumber() == oldInt) + { + adr->setWellSegmentNumber(newInt); + + return true; + } + } return false; } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.h index 3fb33e26ca..746ec9777b 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.h @@ -18,6 +18,7 @@ #pragma once + #include "RiaSummaryCurveAnalyzer.h" #include "RifEclipseSummaryAddress.h" @@ -114,7 +115,11 @@ private: caf::PdmField m_region; caf::PdmField m_quantity; caf::PdmField m_placeholderForLabel; - + + caf::PdmField m_cellBlock; + caf::PdmField m_segment; + caf::PdmField m_completion; + caf::PdmField m_includeEnsembleCasesForCaseStepping; SourceSteppingType m_sourceSteppingType; diff --git a/ApplicationCode/UnitTests/CMakeLists_files.cmake b/ApplicationCode/UnitTests/CMakeLists_files.cmake index 160b3fda66..7f7dec4dcb 100644 --- a/ApplicationCode/UnitTests/CMakeLists_files.cmake +++ b/ApplicationCode/UnitTests/CMakeLists_files.cmake @@ -57,6 +57,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimWellPathCompletions-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/RimSummaryCaseCollection-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/RifActiveCellsReader-Test.cpp ${CMAKE_CURRENT_LIST_DIR}/RifCsvDataTableFormatter-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaSummaryCurveAnalyzer-Test.cpp ) if (RESINSIGHT_ENABLE_GRPC) diff --git a/ApplicationCode/UnitTests/RiaSummaryCurveAnalyzer-Test.cpp b/ApplicationCode/UnitTests/RiaSummaryCurveAnalyzer-Test.cpp new file mode 100644 index 0000000000..8ef1d3efcd --- /dev/null +++ b/ApplicationCode/UnitTests/RiaSummaryCurveAnalyzer-Test.cpp @@ -0,0 +1,134 @@ +#include "gtest/gtest.h" + +#include "RiaSummaryCurveAnalyzer.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(RiaSummaryCurveAnalyzer, WellCompletions) +{ + std::vector addresses; + + // Well A + std::string wellNameA = "well_name_a"; + { + RifEclipseSummaryAddress adr = RifEclipseSummaryAddress::wellCompletionAddress("quantity_name", wellNameA, 1, 2, 3); + addresses.push_back(adr); + } + { + RifEclipseSummaryAddress adr = RifEclipseSummaryAddress::wellCompletionAddress("quantity_name", wellNameA, 1, 2, 3); + addresses.push_back(adr); + } + { + RifEclipseSummaryAddress adr = RifEclipseSummaryAddress::wellCompletionAddress("quantity_name", wellNameA, 5, 2, 3); + addresses.push_back(adr); + } + + // Well B + std::string wellNameB = "well_name_b"; + { + RifEclipseSummaryAddress adr = RifEclipseSummaryAddress::wellCompletionAddress("quantity_name", wellNameB, 5, 2, 3); + addresses.push_back(adr); + } + { + RifEclipseSummaryAddress adr = RifEclipseSummaryAddress::wellCompletionAddress("quantity_name", wellNameB, 5, 4, 3); + addresses.push_back(adr); + } + { + RifEclipseSummaryAddress adr = RifEclipseSummaryAddress::wellCompletionAddress("quantity_name", wellNameB, 5, 4, 30); + addresses.push_back(adr); + } + + RiaSummaryCurveAnalyzer analyzer; + analyzer.appendAdresses(addresses); + + EXPECT_EQ(2u, analyzer.wellNames().size()); + + auto completionsForA = analyzer.wellCompletions(wellNameA); + EXPECT_EQ(2u, completionsForA.size()); + + auto completionsForB = analyzer.wellCompletions(wellNameB); + EXPECT_EQ(3u, completionsForB.size()); + std::string tupleToFind = "5, 4, 30"; + EXPECT_TRUE(completionsForB.find(tupleToFind) != completionsForB.end()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(RiaSummaryCurveAnalyzer, WellSegments) +{ + std::vector addresses; + + // Well A + std::string wellNameA = "well_name_a"; + { + RifEclipseSummaryAddress adr = RifEclipseSummaryAddress::wellSegmentAddress("quantity_name", wellNameA, 1); + addresses.push_back(adr); + } + { + RifEclipseSummaryAddress adr = RifEclipseSummaryAddress::wellSegmentAddress("quantity_name", wellNameA, 1); + addresses.push_back(adr); + } + { + RifEclipseSummaryAddress adr = RifEclipseSummaryAddress::wellSegmentAddress("quantity_name", wellNameA, 30); + addresses.push_back(adr); + } + + // Well B + std::string wellNameB = "well_name_b"; + { + RifEclipseSummaryAddress adr = RifEclipseSummaryAddress::wellSegmentAddress("quantity_name", wellNameB, 1); + addresses.push_back(adr); + } + { + RifEclipseSummaryAddress adr = RifEclipseSummaryAddress::wellSegmentAddress("quantity_name", wellNameB, 3); + addresses.push_back(adr); + } + { + RifEclipseSummaryAddress adr = RifEclipseSummaryAddress::wellSegmentAddress("quantity_name", wellNameB, 10); + addresses.push_back(adr); + } + + RiaSummaryCurveAnalyzer analyzer; + analyzer.appendAdresses(addresses); + + EXPECT_EQ(2u, analyzer.wellNames().size()); + + auto segmentsForA = analyzer.wellSegmentNumbers(wellNameA); + EXPECT_EQ(2u, segmentsForA.size()); + + auto segmentsForB = analyzer.wellSegmentNumbers(wellNameB); + EXPECT_EQ(3u, segmentsForB.size()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(RiaSummaryCurveAnalyzer, CellBlocks) +{ + std::vector addresses; + + { + RifEclipseSummaryAddress adr = RifEclipseSummaryAddress::blockAddress("quantity_name", 1, 2, 3); + addresses.push_back(adr); + } + { + RifEclipseSummaryAddress adr = RifEclipseSummaryAddress::blockAddress("quantity_name", 1, 2, 3); + addresses.push_back(adr); + } + { + RifEclipseSummaryAddress adr = RifEclipseSummaryAddress::blockAddress("quantity_name", 2, 2, 3); + addresses.push_back(adr); + } + { + RifEclipseSummaryAddress adr = RifEclipseSummaryAddress::blockAddress("quantity_name", 5, 2, 3); + addresses.push_back(adr); + } + + RiaSummaryCurveAnalyzer analyzer; + analyzer.appendAdresses(addresses); + + auto blocks = analyzer.blocks(); + EXPECT_EQ(3u, blocks.size()); +}