diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.cpp index 2500135225..0a9eb9900c 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.cpp @@ -295,6 +295,37 @@ void RigGeoMechCaseData::posNegClosestToZeroInternal(const RigFemResultAddress& *overallNegClosestToZero = negClosestToZero; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigGeoMechCaseData::meanCellScalarValues(const RigFemResultAddress& resVarAddr, double* meanValue) +{ + CVF_ASSERT(meanValue); + + double mean = 0; + size_t meanContribCount = 0; + + for (int pIdx = 0; pIdx < static_cast(m_femPartResults.size()); ++pIdx) + { + if (m_femPartResults[pIdx].notNull()) + { + RigFemScalarResultFrames* frames = findOrLoadScalarResult(pIdx, resVarAddr); + if (frames) + { + double localMean = 0; + + RigStatisticsDataCache* stats = frames->statistics(); + stats->meanCellScalarValues(localMean); + + mean += localMean; + meanContribCount++; + } + } + } + + *meanValue = meanContribCount > 0 ? mean/meanContribCount : 0; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.h index 5e3fb10a6b..8df16cffdf 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.h +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.h @@ -54,6 +54,7 @@ public: 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, double* globalPosClosestToZero, double* globalNegClosestToZero); + void meanCellScalarValues(const RigFemResultAddress& resVarAddr, double* meanValue); private: void minMaxScalarValuesInternal(const RigFemResultAddress& resVarAddr, int frameIndex, diff --git a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp index 27cea45f8a..5a328589e9 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp @@ -38,8 +38,7 @@ #include "RigGeoMechCaseData.h" #include "RigFemPartCollection.h" #include "RimGeoMechResultSlot.h" - - +#include "RigFemResultAddress.h" CAF_PDM_SOURCE_INIT(Rim3dOverlayInfoConfig, "View3dOverlayInfoConfig"); @@ -330,6 +329,9 @@ void Rim3dOverlayInfoConfig::updateGeoMech3DInfo(RimGeoMechView * geoMechView) double p10 = 0, p90 = 0; double mean = 0; + RigFemResultAddress resAddress = geoMechView->cellResult()->resultAddress(); + caseData->meanCellScalarValues(resAddress, &mean); + // ToDo: Implement statistics for geomech data /*RigStatisticsDataCache* statistics = caseData ? caseData->statistics() : NULL; statistics->minMaxCellScalarValues(min, max);