From 4b2af286e3ced8f9bcac26e2d9d7e3d323200f5c Mon Sep 17 00:00:00 2001 From: Rebecca Cox Date: Thu, 16 Nov 2017 10:22:55 +0100 Subject: [PATCH] #2146 Num Flooded PV: Move getResultIndexableStaticResult --- .../RigCaseCellResultsData.cpp | 36 ++++++++++++++++ .../RigCaseCellResultsData.h | 1 + ...igNumberOfFloodedPoreVolumesCalculator.cpp | 41 +------------------ 3 files changed, 39 insertions(+), 39 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp index ab230499f7..af93731885 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp @@ -682,6 +682,42 @@ bool RigCaseCellResultsData::updateResultName(RiaDefines::ResultCatType resultTy return anyNameUpdated; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const std::vector* RigCaseCellResultsData::getResultIndexableStaticResult(RigActiveCellInfo* actCellInfo, RigCaseCellResultsData* gridCellResults, QString porvResultName, std::vector &activeCellsResultsTempContainer) +{ + size_t resultCellCount = actCellInfo->reservoirCellResultCount(); + size_t reservoirCellCount = actCellInfo->reservoirCellCount(); + + size_t scalarResultIndexPorv = gridCellResults->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, porvResultName); + + if (scalarResultIndexPorv == cvf::UNDEFINED_SIZE_T) return nullptr; + + const std::vector* porvResults = &(gridCellResults->cellScalarResults(scalarResultIndexPorv, 0)); + + if (!gridCellResults->isUsingGlobalActiveIndex(scalarResultIndexPorv)) + { + // PORV is given for all cells + + activeCellsResultsTempContainer.resize(resultCellCount, HUGE_VAL); + + for (size_t globalCellIndex = 0; globalCellIndex < reservoirCellCount; globalCellIndex++) + { + size_t resultIdx = actCellInfo->cellResultIndex(globalCellIndex); + if (resultIdx != cvf::UNDEFINED_SIZE_T) + { + activeCellsResultsTempContainer[resultIdx] = porvResults->at(globalCellIndex); + } + } + return &activeCellsResultsTempContainer; + } + else + { + return porvResults; + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h index ac1111cffc..e428b29f22 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h +++ b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h @@ -117,6 +117,7 @@ public: bool updateResultName(RiaDefines::ResultCatType resultType, QString& oldName, const QString& newName); + static const std::vector* getResultIndexableStaticResult(RigActiveCellInfo* actCellInfo, public: const std::vector& infoForEachResultIndex() { return m_resultInfos;} diff --git a/ApplicationCode/ReservoirDataModel/RigNumberOfFloodedPoreVolumesCalculator.cpp b/ApplicationCode/ReservoirDataModel/RigNumberOfFloodedPoreVolumesCalculator.cpp index f3e77288fb..cb507aadf4 100644 --- a/ApplicationCode/ReservoirDataModel/RigNumberOfFloodedPoreVolumesCalculator.cpp +++ b/ApplicationCode/ReservoirDataModel/RigNumberOfFloodedPoreVolumesCalculator.cpp @@ -36,43 +36,6 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- - -const std::vector* getResultIndexableStaticResult(RigActiveCellInfo* actCellInfo, - RigCaseCellResultsData* gridCellResults, - QString porvResultName, - std::vector &activeCellsResultsTempContainer) -{ - size_t resultCellCount = actCellInfo->reservoirCellResultCount(); - size_t reservoirCellCount = actCellInfo->reservoirCellCount(); - - size_t scalarResultIndexPorv = gridCellResults->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, porvResultName); - - if (scalarResultIndexPorv == cvf::UNDEFINED_SIZE_T) return nullptr; - - const std::vector* porvResults = &(gridCellResults->cellScalarResults(scalarResultIndexPorv, 0)); - - if ( !gridCellResults->isUsingGlobalActiveIndex(scalarResultIndexPorv) ) - { - // PORV is given for all cells - - activeCellsResultsTempContainer.resize(resultCellCount, HUGE_VAL); - - for ( size_t globalCellIndex = 0; globalCellIndex < reservoirCellCount; globalCellIndex++ ) - { - size_t resultIdx = actCellInfo->cellResultIndex(globalCellIndex); - if ( resultIdx != cvf::UNDEFINED_SIZE_T ) - { - activeCellsResultsTempContainer[resultIdx] = porvResults->at(globalCellIndex); - } - } - return &activeCellsResultsTempContainer; - } - else - { - return porvResults; - } -} - RigNumberOfFloodedPoreVolumesCalculator::RigNumberOfFloodedPoreVolumesCalculator(RimEclipseCase* caseToApply, const std::vector tracerNames) { @@ -87,12 +50,12 @@ RigNumberOfFloodedPoreVolumesCalculator::RigNumberOfFloodedPoreVolumesCalculator // PORV const std::vector* porvResults = nullptr; std::vector porvActiveCellsResultStorage; - porvResults = getResultIndexableStaticResult(actCellInfo, gridCellResults, "PORV", porvActiveCellsResultStorage); + porvResults = RigCaseCellResultsData::getResultIndexableStaticResult(actCellInfo, gridCellResults, "PORV", porvActiveCellsResultStorage); // SWCR if defined const std::vector* swcrResults = nullptr; - swcrResults = getResultIndexableStaticResult(actCellInfo, gridCellResults, "SWCR", porvActiveCellsResultStorage); + swcrResults = RigCaseCellResultsData::getResultIndexableStaticResult(actCellInfo, gridCellResults, "SWCR", porvActiveCellsResultStorage); std::vector scalarResultIndexTracers; for (QString tracerName : tracerNames)