(#606)(#607) Added option to show 3D-info statistics pr. time step.

This commit is contained in:
Jacob Støren 2015-11-04 15:44:09 +01:00
parent 738af9c88e
commit a4d7e369eb
7 changed files with 274 additions and 110 deletions

View File

@ -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<size_t>& RigFemPartResultsCollection::scalarValuesHistogram(co
return this->statistics(resVarAddr)->cellScalarValuesHistogram();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const std::vector<size_t>& RigFemPartResultsCollection::scalarValuesHistogram(const RigFemResultAddress& resVarAddr, int frameIndex)
{
return this->statistics(resVarAddr)->cellScalarValuesHistogram(frameIndex);
}

View File

@ -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<size_t>& scalarValuesHistogram(const RigFemResultAddress& resVarAddr);
const std::vector<size_t>& scalarValuesHistogram(const RigFemResultAddress& resVarAddr, int frameIndex);
private:
RigFemScalarResultFrames* findOrLoadScalarResult(int partIndex,

View File

@ -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("<table border=0 cellspacing=5 >"
@ -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<size_t>* 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("<b>Cell result:</b> %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("<table border=0 cellspacing=5 >"
"<tr> <td>Min</td> <td>P10</td> <td>Mean</td> <td>P90</td> <td>Max</td> </tr>"
@ -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<size_t>* 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);
}
}

View File

@ -87,6 +87,14 @@ const std::vector<size_t>& RigCaseCellResultsData::cellScalarValuesHistogram(siz
return m_statisticsDataCache[scalarResultIndex]->cellScalarValuesHistogram();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const std::vector<size_t>& 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);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -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<size_t>& cellScalarValuesHistogram(size_t scalarResultIndex);
const std::vector<size_t>& 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;

View File

@ -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<size_t>& RigStatisticsDataCache::cellScalarValuesHistogram()
{
computeStatisticsIfNeeded();
computeHistogramStatisticsIfNeeded();
return m_histogram;
return m_statsAllTimesteps.m_histogram;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const std::vector<size_t>& RigStatisticsDataCache::cellScalarValuesHistogram(size_t timeStepIndex)
{
computeHistogramStatisticsIfNeeded(timeStepIndex);
return m_statsPrTs[timeStepIndex].m_histogram;
}
//--------------------------------------------------------------------------------------------------
@ -183,11 +179,21 @@ const std::vector<size_t>& 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);
}
}

View File

@ -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<size_t>& cellScalarValuesHistogram();
const std::vector<size_t>& 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<size_t> m_histogram;
std::vector<size_t> m_histogram;
};
std::vector<std::pair<double, double> > m_maxMinValuesPrTs; ///< Max min values for each time step
std::vector<bool> m_isMaxMinPrTsCalculated;
std::vector<std::pair<double, double> > m_posNegClosestToZeroPrTs; ///< PosNeg values for each time step
std::vector<bool> m_isClosestToZeroPrTsCalculated;
StatisticsValues m_statsAllTimesteps;
std::vector<StatisticsValues> m_statsPrTs;
cvf::ref<RigStatisticsCalculator> m_statisticsCalculator;
cvf::ref<RigStatisticsCalculator> m_statisticsCalculator;
};