From 577a706b576b1aa38303d4f5403fb4328bb16530 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 23 Oct 2018 21:27:26 +0200 Subject: [PATCH] #3531 Temporary LGR : Copy value from main grid cell to temporary cells --- .../RigCaseCellResultsData.cpp | 44 ++++++++++++++++++- .../RigCaseCellResultsData.h | 2 + 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp index b723249789..6a43fa717b 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp @@ -1125,9 +1125,11 @@ size_t RigCaseCellResultsData::findOrLoadScalarResult(RiaDefines::ResultCatType { resultLoadingSucess = false; } - else + else if (tempGridCellCount > 0) { values.resize(values.size() + tempGridCellCount); + + assignValuesToTemporaryLgrs(values); } } } @@ -1140,9 +1142,10 @@ size_t RigCaseCellResultsData::findOrLoadScalarResult(RiaDefines::ResultCatType { resultLoadingSucess = false; } - else + else if (tempGridCellCount > 0) { values.resize(values.size() + tempGridCellCount); + assignValuesToTemporaryLgrs(values); } } @@ -2398,3 +2401,40 @@ bool RigCaseCellResultsData::isDataPresent(size_t scalarResultIndex) const return false; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigCaseCellResultsData::assignValuesToTemporaryLgrs(std::vector& valuesForAllReservoirCells) +{ + CVF_ASSERT(m_activeCellInfo); + + for (size_t gridIdx = 0; gridIdx < m_ownerMainGrid->gridCount(); gridIdx++) + { + const auto& grid = m_ownerMainGrid->gridByIndex(gridIdx); + if (grid->isTempGrid()) + { + for (size_t localCellIdx = 0; localCellIdx < grid->cellCount(); localCellIdx++) + { + const RigCell& cell = grid->cell(localCellIdx); + + size_t mainGridCellIndex = cell.mainGridCellIndex(); + size_t reservoirCellIndex = grid->reservoirCellIndex(localCellIdx); + + size_t mainGridCellResultIndex = m_activeCellInfo->cellResultIndex(mainGridCellIndex); + size_t cellResultIndex = m_activeCellInfo->cellResultIndex(reservoirCellIndex); + + if (mainGridCellResultIndex != cvf::UNDEFINED_SIZE_T && cellResultIndex != cvf::UNDEFINED_SIZE_T) + { + double mainGridValue = valuesForAllReservoirCells[mainGridCellResultIndex]; + + valuesForAllReservoirCells[cellResultIndex] = mainGridValue; + } + else + { + RiaLogging::warning("Detected invalid/undefined cells when assigning result values to temporary LGRs"); + } + } + } + } +} + diff --git a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h index 728049b79c..3112ac7110 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h +++ b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h @@ -159,6 +159,8 @@ private: // from RimReservoirCellResultsStorage bool isDataPresent(size_t scalarResultIndex) const; + void assignValuesToTemporaryLgrs(std::vector& values); + cvf::ref m_readerInterface; private: