From eb0c2e4737e03cf7865d655acb634483e62e71e2 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Fri, 15 Feb 2019 13:03:05 +0100 Subject: [PATCH] #4096 Simplify code for loading case and time diff to use same method --- .../RigCaseCellResultCalculator.cpp | 14 +++--- .../RigCaseCellResultsData.cpp | 44 +------------------ 2 files changed, 8 insertions(+), 50 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/RigCaseCellResultCalculator.cpp b/ApplicationCode/ReservoirDataModel/RigCaseCellResultCalculator.cpp index a58355aacc..3e448c52c3 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseCellResultCalculator.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCaseCellResultCalculator.cpp @@ -44,22 +44,22 @@ bool RigCaseCellResultCalculator::computeDifference(RigEclipseCaseData* const RigEclipseResultAddress& address) { CVF_ASSERT(address.isValid()); - CVF_ASSERT(address.hasDifferenceCase()); + CVF_ASSERT(address.hasDifferenceCase() || address.isTimeLapse()); // Assume at this stage that data for the case is available // It is up to the caller to make sure the case is read from file - RigEclipseCaseData* baseCase = nullptr; + RigEclipseCaseData* baseCase = sourceCase; + if (address.hasDifferenceCase()) { - auto eclipseCases = RiaApplication::instance()->project()->eclipseCases(); - for (RimEclipseCase* c : eclipseCases) { - if (c->caseId() == address.m_differenceCaseId) + auto eclipseCases = RiaApplication::instance()->project()->eclipseCases(); + for (RimEclipseCase* c : eclipseCases) { - if (c && c->eclipseCaseData()) + if (c && c->caseId() == address.m_differenceCaseId && c->eclipseCaseData()) { - baseCase = c->eclipseCaseData(); + baseCase = c->eclipseCaseData(); } } } diff --git a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp index 62580372bc..aefb4a4bcf 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp @@ -1083,7 +1083,7 @@ size_t RigCaseCellResultsData::findOrLoadKnownScalarResult(const RigEclipseResul RiaDefines::ResultCatType type = resVarAddr.m_resultCatType; QString resultName = resVarAddr.m_resultName; - if (resVarAddr.hasDifferenceCase()) + if (resVarAddr.hasDifferenceCase() || resVarAddr.isTimeLapse()) { if (!RigCaseCellResultCalculator::computeDifference(this->m_ownerCaseData, RiaDefines::MATRIX_MODEL, resVarAddr)) { @@ -1092,48 +1092,6 @@ size_t RigCaseCellResultsData::findOrLoadKnownScalarResult(const RigEclipseResul return scalarResultIndex; } - else if (resVarAddr.isTimeLapse()) - { - RigEclipseResultAddress noneTimeLapseAddress(resVarAddr); - noneTimeLapseAddress.m_timeLapseBaseFrameIdx = RigEclipseResultAddress::NO_TIME_LAPSE; - size_t sourceResultIdx = this->findOrLoadKnownScalarResult(noneTimeLapseAddress); - - if (sourceResultIdx != cvf::UNDEFINED_SIZE_T) - { - std::vector< std::vector > & srcFrames = m_cellScalarResults[sourceResultIdx]; - std::vector< std::vector > & dstFrames = m_cellScalarResults[scalarResultIndex]; - - size_t baseFrameIdx = resVarAddr.m_timeLapseBaseFrameIdx; - size_t frameCount = srcFrames.size(); - - if (!(baseFrameIdx < frameCount )) - { - dstFrames.clear(); - return scalarResultIndex; - } - - std::vector& srcBaseVals = srcFrames[baseFrameIdx]; - - dstFrames.resize(frameCount); - - for (size_t fIdx = 0; fIdx < frameCount; ++fIdx) - { - std::vector& srcVals = srcFrames[fIdx]; - - std::vector& dstVals = dstFrames[fIdx]; - dstVals.resize(srcVals.size(), std::numeric_limits::infinity()); - size_t valCount = srcVals.size(); - - //#pragma omp parallel for - for (long vIdx = 0; vIdx < static_cast(valCount); ++vIdx) - { - dstVals[vIdx] = srcVals[vIdx] - srcBaseVals[vIdx]; - } - } - } - - return scalarResultIndex; - } // Load dependency data sets