From a4d7e369ebcbb8938ef2e706e6048124a592dfbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Wed, 4 Nov 2015 15:44:09 +0100 Subject: [PATCH] (#606)(#607) Added option to show 3D-info statistics pr. time step. --- .../RigFemPartResultsCollection.cpp | 24 +++ .../RigFemPartResultsCollection.h | 5 +- .../Rim3dOverlayInfoConfig.cpp | 112 ++++++++---- .../RigCaseCellResultsData.cpp | 24 +++ .../RigCaseCellResultsData.h | 3 + .../RigStatisticsDataCache.cpp | 159 +++++++++++------- .../RigStatisticsDataCache.h | 57 +++++-- 7 files changed, 274 insertions(+), 110 deletions(-) diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp index 8421d1dcc4..493f626c54 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp @@ -781,6 +781,14 @@ void RigFemPartResultsCollection::meanScalarValue(const RigFemResultAddress& res this->statistics(resVarAddr)->meanCellScalarValues(*meanValue); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFemPartResultsCollection::meanScalarValue(const RigFemResultAddress& resVarAddr, int frameIndex, double* meanValue) +{ + this->statistics(resVarAddr)->meanCellScalarValues(frameIndex, *meanValue); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -789,6 +797,14 @@ void RigFemPartResultsCollection::p10p90ScalarValues(const RigFemResultAddress& this->statistics(resVarAddr)->p10p90CellScalarValues(*p10, *p90); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFemPartResultsCollection::p10p90ScalarValues(const RigFemResultAddress& resVarAddr, int frameIndex, double* p10, double* p90) +{ + this->statistics(resVarAddr)->p10p90CellScalarValues(frameIndex, *p10, *p90); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -797,3 +813,11 @@ const std::vector& RigFemPartResultsCollection::scalarValuesHistogram(co return this->statistics(resVarAddr)->cellScalarValuesHistogram(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const std::vector& RigFemPartResultsCollection::scalarValuesHistogram(const RigFemResultAddress& resVarAddr, int frameIndex) +{ + return this->statistics(resVarAddr)->cellScalarValuesHistogram(frameIndex); +} + diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h index 48dd83b91e..8980de73c3 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h @@ -48,12 +48,15 @@ public: void minMaxScalarValues (const RigFemResultAddress& resVarAddr, int frameIndex, double* localMin, double* localMax); - void posNegClosestToZero(const RigFemResultAddress& resVarAddr, int frameIndex, double* localPosClosestToZero, double* localNegClosestToZero); void minMaxScalarValues (const RigFemResultAddress& resVarAddr, double* globalMin, double* globalMax); + void posNegClosestToZero(const RigFemResultAddress& resVarAddr, int frameIndex, double* localPosClosestToZero, double* localNegClosestToZero); void posNegClosestToZero(const RigFemResultAddress& resVarAddr, double* globalPosClosestToZero, double* globalNegClosestToZero); void meanScalarValue(const RigFemResultAddress& resVarAddr, double* meanValue); + 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); const std::vector& scalarValuesHistogram(const RigFemResultAddress& resVarAddr); + const std::vector& scalarValuesHistogram(const RigFemResultAddress& resVarAddr, int frameIndex); private: RigFemScalarResultFrames* findOrLoadScalarResult(int partIndex, diff --git a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp index f80ce53311..a22a6bf821 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp @@ -89,6 +89,7 @@ Rim3dOverlayInfoConfig::Rim3dOverlayInfoConfig() CAF_PDM_InitFieldNoDefault(&m_statisticsTimeRange, "StatisticsTimeRange", "Statistics Time Range", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_statisticsCellRange, "StatisticsCellRange", "Statistics Cell Range", "", "", ""); + m_statisticsCellRange.uiCapability()->setUiHidden(true); } //-------------------------------------------------------------------------------------------------- @@ -220,9 +221,9 @@ void Rim3dOverlayInfoConfig::updateEclipse3DInfo(RimEclipseView * reservoirView) if (m_statisticsCellRange == ALL_CELLS) { - double min, max; - double p10, p90; - double mean; + double min = HUGE_VAL, max = HUGE_VAL; + double p10 = HUGE_VAL, p90 = HUGE_VAL; + double mean = HUGE_VAL; size_t scalarIndex = reservoirView->cellResult()->scalarResultIndex(); @@ -236,11 +237,8 @@ void Rim3dOverlayInfoConfig::updateEclipse3DInfo(RimEclipseView * reservoirView) { int timeStepIdx = reservoirView->currentTimeStep(); reservoirView->currentGridCellResults()->cellResults()->minMaxCellScalarValues(scalarIndex, timeStepIdx, min, max); - //reservoirView->currentGridCellResults()->cellResults()->p10p90CellScalarValues(scalarIndex, timeStepIdx, p10, p90); - //reservoirView->currentGridCellResults()->cellResults()->meanCellScalarValues(scalarIndex, timeStepIdx, mean); - p10 = HUGE_VAL; - p90 = HUGE_VAL; - mean = HUGE_VAL; + reservoirView->currentGridCellResults()->cellResults()->p10p90CellScalarValues(scalarIndex, timeStepIdx, p10, p90); + reservoirView->currentGridCellResults()->cellResults()->meanCellScalarValues(scalarIndex, timeStepIdx, mean); } infoText += QString("" @@ -309,20 +307,38 @@ void Rim3dOverlayInfoConfig::updateEclipse3DInfo(RimEclipseView * reservoirView) { if (reservoirView->hasUserRequestedAnimation() && reservoirView->cellResult()->hasResult()) { - if (m_statisticsCellRange == ALL_CELLS && m_statisticsTimeRange == ALL_TIMESTEPS) + if (m_statisticsCellRange == ALL_CELLS) { - double min, max; - double p10, p90; - double mean; + double min = HUGE_VAL, max = HUGE_VAL; + double p10 = HUGE_VAL, p90 = HUGE_VAL; + double mean = HUGE_VAL; + const std::vector* histogram = NULL; - size_t scalarIndex = reservoirView->cellResult()->scalarResultIndex(); - reservoirView->currentGridCellResults()->cellResults()->minMaxCellScalarValues(scalarIndex, min, max); - reservoirView->currentGridCellResults()->cellResults()->p10p90CellScalarValues(scalarIndex, p10, p90); - reservoirView->currentGridCellResults()->cellResults()->meanCellScalarValues(scalarIndex, mean); + size_t scalarIndex = reservoirView->cellResult()->scalarResultIndex(); - reservoirView->viewer()->showHistogram(true); - reservoirView->viewer()->setHistogram(min, max, reservoirView->currentGridCellResults()->cellResults()->cellScalarValuesHistogram(scalarIndex)); - reservoirView->viewer()->setHistogramPercentiles(p10, p90, mean); + if (m_statisticsTimeRange == ALL_TIMESTEPS) + { + reservoirView->currentGridCellResults()->cellResults()->minMaxCellScalarValues(scalarIndex, min, max); + reservoirView->currentGridCellResults()->cellResults()->p10p90CellScalarValues(scalarIndex, p10, p90); + reservoirView->currentGridCellResults()->cellResults()->meanCellScalarValues(scalarIndex, mean); + histogram = &(reservoirView->currentGridCellResults()->cellResults()->cellScalarValuesHistogram(scalarIndex)); + } + else if (m_statisticsTimeRange == CURRENT_TIMESTEP ) + { + int timeStepIdx = reservoirView->currentTimeStep(); + reservoirView->currentGridCellResults()->cellResults()->minMaxCellScalarValues(scalarIndex, timeStepIdx, min, max); + reservoirView->currentGridCellResults()->cellResults()->p10p90CellScalarValues(scalarIndex, timeStepIdx, p10, p90); + reservoirView->currentGridCellResults()->cellResults()->meanCellScalarValues(scalarIndex, timeStepIdx, mean); + histogram = &(reservoirView->currentGridCellResults()->cellResults()->cellScalarValuesHistogram(scalarIndex, timeStepIdx)); + } + else + { + CVF_ASSERT(false); + } + + reservoirView->viewer()->showHistogram(true); + reservoirView->viewer()->setHistogram(min, max, *histogram); + reservoirView->viewer()->setHistogramPercentiles(p10, p90, mean); } } } @@ -379,14 +395,25 @@ void Rim3dOverlayInfoConfig::updateGeoMech3DInfo(RimGeoMechView * geoMechView) infoText += QString("Cell result: %1, %2, %3").arg(resultPos).arg(fieldName).arg(compName); - double min = 0, max = 0; - double p10 = 0, p90 = 0; - double mean = 0; - + double min = HUGE_VAL, max = HUGE_VAL; + double p10 = HUGE_VAL, p90 = HUGE_VAL; + double mean = HUGE_VAL; + RigFemResultAddress resAddress = geoMechView->cellResult()->resultAddress(); - caseData->femPartResults()->meanScalarValue(resAddress, &mean); - caseData->femPartResults()->minMaxScalarValues(resAddress,&min, &max); - caseData->femPartResults()->p10p90ScalarValues(resAddress, &p10, &p90); + + if (m_statisticsTimeRange == ALL_TIMESTEPS) + { + caseData->femPartResults()->meanScalarValue (resAddress, &mean); + caseData->femPartResults()->minMaxScalarValues(resAddress,&min, &max); + caseData->femPartResults()->p10p90ScalarValues(resAddress, &p10, &p90); + } + else if (m_statisticsTimeRange == CURRENT_TIMESTEP) + { + int timeStepIdx = geoMechView->currentTimeStep(); + caseData->femPartResults()->meanScalarValue (resAddress, timeStepIdx, &mean); + caseData->femPartResults()->minMaxScalarValues(resAddress, timeStepIdx, &min, &max); + caseData->femPartResults()->p10p90ScalarValues(resAddress, timeStepIdx, &p10, &p90); + } infoText += QString("
" "" @@ -420,15 +447,34 @@ void Rim3dOverlayInfoConfig::updateGeoMech3DInfo(RimGeoMechView * geoMechView) if (caseData) { - double min = 0, max = 0; - double p10 = 0, p90 = 0; - double mean = 0; + double min = HUGE_VAL, max = HUGE_VAL; + double p10 = HUGE_VAL, p90 = HUGE_VAL; + double mean = HUGE_VAL; + const std::vector* histogram = NULL; RigFemResultAddress resAddress = geoMechView->cellResult()->resultAddress(); - caseData->femPartResults()->meanScalarValue(resAddress, &mean); - caseData->femPartResults()->minMaxScalarValues(resAddress, &min, &max); - caseData->femPartResults()->p10p90ScalarValues(resAddress, &p10, &p90); - geoMechView->viewer()->setHistogram(min, max, caseData->femPartResults()->scalarValuesHistogram(resAddress)); + + if (m_statisticsTimeRange == ALL_TIMESTEPS) + { + caseData->femPartResults()->meanScalarValue(resAddress, &mean); + caseData->femPartResults()->minMaxScalarValues(resAddress, &min, &max); + caseData->femPartResults()->p10p90ScalarValues(resAddress, &p10, &p90); + histogram = &(caseData->femPartResults()->scalarValuesHistogram(resAddress)); + } + else if (m_statisticsTimeRange == CURRENT_TIMESTEP) + { + int timeStepIdx = geoMechView->currentTimeStep(); + caseData->femPartResults()->meanScalarValue(resAddress, timeStepIdx, &mean); + caseData->femPartResults()->minMaxScalarValues(resAddress, timeStepIdx, &min, &max); + caseData->femPartResults()->p10p90ScalarValues(resAddress, timeStepIdx, &p10, &p90); + histogram = &(caseData->femPartResults()->scalarValuesHistogram(resAddress, timeStepIdx)); + } + else + { + CVF_ASSERT(false); + } + + geoMechView->viewer()->setHistogram(min, max, *histogram); geoMechView->viewer()->setHistogramPercentiles(p10, p90, mean); } } diff --git a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp index 10e2a61c47..885b24d48e 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp @@ -87,6 +87,14 @@ const std::vector& RigCaseCellResultsData::cellScalarValuesHistogram(siz return m_statisticsDataCache[scalarResultIndex]->cellScalarValuesHistogram(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const std::vector& RigCaseCellResultsData::cellScalarValuesHistogram(size_t scalarResultIndex, size_t timeStepIndex) +{ + return m_statisticsDataCache[scalarResultIndex]->cellScalarValuesHistogram(timeStepIndex); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -95,6 +103,14 @@ void RigCaseCellResultsData::p10p90CellScalarValues(size_t scalarResultIndex, do m_statisticsDataCache[scalarResultIndex]->p10p90CellScalarValues(p10, p90); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigCaseCellResultsData::p10p90CellScalarValues(size_t scalarResultIndex, size_t timeStepIndex, double& p10, double& p90) +{ + m_statisticsDataCache[scalarResultIndex]->p10p90CellScalarValues(timeStepIndex, p10, p90); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -103,6 +119,14 @@ void RigCaseCellResultsData::meanCellScalarValues(size_t scalarResultIndex, doub m_statisticsDataCache[scalarResultIndex]->meanCellScalarValues(meanValue); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigCaseCellResultsData::meanCellScalarValues(size_t scalarResultIndex, size_t timeStepIndex, double& meanValue) +{ + m_statisticsDataCache[scalarResultIndex]->meanCellScalarValues(timeStepIndex, meanValue); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h index a772be7f47..901b57d224 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h +++ b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h @@ -54,8 +54,11 @@ public: void posNegClosestToZero(size_t scalarResultIndex, double& pos, double& neg); void posNegClosestToZero(size_t scalarResultIndex, size_t timeStepIndex, double& pos, double& neg); const std::vector& cellScalarValuesHistogram(size_t scalarResultIndex); + const std::vector& cellScalarValuesHistogram(size_t scalarResultIndex, size_t timeStepIndex); void p10p90CellScalarValues(size_t scalarResultIndex, double& p10, double& p90); + 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); // Access meta-information about the results size_t resultCount() const; diff --git a/ApplicationCode/ResultStatisticsCache/RigStatisticsDataCache.cpp b/ApplicationCode/ResultStatisticsCache/RigStatisticsDataCache.cpp index 5b4a7182b4..dff04de95e 100644 --- a/ApplicationCode/ResultStatisticsCache/RigStatisticsDataCache.cpp +++ b/ApplicationCode/ResultStatisticsCache/RigStatisticsDataCache.cpp @@ -39,20 +39,8 @@ RigStatisticsDataCache::RigStatisticsDataCache(RigStatisticsCalculator* statisti //-------------------------------------------------------------------------------------------------- void RigStatisticsDataCache::clearAllStatistics() { - m_minValue = HUGE_VAL; - m_maxValue = -HUGE_VAL; - m_isMaxMinCalculated = false; - m_posClosestToZero = HUGE_VAL; - m_negClosestToZero = -HUGE_VAL; - m_isClosestToZeroCalculated = false; - m_p10 = HUGE_VAL; - m_p90 = HUGE_VAL; - m_meanValue = HUGE_VAL; - m_isMeanCalculated = false; - - m_histogram.clear(); - m_maxMinValuesPrTs.clear(); - m_posNegClosestToZeroPrTs.clear(); + m_statsAllTimesteps = StatisticsValues(); + m_statsPrTs.clear(); } //-------------------------------------------------------------------------------------------------- @@ -60,7 +48,7 @@ void RigStatisticsDataCache::clearAllStatistics() //-------------------------------------------------------------------------------------------------- void RigStatisticsDataCache::minMaxCellScalarValues(double& min, double& max) { - if (!m_isMaxMinCalculated) + if (!m_statsAllTimesteps.m_isMaxMinCalculated) { min = HUGE_VAL; max = -HUGE_VAL; @@ -74,13 +62,13 @@ void RigStatisticsDataCache::minMaxCellScalarValues(double& min, double& max) if (tsmax > max) max = tsmax; } - m_minValue = min; - m_maxValue = max; - m_isMaxMinCalculated = true; + m_statsAllTimesteps.m_minValue = min; + m_statsAllTimesteps.m_maxValue = max; + m_statsAllTimesteps.m_isMaxMinCalculated = true; } - min = m_minValue; - max = m_maxValue; + min = m_statsAllTimesteps.m_minValue; + max = m_statsAllTimesteps.m_maxValue; } //-------------------------------------------------------------------------------------------------- @@ -88,27 +76,26 @@ void RigStatisticsDataCache::minMaxCellScalarValues(double& min, double& max) //-------------------------------------------------------------------------------------------------- void RigStatisticsDataCache::minMaxCellScalarValues(size_t timeStepIndex, double& min, double& max) { - if (timeStepIndex >= m_maxMinValuesPrTs.size()) + if (timeStepIndex >= m_statsPrTs.size()) { - m_maxMinValuesPrTs.resize(timeStepIndex + 1, std::make_pair(HUGE_VAL, -HUGE_VAL)); - m_isMaxMinPrTsCalculated.resize(timeStepIndex + 1, false); + m_statsPrTs.resize(timeStepIndex + 1); } - if (!m_isMaxMinPrTsCalculated[timeStepIndex]) + if (!m_statsPrTs[timeStepIndex].m_isMaxMinCalculated) { double tsMin = HUGE_VAL; double tsMax = -HUGE_VAL; m_statisticsCalculator->minMaxCellScalarValues(timeStepIndex, tsMin, tsMax); - m_maxMinValuesPrTs[timeStepIndex].first = tsMin; - m_maxMinValuesPrTs[timeStepIndex].second = tsMax; + m_statsPrTs[timeStepIndex].m_minValue = tsMin; + m_statsPrTs[timeStepIndex].m_maxValue = tsMax; - m_isMaxMinPrTsCalculated[timeStepIndex] = true; + m_statsPrTs[timeStepIndex].m_isMaxMinCalculated = true; } - min = m_maxMinValuesPrTs[timeStepIndex].first; - max = m_maxMinValuesPrTs[timeStepIndex].second; + min = m_statsPrTs[timeStepIndex].m_minValue; + max = m_statsPrTs[timeStepIndex].m_maxValue; } //-------------------------------------------------------------------------------------------------- @@ -116,7 +103,7 @@ void RigStatisticsDataCache::minMaxCellScalarValues(size_t timeStepIndex, double //-------------------------------------------------------------------------------------------------- void RigStatisticsDataCache::posNegClosestToZero(double& pos, double& neg) { - if (!m_isClosestToZeroCalculated) + if (!m_statsAllTimesteps.m_isClosestToZeroCalculated) { pos = HUGE_VAL; neg = -HUGE_VAL; @@ -130,13 +117,13 @@ void RigStatisticsDataCache::posNegClosestToZero(double& pos, double& neg) if (tsPos < pos && tsPos > 0) pos = tsPos; } - m_posClosestToZero = pos; - m_negClosestToZero = neg; - m_isClosestToZeroCalculated = true; + m_statsAllTimesteps.m_posClosestToZero = pos; + m_statsAllTimesteps.m_negClosestToZero = neg; + m_statsAllTimesteps.m_isClosestToZeroCalculated = true; } - pos = m_posClosestToZero; - neg = m_negClosestToZero; + pos = m_statsAllTimesteps.m_posClosestToZero; + neg = m_statsAllTimesteps.m_negClosestToZero; } //-------------------------------------------------------------------------------------------------- @@ -144,13 +131,12 @@ void RigStatisticsDataCache::posNegClosestToZero(double& pos, double& neg) //-------------------------------------------------------------------------------------------------- void RigStatisticsDataCache::posNegClosestToZero(size_t timeStepIndex, double& posNearZero, double& negNearZero) { - if (timeStepIndex >= m_posNegClosestToZeroPrTs.size()) + if (timeStepIndex >= m_statsPrTs.size()) { - m_posNegClosestToZeroPrTs.resize(timeStepIndex + 1, std::make_pair(HUGE_VAL, -HUGE_VAL)); - m_isClosestToZeroPrTsCalculated.resize(timeStepIndex + 1, false); + m_statsPrTs.resize(timeStepIndex + 1); } - if (!m_isClosestToZeroPrTsCalculated[timeStepIndex]) + if (!m_statsPrTs[timeStepIndex].m_isClosestToZeroCalculated) { double pos = HUGE_VAL; @@ -158,14 +144,14 @@ void RigStatisticsDataCache::posNegClosestToZero(size_t timeStepIndex, double& p m_statisticsCalculator->posNegClosestToZero(timeStepIndex, pos, neg); - m_posNegClosestToZeroPrTs[timeStepIndex].first = pos; - m_posNegClosestToZeroPrTs[timeStepIndex].second = neg; + m_statsPrTs[timeStepIndex].m_posClosestToZero = pos; + m_statsPrTs[timeStepIndex].m_negClosestToZero = neg; - m_isClosestToZeroPrTsCalculated[timeStepIndex] = true; + m_statsPrTs[timeStepIndex].m_isClosestToZeroCalculated = true; } - posNearZero = m_posNegClosestToZeroPrTs[timeStepIndex].first; - negNearZero = m_posNegClosestToZeroPrTs[timeStepIndex].second; + posNearZero = m_statsPrTs[timeStepIndex].m_posClosestToZero; + negNearZero = m_statsPrTs[timeStepIndex].m_negClosestToZero; } //-------------------------------------------------------------------------------------------------- @@ -173,9 +159,19 @@ void RigStatisticsDataCache::posNegClosestToZero(size_t timeStepIndex, double& p //-------------------------------------------------------------------------------------------------- const std::vector& RigStatisticsDataCache::cellScalarValuesHistogram() { - computeStatisticsIfNeeded(); + computeHistogramStatisticsIfNeeded(); - return m_histogram; + return m_statsAllTimesteps.m_histogram; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const std::vector& RigStatisticsDataCache::cellScalarValuesHistogram(size_t timeStepIndex) +{ + computeHistogramStatisticsIfNeeded(timeStepIndex); + + return m_statsPrTs[timeStepIndex].m_histogram; } //-------------------------------------------------------------------------------------------------- @@ -183,11 +179,21 @@ const std::vector& RigStatisticsDataCache::cellScalarValuesHistogram() //-------------------------------------------------------------------------------------------------- void RigStatisticsDataCache::p10p90CellScalarValues(double& p10, double& p90) { - // First make sure they are calculated - computeStatisticsIfNeeded(); + computeHistogramStatisticsIfNeeded(); - p10 = m_p10; - p90 = m_p90; + p10 = m_statsAllTimesteps.m_p10; + p90 = m_statsAllTimesteps.m_p90; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigStatisticsDataCache::p10p90CellScalarValues(size_t timeStepIndex, double& p10, double& p90) +{ + computeHistogramStatisticsIfNeeded(timeStepIndex); + + p10 = m_statsPrTs[timeStepIndex].m_p10; + p90 = m_statsPrTs[timeStepIndex].m_p90; } //-------------------------------------------------------------------------------------------------- @@ -195,33 +201,68 @@ void RigStatisticsDataCache::p10p90CellScalarValues(double& p10, double& p90) //-------------------------------------------------------------------------------------------------- void RigStatisticsDataCache::meanCellScalarValues(double& meanValue) { - if (!m_isMeanCalculated) + if (!m_statsAllTimesteps.m_isMeanCalculated) { - m_statisticsCalculator->meanCellScalarValue(m_meanValue); - m_isMeanCalculated = true; + m_statisticsCalculator->meanCellScalarValue(m_statsAllTimesteps.m_meanValue); + m_statsAllTimesteps.m_isMeanCalculated = true; } - meanValue = m_meanValue; + meanValue = m_statsAllTimesteps.m_meanValue; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigStatisticsDataCache::computeStatisticsIfNeeded() +void RigStatisticsDataCache::meanCellScalarValues(size_t timeStepIndex, double& meanValue) { - if (m_histogram.size() == 0) + if (!m_statsPrTs[timeStepIndex].m_isMeanCalculated) + { + m_statisticsCalculator->meanCellScalarValue(timeStepIndex, m_statsPrTs[timeStepIndex].m_meanValue); + m_statsPrTs[timeStepIndex].m_isMeanCalculated = true; + } + + meanValue = m_statsPrTs[timeStepIndex].m_meanValue; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigStatisticsDataCache::computeHistogramStatisticsIfNeeded() +{ + if (m_statsAllTimesteps.m_histogram.size() == 0) { double min; double max; size_t nBins = 100; this->minMaxCellScalarValues(min, max); - RigHistogramCalculator histCalc(min, max, nBins, &m_histogram); + RigHistogramCalculator histCalc(min, max, nBins, &m_statsAllTimesteps.m_histogram); m_statisticsCalculator->addDataToHistogramCalculator(histCalc); - m_p10 = histCalc.calculatePercentil(0.1); - m_p90 = histCalc.calculatePercentil(0.9); + m_statsAllTimesteps.m_p10 = histCalc.calculatePercentil(0.1); + m_statsAllTimesteps.m_p90 = histCalc.calculatePercentil(0.9); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigStatisticsDataCache::computeHistogramStatisticsIfNeeded(size_t timeStepIndex) +{ + if (m_statsPrTs[timeStepIndex].m_histogram.size() == 0) + { + double min; + double max; + size_t nBins = 100; + this->minMaxCellScalarValues(min, max); + + RigHistogramCalculator histCalc(min, max, nBins, &m_statsPrTs[timeStepIndex].m_histogram); + + m_statisticsCalculator->addDataToHistogramCalculator(timeStepIndex, histCalc); + + m_statsPrTs[timeStepIndex].m_p10 = histCalc.calculatePercentil(0.1); + m_statsPrTs[timeStepIndex].m_p90 = histCalc.calculatePercentil(0.9); } } diff --git a/ApplicationCode/ResultStatisticsCache/RigStatisticsDataCache.h b/ApplicationCode/ResultStatisticsCache/RigStatisticsDataCache.h index ae4c262f35..4926a0a68c 100644 --- a/ApplicationCode/ResultStatisticsCache/RigStatisticsDataCache.h +++ b/ApplicationCode/ResultStatisticsCache/RigStatisticsDataCache.h @@ -39,37 +39,60 @@ public: void minMaxCellScalarValues(double& min, double& max); void minMaxCellScalarValues(size_t timeStepIndex, double& min, double& max); + void posNegClosestToZero(double& pos, double& neg); void posNegClosestToZero(size_t timeStepIndex, double& pos, double& neg); void p10p90CellScalarValues(double& p10, double& p90); + void p10p90CellScalarValues(size_t timeStepIndex, double& p10, double& p90); + void meanCellScalarValues(double& meanValue); + void meanCellScalarValues(size_t timeStepIndex, double& meanValue); + const std::vector& cellScalarValuesHistogram(); + const std::vector& cellScalarValuesHistogram(size_t timeStepIndex); private: - void computeStatisticsIfNeeded(); + void computeHistogramStatisticsIfNeeded(); + void computeHistogramStatisticsIfNeeded(size_t timeStepIndex); private: - double m_minValue; - double m_maxValue; - bool m_isMaxMinCalculated; + struct StatisticsValues + { + StatisticsValues() + { + m_minValue = HUGE_VAL; + m_maxValue = -HUGE_VAL; + m_isMaxMinCalculated = false; + m_meanValue = HUGE_VAL; + m_isMeanCalculated = false; + m_posClosestToZero = HUGE_VAL; + m_negClosestToZero = -HUGE_VAL; + m_isClosestToZeroCalculated = false; + m_p10 = HUGE_VAL; + m_p90 = HUGE_VAL; + } - double m_posClosestToZero; - double m_negClosestToZero; - bool m_isClosestToZeroCalculated; + double m_minValue; + double m_maxValue; + bool m_isMaxMinCalculated; + + double m_meanValue; + bool m_isMeanCalculated; - double m_p10; - double m_p90; - double m_meanValue; - bool m_isMeanCalculated; + double m_posClosestToZero; + double m_negClosestToZero; + bool m_isClosestToZeroCalculated; + + double m_p10; + double m_p90; - std::vector m_histogram; + std::vector m_histogram; + }; - std::vector > m_maxMinValuesPrTs; ///< Max min values for each time step - std::vector m_isMaxMinPrTsCalculated; - std::vector > m_posNegClosestToZeroPrTs; ///< PosNeg values for each time step - std::vector m_isClosestToZeroPrTsCalculated; + StatisticsValues m_statsAllTimesteps; + std::vector m_statsPrTs; - cvf::ref m_statisticsCalculator; + cvf::ref m_statisticsCalculator; };
Min P10 Mean P90 Max