(#606) (#607) Calculate visible cells statistics for geomech

Refactored some in 3D info regarding geomech cases.
This commit is contained in:
Jacob Støren
2015-11-06 10:18:55 +01:00
parent 2adb9279ce
commit 0bd4f4a8f9
11 changed files with 509 additions and 174 deletions

View File

@@ -31,6 +31,8 @@
RigStatisticsDataCache::RigStatisticsDataCache(RigStatisticsCalculator* statisticsCalculator)
: m_statisticsCalculator(statisticsCalculator)
{
CVF_ASSERT(m_statisticsCalculator.notNull());
clearAllStatistics();
}
@@ -153,6 +155,40 @@ void RigStatisticsDataCache::posNegClosestToZero(size_t timeStepIndex, double& p
posNearZero = m_statsPrTs[timeStepIndex].m_posClosestToZero;
negNearZero = m_statsPrTs[timeStepIndex].m_negClosestToZero;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigStatisticsDataCache::meanCellScalarValues(double& meanValue)
{
if (!m_statsAllTimesteps.m_isMeanCalculated)
{
m_statisticsCalculator->meanCellScalarValue(m_statsAllTimesteps.m_meanValue);
m_statsAllTimesteps.m_isMeanCalculated = true;
}
meanValue = m_statsAllTimesteps.m_meanValue;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigStatisticsDataCache::meanCellScalarValues(size_t timeStepIndex, double& meanValue)
{
if (timeStepIndex >= m_statsPrTs.size())
{
m_statsPrTs.resize(timeStepIndex + 1);
}
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;
}
//--------------------------------------------------------------------------------------------------
///
@@ -196,34 +232,6 @@ void RigStatisticsDataCache::p10p90CellScalarValues(size_t timeStepIndex, double
p90 = m_statsPrTs[timeStepIndex].m_p90;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigStatisticsDataCache::meanCellScalarValues(double& meanValue)
{
if (!m_statsAllTimesteps.m_isMeanCalculated)
{
m_statisticsCalculator->meanCellScalarValue(m_statsAllTimesteps.m_meanValue);
m_statsAllTimesteps.m_isMeanCalculated = true;
}
meanValue = m_statsAllTimesteps.m_meanValue;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigStatisticsDataCache::meanCellScalarValues(size_t timeStepIndex, double& meanValue)
{
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;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -186,7 +186,28 @@ RigHistogramCalculator::RigHistogramCalculator(double min, double max, size_t nB
for (size_t i = 0; i < m_histogram->size(); ++i) (*m_histogram)[i] = 0;
m_range = max - min;
maxIndex = nBins-1;
m_maxIndex = nBins-1;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigHistogramCalculator::addValue(double value)
{
if (value == HUGE_VAL || value != value)
{
return;
}
size_t index = 0;
if (m_maxIndex > 0) index = (size_t)(m_maxIndex*(value - m_min)/m_range);
if (index < m_histogram->size()) // Just clip to the max min range (-index will overflow to positive )
{
(*m_histogram)[index]++;
m_observationCount++;
}
}
//--------------------------------------------------------------------------------------------------
@@ -197,20 +218,7 @@ void RigHistogramCalculator::addData(const std::vector<double>& data)
assert(m_histogram);
for (size_t i = 0; i < data.size(); ++i)
{
if (data[i] == HUGE_VAL)
{
continue;
}
size_t index = 0;
if (maxIndex > 0) index = (size_t)(maxIndex*(data[i] - m_min)/m_range);
if(index < m_histogram->size()) // Just clip to the max min range (-index will overflow to positive )
{
(*m_histogram)[index]++;
m_observationCount++;
}
addValue(data[i]);
}
}
@@ -222,20 +230,7 @@ void RigHistogramCalculator::addData(const std::vector<float>& data)
assert(m_histogram);
for (size_t i = 0; i < data.size(); ++i)
{
if (data[i] == HUGE_VAL)
{
continue;
}
size_t index = 0;
if (maxIndex > 0) index = (size_t)(maxIndex*(data[i] - m_min)/m_range);
if(index < m_histogram->size()) // Just clip to the max min range (-index will overflow to positive )
{
(*m_histogram)[index]++;
m_observationCount++;
}
addValue(data[i]);
}
}

View File

@@ -41,6 +41,8 @@ public:
void addData(const std::vector<double>& data);
void addData(const std::vector<float>& data);
void addValue(double value);
/// Calculates the estimated percentile from the histogram.
/// the percentile is the domain value at which pVal of the observations are below it.
/// Will only consider observed values between min and max, as all other values are discarded from the histogram
@@ -48,7 +50,7 @@ public:
double calculatePercentil(double pVal);
private:
size_t maxIndex;
size_t m_maxIndex;
double m_range;
double m_min;
size_t m_observationCount;