diff --git a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp index a44cee7f38..bfcc9f2c3a 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp @@ -216,7 +216,6 @@ Rim3dOverlayInfoConfig::HistogramData Rim3dOverlayInfoConfig::histogramData(RimE if (scalarIndex != cvf::UNDEFINED_SIZE_T) { - if (m_statisticsCellRange == ALL_CELLS) { if (m_statisticsTimeRange == ALL_TIMESTEPS) @@ -239,6 +238,8 @@ Rim3dOverlayInfoConfig::HistogramData Rim3dOverlayInfoConfig::histogramData(RimE eclipseView->currentGridCellResults()->p10p90CellScalarValues(scalarIndex, currentTimeStep, histData.p10, histData.p90); eclipseView->currentGridCellResults()->meanCellScalarValues(scalarIndex, currentTimeStep, histData.mean); eclipseView->currentGridCellResults()->sumCellScalarValues(scalarIndex, currentTimeStep, histData.sum); + eclipseView->currentGridCellResults()->mobileVolumeWeightedMean(scalarIndex, currentTimeStep, histData.weightedMean); + histData.histogram = &(eclipseView->currentGridCellResults()->cellScalarValuesHistogram(scalarIndex, currentTimeStep)); } else diff --git a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp index c47248108b..3f2daabf3e 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp @@ -165,6 +165,14 @@ void RigCaseCellResultsData::sumCellScalarValues(size_t scalarResultIndex, size_ m_statisticsDataCache[scalarResultIndex]->sumCellScalarValues(timeStepIndex, sumValue); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigCaseCellResultsData::mobileVolumeWeightedMean(size_t scalarResultIndex, size_t timeStepIndex, double& meanValue) +{ + m_statisticsDataCache[scalarResultIndex]->mobileVolumeWeightedMean(timeStepIndex, meanValue); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h index 859604c8ed..e7105faaa7 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h +++ b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h @@ -69,7 +69,7 @@ public: const std::vector& uniqueCellScalarValues(size_t scalarResultIndex); void sumCellScalarValues(size_t scalarResultIndex, double& sumValue); void sumCellScalarValues(size_t scalarResultIndex, size_t timeStepIndex, double& sumValue); - + void mobileVolumeWeightedMean(size_t scalarResultIndex, size_t timeStepIndex, double& meanValue); // Access meta-information about the results size_t resultCount() const; size_t timeStepCount(size_t scalarResultIndex) const; diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseNativeStatCalc.cpp b/ApplicationCode/ReservoirDataModel/RigEclipseNativeStatCalc.cpp index 97e86bdfa2..3c5e077e04 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseNativeStatCalc.cpp +++ b/ApplicationCode/ReservoirDataModel/RigEclipseNativeStatCalc.cpp @@ -22,6 +22,7 @@ #include "RigStatisticsMath.h" #include "RigCaseCellResultsData.h" #include "RigStatisticsMath.h" +#include "RigWeightedMeanCalc.h" #include // Needed for HUGE_VAL on Linux @@ -94,3 +95,18 @@ size_t RigEclipseNativeStatCalc::timeStepCount() { return m_resultsData->timeStepCount(m_scalarResultIndex); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigEclipseNativeStatCalc::mobileVolumeWeightedMean(size_t timeStepIndex, double& mean) +{ + size_t mobPVResultIndex = m_resultsData->findOrLoadScalarResult(RiaDefines::ResultCatType::STATIC_NATIVE, RiaDefines::mobilePoreVolumeName()); + + const std::vector& weights = m_resultsData->cellScalarResults(mobPVResultIndex, 0); + const std::vector& values = m_resultsData->cellScalarResults(m_scalarResultIndex, timeStepIndex); + + const RigActiveCellInfo* actCellInfo = m_resultsData->activeCellInfo(); + + RigWeightedMeanCalc::weightedMeanOverCells(&weights, &values, nullptr, false, actCellInfo, m_resultsData->isUsingGlobalActiveIndex(m_scalarResultIndex), &mean); +} diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseNativeStatCalc.h b/ApplicationCode/ReservoirDataModel/RigEclipseNativeStatCalc.h index 26d82198d6..059b5c41e7 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseNativeStatCalc.h +++ b/ApplicationCode/ReservoirDataModel/RigEclipseNativeStatCalc.h @@ -41,6 +41,7 @@ public: virtual void addDataToHistogramCalculator(size_t timeStepIndex, RigHistogramCalculator& histogramCalculator); virtual void uniqueValues(size_t timeStepIndex, std::set& values); virtual size_t timeStepCount(); + virtual void mobileVolumeWeightedMean(size_t timeStepIndex, double& mean); private: RigCaseCellResultsData* m_resultsData;