#2146 Num Flooded PV: Add allVisibleCells for flowDiag

This commit is contained in:
Rebecca Cox 2017-11-16 14:59:55 +01:00
parent 92a6819b39
commit 204ee2162a
10 changed files with 71 additions and 54 deletions

View File

@ -292,6 +292,7 @@ Rim3dOverlayInfoConfig::HistogramData Rim3dOverlayInfoConfig::histogramData(RimE
fldResults->p10p90ScalarValues(resAddr, currentTimeStep, &histData.p10, &histData.p90);
fldResults->meanScalarValue(resAddr, currentTimeStep, &histData.mean);
fldResults->sumScalarValue(resAddr, currentTimeStep, &histData.sum);
fldResults->mobileVolumeWeightedMean(resAddr, currentTimeStep, &histData.weightedMean);
histData.histogram = &(fldResults->scalarValuesHistogram(resAddr, currentTimeStep));
}

View File

@ -112,6 +112,6 @@ void RigEclipseNativeVisibleCellsStatCalc::mobileVolumeWeightedMean(size_t timeS
const RigActiveCellInfo* actCellInfo = m_caseData->activeCellInfo();
RigWeightedMeanCalc::weightedMeanOverCells(&weights, &values, m_cellVisibilities.p(), actCellInfo, m_caseData->isUsingGlobalActiveIndex(m_scalarResultIndex), &result);
RigWeightedMeanCalc::weightedMeanOverCells(&weights, &values, m_cellVisibilities.p(), true, actCellInfo, m_caseData->isUsingGlobalActiveIndex(m_scalarResultIndex), &result);
}

View File

@ -665,6 +665,14 @@ const std::vector<int>& RigFlowDiagResults::uniqueCellScalarValues(const RigFlow
return this->statistics(resVarAddr)->uniqueCellScalarValues(timeStepIndex);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigFlowDiagResults::mobileVolumeWeightedMean(const RigFlowDiagResultAddress& resVarAddr, int timeStepIndex, double* mean)
{
this->statistics(resVarAddr)->mobileVolumeWeightedMean(timeStepIndex, *mean);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -74,6 +74,7 @@ public:
const std::vector<size_t>& scalarValuesHistogram(const RigFlowDiagResultAddress& resVarAddr, int timeStepIndex);
const std::vector<int>& uniqueCellScalarValues(const RigFlowDiagResultAddress& resVarAddr);
const std::vector<int>& uniqueCellScalarValues(const RigFlowDiagResultAddress& resVarAddr, int timeStepIndex);
void mobileVolumeWeightedMean(const RigFlowDiagResultAddress& resVarAddr, int timeStepIndex, double* mean);
std::pair<double, double> injectorProducerPairFluxes(const std::string& injTracername, const std::string& prodTracerName, int timeStepIndex);
double maxAbsPairFlux(int timeStepIndex);

View File

@ -18,10 +18,15 @@
/////////////////////////////////////////////////////////////////////////////////
#include "RigFlowDiagStatCalc.h"
#include "RigCaseCellResultsData.h"
#include "RigFlowDiagResults.h"
#include "RigStatisticsMath.h"
#include "RigWeightedMeanCalc.h"
#include "RimEclipseResultCase.h"
#include <math.h>
#include "RigStatisticsMath.h"
//--------------------------------------------------------------------------------------------------
///
@ -104,4 +109,24 @@ size_t RigFlowDiagStatCalc::timeStepCount()
return m_resultsData->timeStepCount();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigFlowDiagStatCalc::mobileVolumeWeightedMean(size_t timeStepIndex, double& mean)
{
RimEclipseResultCase* eclCase = nullptr;
m_resultsData->flowDiagSolution()->firstAncestorOrThisOfType(eclCase);
if (!eclCase) return;
RigCaseCellResultsData* caseCellResultsData = eclCase->results(RiaDefines::MATRIX_MODEL);
size_t mobPVResultIndex = caseCellResultsData->findOrLoadScalarResult(RiaDefines::ResultCatType::STATIC_NATIVE, RiaDefines::mobilePoreVolumeName());
const std::vector<double>& weights = caseCellResultsData->cellScalarResults(mobPVResultIndex, 0);
const std::vector<double>* values = m_resultsData->resultValues(m_resVarAddr, timeStepIndex);
const RigActiveCellInfo* actCellInfo = m_resultsData->activeCellInfo(m_resVarAddr);
RigWeightedMeanCalc::weightedMeanOverCells(&weights, values, nullptr, false, actCellInfo, true, &mean);
}

View File

@ -19,8 +19,8 @@
#pragma once
#include "RigStatisticsCalculator.h"
#include "RigFlowDiagResultAddress.h"
#include "RigStatisticsCalculator.h"
class RigHistogramCalculator;
class RigFlowDiagResults;
@ -32,7 +32,7 @@ class RigFlowDiagResults;
class RigFlowDiagStatCalc : public RigStatisticsCalculator
{
public:
RigFlowDiagStatCalc(RigFlowDiagResults* femResultCollection, const RigFlowDiagResultAddress& resVarAddr);
RigFlowDiagStatCalc(RigFlowDiagResults* flowDiagResults, const RigFlowDiagResultAddress& resVarAddr);
virtual void minMaxCellScalarValues(size_t timeStepIndex, double& min, double& max);
virtual void posNegClosestToZero(size_t timeStepIndex, double& pos, double& neg);
@ -40,6 +40,7 @@ public:
virtual void addDataToHistogramCalculator(size_t timeStepIndex, RigHistogramCalculator& histogramCalculator);
virtual void uniqueValues(size_t timeStepIndex, std::set<int>& values);
virtual size_t timeStepCount();
virtual void mobileVolumeWeightedMean(size_t timeStepIndex, double& mean);
private:
RigFlowDiagResults* m_resultsData;

View File

@ -116,6 +116,6 @@ void RigFlowDiagVisibleCellsStatCalc::mobileVolumeWeightedMean(size_t timeStepIn
const RigActiveCellInfo* actCellInfo = m_resultsData->activeCellInfo(m_resVarAddr);
RigWeightedMeanCalc::weightedMeanOverCells(&weights, values, m_cellVisibilities.p(), actCellInfo, true, &result);
RigWeightedMeanCalc::weightedMeanOverCells(&weights, values, m_cellVisibilities.p(), true, actCellInfo, true, &result);
}

View File

@ -28,71 +28,48 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigWeightedMeanCalc::weightedMeanOverCells(const std::vector<double>* weights,
const std::vector<double>* values,
const cvf::UByteArray* cellVisibilities,
void RigWeightedMeanCalc::weightedMeanOverCells(const std::vector<double>* weights,
const std::vector<double>* values,
const cvf::UByteArray* cellVisibilities,
bool isUsingVisibleCells,
const RigActiveCellInfo* actCellInfo,
bool isUsingActiveIndex,
double *result)
{
if (!(weights && values && cellVisibilities && result)) return;
if (!(weights && values && result)) return;
if (!cellVisibilities && isUsingVisibleCells) return;
if (!actCellInfo && isUsingActiveIndex) return;
if (weights->empty() || values->empty()) return;
if (weights->size() != values->size()) return;
double weightedSum = 0.0;
double weightSum = 0.0;
for (size_t cIdx = 0; cIdx < cellVisibilities->size(); ++cIdx)
for (size_t cIdx = 0; cIdx < actCellInfo->reservoirCellCount(); ++cIdx)
{
if (!(*cellVisibilities)[cIdx]) continue;
if (isUsingVisibleCells)
{
if (!(*cellVisibilities)[cIdx]) continue;
}
size_t cellResultIndex = actCellInfo->cellResultIndex(cIdx);
if (cellResultIndex == cvf::UNDEFINED_SIZE_T || cellResultIndex > weights->size())
{
continue;
}
double value;
size_t cellResultIndex = cIdx;
if (isUsingActiveIndex)
{
cellResultIndex = actCellInfo->cellResultIndex(cIdx);
value = (*values)[cellResultIndex];
}
else
{
value = (*values)[cIdx];
}
if (cellResultIndex == cvf::UNDEFINED_SIZE_T || cellResultIndex > values->size()) continue;
double weight = (*weights)[cellResultIndex];
double value = (*values)[cellResultIndex];
if (weight == HUGE_VAL || value == HUGE_VAL)
{
continue;
}
weightedSum += weight * value;
weightSum += weight;
}
if (weightSum != 0)
{
*result = weightedSum / weightSum;
}
else
{
*result = HUGE_VAL;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigWeightedMeanCalc::weightedMean(const std::vector<double>* weights, const std::vector<double>* values, double* result)
{
if (!weights || !values) return;
if (weights->size() != values->size()) return;
double weightedSum = 0;
double weightSum = 0;
for (size_t i = 0; i < values->size(); i++)
{
double weight = weights->at(i);
double value = values->at(i);
if (weight == HUGE_VAL || value == HUGE_VAL)
{

View File

@ -31,9 +31,8 @@ public:
static void weightedMeanOverCells(const std::vector<double>* weights,
const std::vector<double>* values,
const cvf::UByteArray* cellVisibilities,
bool isUsingVisibleCells,
const RigActiveCellInfo* actCellInfo,
bool isUsingActiveIndex,
double *result);
static void weightedMean(const std::vector<double>* weights, const std::vector<double>* values, double *result);
};

View File

@ -280,6 +280,11 @@ const std::vector<int>& RigStatisticsDataCache::uniqueCellScalarValues(size_t ti
//--------------------------------------------------------------------------------------------------
void RigStatisticsDataCache::mobileVolumeWeightedMean(size_t timeStepIndex, double& mean)
{
if (timeStepIndex >= m_statsPrTs.size())
{
m_statsPrTs.resize(timeStepIndex + 1);
}
if (!m_statsPrTs[timeStepIndex].m_isVolumeWeightedMeanCalculated)
{
m_statisticsCalculator->mobileVolumeWeightedMean(timeStepIndex, m_statsPrTs[timeStepIndex].m_volumeWeightedMean);