diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp index 763ad3626a..73dda88c79 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp @@ -805,6 +805,26 @@ void RigFemPartResultsCollection::p10p90ScalarValues(const RigFemResultAddress& this->statistics(resVarAddr)->p10p90CellScalarValues(frameIndex, *p10, *p90); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFemPartResultsCollection::sumScalarValue(const RigFemResultAddress& resVarAddr, double* sum) +{ + CVF_ASSERT(sum); + + this->statistics(resVarAddr)->sumCellScalarValues(*sum); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFemPartResultsCollection::sumScalarValue(const RigFemResultAddress& resVarAddr, int frameIndex, double* sum) +{ + CVF_ASSERT(sum); + + this->statistics(resVarAddr)->sumCellScalarValues(frameIndex, *sum); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h index fe02ace9d8..d2c97668b2 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h @@ -55,6 +55,8 @@ public: void meanScalarValue(const RigFemResultAddress& resVarAddr, int frameIndex, double* meanValue); void p10p90ScalarValues(const RigFemResultAddress& resVarAddr, double* p10, double* p90); void p10p90ScalarValues(const RigFemResultAddress& resVarAddr, int frameIndex, double* p10, double* p90); + void sumScalarValue(const RigFemResultAddress& resVarAddr, double* sum); + void sumScalarValue(const RigFemResultAddress& resVarAddr, int frameIndex, double* sum); const std::vector& scalarValuesHistogram(const RigFemResultAddress& resVarAddr); const std::vector& scalarValuesHistogram(const RigFemResultAddress& resVarAddr, int frameIndex); diff --git a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp index f7f0969899..9a40a41d33 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp @@ -197,6 +197,7 @@ void Rim3dOverlayInfoConfig::updateEclipse3DInfo(RimEclipseView * eclipseView) double min = HUGE_VAL, max = HUGE_VAL; double p10 = HUGE_VAL, p90 = HUGE_VAL; double mean = HUGE_VAL; + double sum = 0.0; const std::vector* histogram = NULL; bool isResultsInfoRelevant = eclipseView->hasUserRequestedAnimation() && eclipseView->cellResult()->hasResult(); @@ -213,6 +214,7 @@ void Rim3dOverlayInfoConfig::updateEclipse3DInfo(RimEclipseView * eclipseView) eclipseView->currentGridCellResults()->cellResults()->minMaxCellScalarValues(scalarIndex, min, max); eclipseView->currentGridCellResults()->cellResults()->p10p90CellScalarValues(scalarIndex, p10, p90); eclipseView->currentGridCellResults()->cellResults()->meanCellScalarValues(scalarIndex, mean); + eclipseView->currentGridCellResults()->cellResults()->sumCellScalarValues(scalarIndex, sum); histogram = &(eclipseView->currentGridCellResults()->cellResults()->cellScalarValuesHistogram(scalarIndex)); } else if (m_statisticsTimeRange == CURRENT_TIMESTEP ) @@ -220,7 +222,8 @@ void Rim3dOverlayInfoConfig::updateEclipse3DInfo(RimEclipseView * eclipseView) int timeStepIdx = eclipseView->currentTimeStep(); eclipseView->currentGridCellResults()->cellResults()->minMaxCellScalarValues(scalarIndex, timeStepIdx, min, max); eclipseView->currentGridCellResults()->cellResults()->p10p90CellScalarValues(scalarIndex, timeStepIdx, p10, p90); - eclipseView->currentGridCellResults()->cellResults()->meanCellScalarValues(scalarIndex, timeStepIdx, mean); + eclipseView->currentGridCellResults()->cellResults()->meanCellScalarValues(scalarIndex, timeStepIdx, mean); + eclipseView->currentGridCellResults()->cellResults()->sumCellScalarValues(scalarIndex, timeStepIdx, sum); histogram = &(eclipseView->currentGridCellResults()->cellResults()->cellScalarValuesHistogram(scalarIndex, timeStepIdx)); } else @@ -237,6 +240,7 @@ void Rim3dOverlayInfoConfig::updateEclipse3DInfo(RimEclipseView * eclipseView) m_visibleCellStatistics->meanCellScalarValues(mean); m_visibleCellStatistics->minMaxCellScalarValues(min, max); m_visibleCellStatistics->p10p90CellScalarValues(p10, p90); + m_visibleCellStatistics->sumCellScalarValues(sum); histogram = &(m_visibleCellStatistics->cellScalarValuesHistogram()); } @@ -246,6 +250,7 @@ void Rim3dOverlayInfoConfig::updateEclipse3DInfo(RimEclipseView * eclipseView) m_visibleCellStatistics->meanCellScalarValues(currentTimeStep, mean); m_visibleCellStatistics->minMaxCellScalarValues(currentTimeStep, min, max); m_visibleCellStatistics->p10p90CellScalarValues(currentTimeStep, p10, p90); + m_visibleCellStatistics->sumCellScalarValues(currentTimeStep, sum); histogram = &(m_visibleCellStatistics->cellScalarValuesHistogram(currentTimeStep)); } @@ -303,9 +308,9 @@ void Rim3dOverlayInfoConfig::updateEclipse3DInfo(RimEclipseView * eclipseView) infoText += QString("Cell Property: %1 ").arg(propName); infoText += QString("
Statistics: ") + m_statisticsTimeRange().uiText() + " and " + m_statisticsCellRange().uiText(); infoText += QString("" - "" - "" - "
Min P10 Mean P90 Max
%1 %2 %3 %4 %5
").arg(min).arg(p10).arg(mean).arg(p90).arg(max); + " Min P10 Mean P90 Max Sum " + " %1 %2 %3 %4 %5 %6 " + "").arg(min).arg(p10).arg(mean).arg(p90).arg(max).arg(sum); if (eclipseView->faultResultSettings()->hasValidCustomResult()) { @@ -381,6 +386,7 @@ void Rim3dOverlayInfoConfig::updateGeoMech3DInfo(RimGeoMechView * geoMechView) double min = HUGE_VAL, max = HUGE_VAL; double p10 = HUGE_VAL, p90 = HUGE_VAL; double mean = HUGE_VAL; + double sum = 0.0; const std::vector* histogram = NULL; if (showResultInfo() || showHistogram()) @@ -395,6 +401,7 @@ void Rim3dOverlayInfoConfig::updateGeoMech3DInfo(RimGeoMechView * geoMechView) caseData->femPartResults()->meanScalarValue(resAddress, &mean); caseData->femPartResults()->minMaxScalarValues(resAddress, &min, &max); caseData->femPartResults()->p10p90ScalarValues(resAddress, &p10, &p90); + caseData->femPartResults()->sumScalarValue(resAddress, &sum); histogram = &(caseData->femPartResults()->scalarValuesHistogram(resAddress)); } @@ -404,6 +411,7 @@ void Rim3dOverlayInfoConfig::updateGeoMech3DInfo(RimGeoMechView * geoMechView) caseData->femPartResults()->meanScalarValue(resAddress, timeStepIdx, &mean); caseData->femPartResults()->minMaxScalarValues(resAddress, timeStepIdx, &min, &max); caseData->femPartResults()->p10p90ScalarValues(resAddress, timeStepIdx, &p10, &p90); + caseData->femPartResults()->sumScalarValue(resAddress, timeStepIdx, &sum); histogram = &(caseData->femPartResults()->scalarValuesHistogram(resAddress, timeStepIdx)); } @@ -418,6 +426,7 @@ void Rim3dOverlayInfoConfig::updateGeoMech3DInfo(RimGeoMechView * geoMechView) m_visibleCellStatistics->meanCellScalarValues(mean); m_visibleCellStatistics->minMaxCellScalarValues(min, max); m_visibleCellStatistics->p10p90CellScalarValues(p10, p90); + m_visibleCellStatistics->sumCellScalarValues(sum); histogram = &(m_visibleCellStatistics->cellScalarValuesHistogram()); } @@ -427,6 +436,7 @@ void Rim3dOverlayInfoConfig::updateGeoMech3DInfo(RimGeoMechView * geoMechView) m_visibleCellStatistics->meanCellScalarValues(timeStepIdx, mean); m_visibleCellStatistics->minMaxCellScalarValues(timeStepIdx, min, max); m_visibleCellStatistics->p10p90CellScalarValues(timeStepIdx, p10, p90); + m_visibleCellStatistics->sumCellScalarValues(timeStepIdx, sum); histogram = &(m_visibleCellStatistics->cellScalarValuesHistogram(timeStepIdx)); } @@ -488,10 +498,9 @@ void Rim3dOverlayInfoConfig::updateGeoMech3DInfo(RimGeoMechView * geoMechView) { infoText += QString("
Statistics: ") + m_statisticsTimeRange().uiText() + " and " + m_statisticsCellRange().uiText(); infoText += QString("" - "" - "" - "
Min P10 Mean P90 Max
%1 %2 %3 %4 %5
").arg(min).arg(p10).arg(mean).arg(p90).arg(max); - + " Min P10 Mean P90 Max Sum " + " %1 %2 %3 %4 %5 %6 " + "").arg(min).arg(p10).arg(mean).arg(p90).arg(max).arg(sum); } } diff --git a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp index df4291934e..2ff69a597c 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp @@ -127,6 +127,22 @@ void RigCaseCellResultsData::meanCellScalarValues(size_t scalarResultIndex, size m_statisticsDataCache[scalarResultIndex]->meanCellScalarValues(timeStepIndex, meanValue); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigCaseCellResultsData::sumCellScalarValues(size_t scalarResultIndex, double& sumValue) +{ + m_statisticsDataCache[scalarResultIndex]->sumCellScalarValues(sumValue); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigCaseCellResultsData::sumCellScalarValues(size_t scalarResultIndex, size_t timeStepIndex, double& sumValue) +{ + m_statisticsDataCache[scalarResultIndex]->sumCellScalarValues(timeStepIndex, sumValue); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h index 901b57d224..1f8230bfab 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h +++ b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h @@ -59,6 +59,8 @@ public: void p10p90CellScalarValues(size_t scalarResultIndex, size_t timeStepIndex, double& p10, double& p90); void meanCellScalarValues(size_t scalarResultIndex, double& meanValue); void meanCellScalarValues(size_t scalarResultIndex, size_t timeStepIndex, double& meanValue); + void sumCellScalarValues(size_t scalarResultIndex, double& sumValue); + void sumCellScalarValues(size_t scalarResultIndex, size_t timeStepIndex, double& sumValue); // Access meta-information about the results size_t resultCount() const; diff --git a/ApplicationCode/ResultStatisticsCache/RigStatisticsDataCache.cpp b/ApplicationCode/ResultStatisticsCache/RigStatisticsDataCache.cpp index acb1947449..cec5859502 100644 --- a/ApplicationCode/ResultStatisticsCache/RigStatisticsDataCache.cpp +++ b/ApplicationCode/ResultStatisticsCache/RigStatisticsDataCache.cpp @@ -190,6 +190,51 @@ void RigStatisticsDataCache::meanCellScalarValues(size_t timeStepIndex, double& } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigStatisticsDataCache::sumCellScalarValues(double& sumValue) +{ + if (!m_statsAllTimesteps.m_isValueSumCalculated) + { + double aggregatedSum = 0.0; + for (size_t i = 0; i < m_statisticsCalculator->timeStepCount(); i++) + { + double valueSum = 0.0; + this->sumCellScalarValues(i, valueSum); + + aggregatedSum += valueSum; + } + + m_statsAllTimesteps.m_valueSum = aggregatedSum; + m_statsAllTimesteps.m_isValueSumCalculated = true; + } + + sumValue = m_statsAllTimesteps.m_valueSum; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigStatisticsDataCache::sumCellScalarValues(size_t timeStepIndex, double& sumValue) +{ + if (timeStepIndex >= m_statsPrTs.size()) + { + m_statsPrTs.resize(timeStepIndex + 1); + } + + if (!m_statsPrTs[timeStepIndex].m_isValueSumCalculated) + { + double valueSum = 0.0; + size_t sampleCount = 0; + m_statisticsCalculator->valueSumAndSampleCount(timeStepIndex, valueSum, sampleCount); + m_statsPrTs[timeStepIndex].m_valueSum = valueSum; + m_statsPrTs[timeStepIndex].m_isValueSumCalculated = true; + } + + sumValue = m_statsPrTs[timeStepIndex].m_valueSum; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ResultStatisticsCache/RigStatisticsDataCache.h b/ApplicationCode/ResultStatisticsCache/RigStatisticsDataCache.h index 8b4d3e7cde..6307ab6be9 100644 --- a/ApplicationCode/ResultStatisticsCache/RigStatisticsDataCache.h +++ b/ApplicationCode/ResultStatisticsCache/RigStatisticsDataCache.h @@ -49,6 +49,9 @@ public: void meanCellScalarValues(double& meanValue); void meanCellScalarValues(size_t timeStepIndex, double& meanValue); + void sumCellScalarValues(double& sumValue); + void sumCellScalarValues(size_t timeStepIndex, double& sumValue); + const std::vector& cellScalarValuesHistogram(); const std::vector& cellScalarValuesHistogram(size_t timeStepIndex); @@ -71,6 +74,8 @@ private: m_isClosestToZeroCalculated = false; m_p10 = HUGE_VAL; m_p90 = HUGE_VAL; + m_valueSum = 0.0; + m_isValueSumCalculated = false; } double m_minValue; @@ -87,6 +92,9 @@ private: double m_p10; double m_p90; + double m_valueSum; + bool m_isValueSumCalculated; + std::vector m_histogram; };