#3958 Starting refactoring of eclipse results addressing

Preparations for time diff results
This commit is contained in:
Jacob Støren
2019-01-22 08:54:00 +01:00
parent b329f3acc7
commit ccfee8f34a
38 changed files with 369 additions and 310 deletions

View File

@@ -77,121 +77,121 @@ void RigCaseCellResultsData::setActiveCellInfo(RigActiveCellInfo* activeCellInfo
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigCaseCellResultsData::minMaxCellScalarValues(size_t scalarResultIndex, double& min, double& max)
void RigCaseCellResultsData::minMaxCellScalarValues(const RigEclipseResultAddress& resVarAddr, double& min, double& max)
{
m_statisticsDataCache[scalarResultIndex]->minMaxCellScalarValues(min, max);
statistics(resVarAddr)->minMaxCellScalarValues(min, max);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigCaseCellResultsData::minMaxCellScalarValues(size_t scalarResultIndex, size_t timeStepIndex, double& min, double& max)
void RigCaseCellResultsData::minMaxCellScalarValues(const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex, double& min, double& max)
{
m_statisticsDataCache[scalarResultIndex]->minMaxCellScalarValues(timeStepIndex, min, max);
statistics(resVarAddr)->minMaxCellScalarValues(timeStepIndex, min, max);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigCaseCellResultsData::posNegClosestToZero(size_t scalarResultIndex, double& pos, double& neg)
void RigCaseCellResultsData::posNegClosestToZero(const RigEclipseResultAddress& resVarAddr, double& pos, double& neg)
{
m_statisticsDataCache[scalarResultIndex]->posNegClosestToZero(pos, neg);
statistics(resVarAddr)->posNegClosestToZero(pos, neg);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigCaseCellResultsData::posNegClosestToZero(size_t scalarResultIndex, size_t timeStepIndex, double& pos, double& neg)
void RigCaseCellResultsData::posNegClosestToZero(const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex, double& pos, double& neg)
{
m_statisticsDataCache[scalarResultIndex]->posNegClosestToZero(timeStepIndex, pos, neg);
statistics(resVarAddr)->posNegClosestToZero(timeStepIndex, pos, neg);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const std::vector<size_t>& RigCaseCellResultsData::cellScalarValuesHistogram(size_t scalarResultIndex)
const std::vector<size_t>& RigCaseCellResultsData::cellScalarValuesHistogram(const RigEclipseResultAddress& resVarAddr)
{
return m_statisticsDataCache[scalarResultIndex]->cellScalarValuesHistogram();
return statistics(resVarAddr)->cellScalarValuesHistogram();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const std::vector<size_t>& RigCaseCellResultsData::cellScalarValuesHistogram(size_t scalarResultIndex, size_t timeStepIndex)
const std::vector<size_t>& RigCaseCellResultsData::cellScalarValuesHistogram(const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex)
{
return m_statisticsDataCache[scalarResultIndex]->cellScalarValuesHistogram(timeStepIndex);
return statistics(resVarAddr)->cellScalarValuesHistogram(timeStepIndex);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigCaseCellResultsData::p10p90CellScalarValues(size_t scalarResultIndex, double& p10, double& p90)
void RigCaseCellResultsData::p10p90CellScalarValues(const RigEclipseResultAddress& resVarAddr, double& p10, double& p90)
{
m_statisticsDataCache[scalarResultIndex]->p10p90CellScalarValues(p10, p90);
statistics(resVarAddr)->p10p90CellScalarValues(p10, p90);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigCaseCellResultsData::p10p90CellScalarValues(size_t scalarResultIndex, size_t timeStepIndex, double& p10, double& p90)
void RigCaseCellResultsData::p10p90CellScalarValues(const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex, double& p10, double& p90)
{
m_statisticsDataCache[scalarResultIndex]->p10p90CellScalarValues(timeStepIndex, p10, p90);
statistics(resVarAddr)->p10p90CellScalarValues(timeStepIndex, p10, p90);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigCaseCellResultsData::meanCellScalarValues(size_t scalarResultIndex, double& meanValue)
void RigCaseCellResultsData::meanCellScalarValues(const RigEclipseResultAddress& resVarAddr, double& meanValue)
{
m_statisticsDataCache[scalarResultIndex]->meanCellScalarValues(meanValue);
statistics(resVarAddr)->meanCellScalarValues(meanValue);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigCaseCellResultsData::meanCellScalarValues(size_t scalarResultIndex, size_t timeStepIndex, double& meanValue)
void RigCaseCellResultsData::meanCellScalarValues(const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex, double& meanValue)
{
m_statisticsDataCache[scalarResultIndex]->meanCellScalarValues(timeStepIndex, meanValue);
statistics(resVarAddr)->meanCellScalarValues(timeStepIndex, meanValue);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const std::vector<int>& RigCaseCellResultsData::uniqueCellScalarValues(size_t scalarResultIndex)
const std::vector<int>& RigCaseCellResultsData::uniqueCellScalarValues(const RigEclipseResultAddress& resVarAddr)
{
return m_statisticsDataCache[scalarResultIndex]->uniqueCellScalarValues();
return statistics(resVarAddr)->uniqueCellScalarValues();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigCaseCellResultsData::sumCellScalarValues(size_t scalarResultIndex, double& sumValue)
void RigCaseCellResultsData::sumCellScalarValues(const RigEclipseResultAddress& resVarAddr, double& sumValue)
{
m_statisticsDataCache[scalarResultIndex]->sumCellScalarValues(sumValue);
statistics(resVarAddr)->sumCellScalarValues(sumValue);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigCaseCellResultsData::sumCellScalarValues(size_t scalarResultIndex, size_t timeStepIndex, double& sumValue)
void RigCaseCellResultsData::sumCellScalarValues(const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex, double& sumValue)
{
m_statisticsDataCache[scalarResultIndex]->sumCellScalarValues(timeStepIndex, sumValue);
statistics(resVarAddr)->sumCellScalarValues(timeStepIndex, sumValue);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigCaseCellResultsData::mobileVolumeWeightedMean(size_t scalarResultIndex, double& meanValue)
void RigCaseCellResultsData::mobileVolumeWeightedMean(const RigEclipseResultAddress& resVarAddr, double& meanValue)
{
m_statisticsDataCache[scalarResultIndex]->mobileVolumeWeightedMean(meanValue);
statistics(resVarAddr)->mobileVolumeWeightedMean(meanValue);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigCaseCellResultsData::mobileVolumeWeightedMean(size_t scalarResultIndex, size_t timeStepIndex, double& meanValue)
void RigCaseCellResultsData::mobileVolumeWeightedMean(const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex, double& meanValue)
{
m_statisticsDataCache[scalarResultIndex]->mobileVolumeWeightedMean(timeStepIndex, meanValue);
statistics(resVarAddr)->mobileVolumeWeightedMean(timeStepIndex, meanValue);
}
//--------------------------------------------------------------------------------------------------
@@ -205,42 +205,53 @@ size_t RigCaseCellResultsData::resultCount() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RigCaseCellResultsData::timeStepCount(size_t scalarResultIndex) const
size_t RigCaseCellResultsData::timeStepCount(const RigEclipseResultAddress& resVarAddr) const
{
CVF_TIGHT_ASSERT(scalarResultIndex < resultCount());
return m_cellScalarResults[scalarResultIndex].size();
return m_cellScalarResults[resVarAddr.scalarResultIndex].size();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const std::vector<std::vector<double>>& RigCaseCellResultsData::cellScalarResults(size_t scalarResultIndex) const
const std::vector<std::vector<double>>& RigCaseCellResultsData::cellScalarResults(const RigEclipseResultAddress& resVarAddr) const
{
CVF_TIGHT_ASSERT(scalarResultIndex < resultCount());
return m_cellScalarResults[scalarResultIndex];
return m_cellScalarResults[resVarAddr.scalarResultIndex];
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<std::vector<double>>& RigCaseCellResultsData::cellScalarResults(size_t scalarResultIndex)
std::vector<std::vector<double>>& RigCaseCellResultsData::cellScalarResults(const RigEclipseResultAddress& resVarAddr)
{
CVF_TIGHT_ASSERT(scalarResultIndex < resultCount());
return m_cellScalarResults[scalarResultIndex];
return m_cellScalarResults[resVarAddr.scalarResultIndex];
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<double>& RigCaseCellResultsData::cellScalarResults(size_t scalarResultIndex, size_t timeStepIndex)
std::vector<double>& RigCaseCellResultsData::cellScalarResults(const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex)
{
CVF_TIGHT_ASSERT(scalarResultIndex < resultCount());
CVF_TIGHT_ASSERT(timeStepIndex < m_cellScalarResults[scalarResultIndex].size());
return m_cellScalarResults[scalarResultIndex][timeStepIndex];
return m_cellScalarResults[resVarAddr.scalarResultIndex][timeStepIndex];
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const std::vector<double>& RigCaseCellResultsData::cellScalarResults(const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex) const
{
CVF_TIGHT_ASSERT(scalarResultIndex < resultCount());
CVF_TIGHT_ASSERT(timeStepIndex < m_cellScalarResults[scalarResultIndex].size());
return m_cellScalarResults[resVarAddr.scalarResultIndex][timeStepIndex];
}
//--------------------------------------------------------------------------------------------------
@@ -460,21 +471,21 @@ const RigActiveCellInfo* RigCaseCellResultsData::activeCellInfo() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigCaseCellResultsData::recalculateStatistics(size_t scalarResultIndex)
void RigCaseCellResultsData::recalculateStatistics(const RigEclipseResultAddress& resVarAddr)
{
m_statisticsDataCache[scalarResultIndex]->clearAllStatistics();
m_statisticsDataCache[resVarAddr.scalarResultIndex]->clearAllStatistics();
}
//--------------------------------------------------------------------------------------------------
/// Returns whether the result data in question is addressed by Active Cell Index
//--------------------------------------------------------------------------------------------------
bool RigCaseCellResultsData::isUsingGlobalActiveIndex(size_t scalarResultIndex) const
bool RigCaseCellResultsData::isUsingGlobalActiveIndex(const RigEclipseResultAddress& resVarAddr) const
{
CVF_TIGHT_ASSERT(scalarResultIndex < m_cellScalarResults.size());
if (!m_cellScalarResults[scalarResultIndex].size()) return true;
if (!m_cellScalarResults[resVarAddr.scalarResultIndex].size()) return true;
size_t firstTimeStepResultValueCount = m_cellScalarResults[scalarResultIndex][0].size();
size_t firstTimeStepResultValueCount = m_cellScalarResults[resVarAddr.scalarResultIndex][0].size();
if (firstTimeStepResultValueCount == m_ownerMainGrid->globalCellArray().size()) return false;
return true;
@@ -513,11 +524,11 @@ std::vector<QDateTime> RigCaseCellResultsData::allTimeStepDatesFromEclipseReader
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<QDateTime> RigCaseCellResultsData::timeStepDates(size_t scalarResultIndex) const
std::vector<QDateTime> RigCaseCellResultsData::timeStepDates(const RigEclipseResultAddress& resVarAddr) const
{
if (scalarResultIndex < m_resultInfos.size())
if (resVarAddr.scalarResultIndex < m_resultInfos.size())
{
return m_resultInfos[scalarResultIndex].dates();
return m_resultInfos[resVarAddr.scalarResultIndex].dates();
}
else
return std::vector<QDateTime>();
@@ -531,7 +542,7 @@ std::vector<QDateTime> RigCaseCellResultsData::timeStepDates() const
size_t scalarResWithMostTimeSteps = cvf::UNDEFINED_SIZE_T;
maxTimeStepCount(&scalarResWithMostTimeSteps);
return timeStepDates(scalarResWithMostTimeSteps);
return timeStepDates(RigEclipseResultAddress(scalarResWithMostTimeSteps));
}
//--------------------------------------------------------------------------------------------------
@@ -542,17 +553,17 @@ std::vector<double> RigCaseCellResultsData::daysSinceSimulationStart() const
size_t scalarResWithMostTimeSteps = cvf::UNDEFINED_SIZE_T;
maxTimeStepCount(&scalarResWithMostTimeSteps);
return daysSinceSimulationStart(scalarResWithMostTimeSteps);
return daysSinceSimulationStart(RigEclipseResultAddress(scalarResWithMostTimeSteps));
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<double> RigCaseCellResultsData::daysSinceSimulationStart(size_t scalarResultIndex) const
std::vector<double> RigCaseCellResultsData::daysSinceSimulationStart(const RigEclipseResultAddress& resVarAddr) const
{
if (scalarResultIndex < m_resultInfos.size())
if (resVarAddr.scalarResultIndex < m_resultInfos.size())
{
return m_resultInfos[scalarResultIndex].daysSinceSimulationStarts();
return m_resultInfos[resVarAddr.scalarResultIndex].daysSinceSimulationStarts();
}
else
{
@@ -563,10 +574,10 @@ std::vector<double> RigCaseCellResultsData::daysSinceSimulationStart(size_t scal
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RigCaseCellResultsData::reportStepNumber(size_t scalarResultIndex, size_t timeStepIndex) const
int RigCaseCellResultsData::reportStepNumber(const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex) const
{
if (scalarResultIndex < m_resultInfos.size() && m_resultInfos[scalarResultIndex].timeStepInfos().size() > timeStepIndex)
return m_resultInfos[scalarResultIndex].timeStepInfos()[timeStepIndex].m_reportNumber;
if (resVarAddr.scalarResultIndex < m_resultInfos.size() && m_resultInfos[resVarAddr.scalarResultIndex].timeStepInfos().size() > timeStepIndex)
return m_resultInfos[resVarAddr.scalarResultIndex].timeStepInfos()[timeStepIndex].m_reportNumber;
else
return -1;
}
@@ -574,10 +585,10 @@ int RigCaseCellResultsData::reportStepNumber(size_t scalarResultIndex, size_t ti
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RigEclipseTimeStepInfo> RigCaseCellResultsData::timeStepInfos(size_t scalarResultIndex) const
std::vector<RigEclipseTimeStepInfo> RigCaseCellResultsData::timeStepInfos(const RigEclipseResultAddress& resVarAddr) const
{
if (scalarResultIndex < m_resultInfos.size())
return m_resultInfos[scalarResultIndex].timeStepInfos();
if (resVarAddr.scalarResultIndex < m_resultInfos.size())
return m_resultInfos[resVarAddr.scalarResultIndex].timeStepInfos();
else
return std::vector<RigEclipseTimeStepInfo>();
}
@@ -585,13 +596,13 @@ std::vector<RigEclipseTimeStepInfo> RigCaseCellResultsData::timeStepInfos(size_t
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigCaseCellResultsData::setTimeStepInfos(size_t scalarResultIndex, const std::vector<RigEclipseTimeStepInfo>& timeStepInfos)
void RigCaseCellResultsData::setTimeStepInfos(const RigEclipseResultAddress& resVarAddr, const std::vector<RigEclipseTimeStepInfo>& timeStepInfos)
{
CVF_ASSERT(scalarResultIndex < m_resultInfos.size());
CVF_ASSERT(resVarAddr.scalarResultIndex < m_resultInfos.size());
m_resultInfos[scalarResultIndex].setTimeStepInfos(timeStepInfos);
m_resultInfos[resVarAddr.scalarResultIndex].setTimeStepInfos(timeStepInfos);
std::vector<std::vector<double>>& dataValues = this->cellScalarResults(scalarResultIndex);
std::vector<std::vector<double>>& dataValues = this->cellScalarResults(resVarAddr);
dataValues.resize(timeStepInfos.size());
}
@@ -656,7 +667,7 @@ void RigCaseCellResultsData::clearScalarResult(RiaDefines::ResultCatType type, c
m_cellScalarResults[scalarResultIndex][tsIdx].swap(empty);
}
recalculateStatistics(scalarResultIndex);
recalculateStatistics(RigEclipseResultAddress(scalarResultIndex));
}
//--------------------------------------------------------------------------------------------------
@@ -760,9 +771,9 @@ const std::vector<double>*
if (scalarResultIndexPorv == cvf::UNDEFINED_SIZE_T) return nullptr;
const std::vector<double>* porvResults = &(gridCellResults->cellScalarResults(scalarResultIndexPorv, 0));
const std::vector<double>* porvResults = &(gridCellResults->cellScalarResults(RigEclipseResultAddress(scalarResultIndexPorv), 0));
if (!gridCellResults->isUsingGlobalActiveIndex(scalarResultIndexPorv))
if (!gridCellResults->isUsingGlobalActiveIndex(RigEclipseResultAddress(scalarResultIndexPorv)))
{
// PORV is given for all cells
@@ -1133,10 +1144,10 @@ size_t RigCaseCellResultsData::findOrLoadScalarResult(RiaDefines::ResultCatType
findOrLoadScalarResult(RiaDefines::DYNAMIC_NATIVE, "SWAT");
findOrLoadScalarResult(RiaDefines::DYNAMIC_NATIVE, "SGAS");
this->cellScalarResults(scalarResultIndex).resize(this->maxTimeStepCount());
m_cellScalarResults[scalarResultIndex].resize(this->maxTimeStepCount());
for (size_t timeStepIdx = 0; timeStepIdx < this->maxTimeStepCount(); timeStepIdx++)
{
std::vector<double>& values = this->cellScalarResults(scalarResultIndex)[timeStepIdx];
std::vector<double>& values = m_cellScalarResults[scalarResultIndex][timeStepIdx];
if (values.size() == 0)
{
computeSOILForTimeStep(timeStepIdx);
@@ -1149,7 +1160,7 @@ size_t RigCaseCellResultsData::findOrLoadScalarResult(RiaDefines::ResultCatType
else if (resultName == RiaDefines::completionTypeResultName())
{
caf::ProgressInfo progressInfo(this->maxTimeStepCount(), "Calculate Completion Type Results");
this->cellScalarResults(scalarResultIndex).resize(this->maxTimeStepCount());
m_cellScalarResults[scalarResultIndex].resize(this->maxTimeStepCount());
for (size_t timeStepIdx = 0; timeStepIdx < this->maxTimeStepCount(); ++timeStepIdx)
{
computeCompletionTypeForTimeStep(timeStepIdx);
@@ -1177,12 +1188,12 @@ size_t RigCaseCellResultsData::findOrLoadScalarResult(RiaDefines::ResultCatType
if (type == RiaDefines::DYNAMIC_NATIVE && timeStepCount > 0)
{
this->cellScalarResults(scalarResultIndex).resize(timeStepCount);
m_cellScalarResults[scalarResultIndex].resize(timeStepCount);
size_t i;
for (i = 0; i < timeStepCount; i++)
{
std::vector<double>& values = this->cellScalarResults(scalarResultIndex)[i];
std::vector<double>& values = m_cellScalarResults[scalarResultIndex][i];
if (!m_readerInterface->dynamicResult(resultName, RiaDefines::MATRIX_MODEL, i, &values))
{
resultLoadingSucess = false;
@@ -1200,9 +1211,9 @@ size_t RigCaseCellResultsData::findOrLoadScalarResult(RiaDefines::ResultCatType
}
else if (type == RiaDefines::STATIC_NATIVE)
{
this->cellScalarResults(scalarResultIndex).resize(1);
m_cellScalarResults[scalarResultIndex].resize(1);
std::vector<double>& values = this->cellScalarResults(scalarResultIndex)[0];
std::vector<double>& values = m_cellScalarResults[scalarResultIndex][0];
if (!m_readerInterface->staticResult(resultName, RiaDefines::MATRIX_MODEL, &values))
{
resultLoadingSucess = false;
@@ -1221,7 +1232,7 @@ size_t RigCaseCellResultsData::findOrLoadScalarResult(RiaDefines::ResultCatType
if (!resultLoadingSucess)
{
// Remove last scalar result because loading of result failed
this->cellScalarResults(scalarResultIndex).clear();
m_cellScalarResults[scalarResultIndex].clear();
}
}
@@ -1246,12 +1257,12 @@ size_t RigCaseCellResultsData::findOrLoadScalarResult(RiaDefines::ResultCatType
{
size_t timeStepCount = this->infoForEachResultIndex()[scalarResultIndex].timeStepInfos().size();
this->cellScalarResults(scalarResultIndex).resize(timeStepCount);
m_cellScalarResults[scalarResultIndex].resize(timeStepCount);
size_t i;
for (i = 0; i < timeStepCount; i++)
{
std::vector<double>& values = this->cellScalarResults(scalarResultIndex)[i];
std::vector<double>& values = m_cellScalarResults[scalarResultIndex][i];
eclReader->sourSimRlResult(resultName, i, &values);
}
}
@@ -1275,9 +1286,9 @@ size_t RigCaseCellResultsData::findOrLoadScalarResultForTimeStep(RiaDefines::Res
if (this->mustBeCalculated(soilScalarResultIndex))
{
this->cellScalarResults(soilScalarResultIndex).resize(this->maxTimeStepCount());
m_cellScalarResults[soilScalarResultIndex].resize(this->maxTimeStepCount());
std::vector<double>& values = this->cellScalarResults(soilScalarResultIndex)[timeStepIndex];
std::vector<double>& values = m_cellScalarResults[soilScalarResultIndex][timeStepIndex];
if (values.size() == 0)
{
computeSOILForTimeStep(timeStepIndex);
@@ -1309,9 +1320,9 @@ size_t RigCaseCellResultsData::findOrLoadScalarResultForTimeStep(RiaDefines::Res
if (type == RiaDefines::DYNAMIC_NATIVE && timeStepCount > 0)
{
this->cellScalarResults(scalarResultIndex).resize(timeStepCount);
m_cellScalarResults[scalarResultIndex].resize(timeStepCount);
std::vector<double>& values = this->cellScalarResults(scalarResultIndex)[timeStepIndex];
std::vector<double>& values = m_cellScalarResults[scalarResultIndex][timeStepIndex];
if (values.size() == 0)
{
if (!m_readerInterface->dynamicResult(resultName, RiaDefines::MATRIX_MODEL, timeStepIndex, &values))
@@ -1322,9 +1333,9 @@ size_t RigCaseCellResultsData::findOrLoadScalarResultForTimeStep(RiaDefines::Res
}
else if (type == RiaDefines::STATIC_NATIVE)
{
this->cellScalarResults(scalarResultIndex).resize(1);
m_cellScalarResults[scalarResultIndex].resize(1);
std::vector<double>& values = this->cellScalarResults(scalarResultIndex)[0];
std::vector<double>& values = m_cellScalarResults[scalarResultIndex][0];
if (!m_readerInterface->staticResult(resultName, RiaDefines::MATRIX_MODEL, &values))
{
resultLoadingSucess = false;
@@ -1347,9 +1358,9 @@ size_t RigCaseCellResultsData::findOrLoadScalarResultForTimeStep(RiaDefines::Res
{
size_t timeStepCount = this->infoForEachResultIndex()[scalarResultIndex].timeStepInfos().size();
this->cellScalarResults(scalarResultIndex).resize(timeStepCount);
m_cellScalarResults[scalarResultIndex].resize(timeStepCount);
std::vector<double>& values = this->cellScalarResults(scalarResultIndex)[timeStepIndex];
std::vector<double>& values = m_cellScalarResults[scalarResultIndex][timeStepIndex];
if (values.size() == 0)
{
@@ -1384,7 +1395,7 @@ void RigCaseCellResultsData::computeSOILForTimeStep(size_t timeStepIndex)
if (scalarIndexSWAT != cvf::UNDEFINED_SIZE_T)
{
std::vector<double>& swatForTimeStep = this->cellScalarResults(scalarIndexSWAT, timeStepIndex);
std::vector<double>& swatForTimeStep = this->cellScalarResults(RigEclipseResultAddress(scalarIndexSWAT), timeStepIndex);
if (swatForTimeStep.size() > 0)
{
soilResultValueCount = swatForTimeStep.size();
@@ -1394,7 +1405,7 @@ void RigCaseCellResultsData::computeSOILForTimeStep(size_t timeStepIndex)
if (scalarIndexSGAS != cvf::UNDEFINED_SIZE_T)
{
std::vector<double>& sgasForTimeStep = this->cellScalarResults(scalarIndexSGAS, timeStepIndex);
std::vector<double>& sgasForTimeStep = this->cellScalarResults(RigEclipseResultAddress(scalarIndexSGAS), timeStepIndex);
if (sgasForTimeStep.size() > 0)
{
soilResultValueCount = qMax(soilResultValueCount, sgasForTimeStep.size());
@@ -1407,15 +1418,15 @@ void RigCaseCellResultsData::computeSOILForTimeStep(size_t timeStepIndex)
// Make sure memory is allocated for the new SOIL results
size_t soilResultScalarIndex = this->findScalarResultIndex(RiaDefines::DYNAMIC_NATIVE, "SOIL");
this->cellScalarResults(soilResultScalarIndex).resize(soilTimeStepCount);
m_cellScalarResults[soilResultScalarIndex].resize(soilTimeStepCount);
if (this->cellScalarResults(soilResultScalarIndex, timeStepIndex).size() > 0)
if (this->cellScalarResults(RigEclipseResultAddress(soilResultScalarIndex), timeStepIndex).size() > 0)
{
// Data is computed and allocated, nothing more to do
return;
}
this->cellScalarResults(soilResultScalarIndex, timeStepIndex).resize(soilResultValueCount);
m_cellScalarResults[soilResultScalarIndex][timeStepIndex].resize(soilResultValueCount);
std::vector<double>* swatForTimeStep = nullptr;
std::vector<double>* sgasForTimeStep = nullptr;
@@ -1423,7 +1434,7 @@ void RigCaseCellResultsData::computeSOILForTimeStep(size_t timeStepIndex)
if (scalarIndexSWAT != cvf::UNDEFINED_SIZE_T)
{
swatForTimeStep = &(this->cellScalarResults(scalarIndexSWAT, timeStepIndex));
swatForTimeStep = &(this->cellScalarResults(RigEclipseResultAddress(scalarIndexSWAT), timeStepIndex));
if (swatForTimeStep->size() == 0)
{
swatForTimeStep = nullptr;
@@ -1432,7 +1443,7 @@ void RigCaseCellResultsData::computeSOILForTimeStep(size_t timeStepIndex)
if (scalarIndexSGAS != cvf::UNDEFINED_SIZE_T)
{
sgasForTimeStep = &(this->cellScalarResults(scalarIndexSGAS, timeStepIndex));
sgasForTimeStep = &(this->cellScalarResults(RigEclipseResultAddress(scalarIndexSGAS), timeStepIndex));
if (sgasForTimeStep->size() == 0)
{
sgasForTimeStep = nullptr;
@@ -1441,14 +1452,14 @@ void RigCaseCellResultsData::computeSOILForTimeStep(size_t timeStepIndex)
if (scalarIndexSSOL != cvf::UNDEFINED_SIZE_T)
{
ssolForTimeStep = &(this->cellScalarResults(scalarIndexSSOL, timeStepIndex));
ssolForTimeStep = &(this->cellScalarResults(RigEclipseResultAddress(scalarIndexSSOL), timeStepIndex));
if (ssolForTimeStep->size() == 0)
{
ssolForTimeStep = nullptr;
}
}
std::vector<double>& soilForTimeStep = this->cellScalarResults(soilResultScalarIndex, timeStepIndex);
std::vector<double>& soilForTimeStep = this->cellScalarResults(RigEclipseResultAddress(soilResultScalarIndex), timeStepIndex);
#pragma omp parallel for
for (int idx = 0; idx < static_cast<int>(soilResultValueCount); idx++)
@@ -1493,9 +1504,9 @@ void RigCaseCellResultsData::testAndComputeSgasForTimeStep(size_t timeStepIndex)
// Simulation type is gas and water. No SGAS is present, compute SGAS based on SWAT
size_t scalarIndexSGAS = this->findOrCreateScalarResultIndex(RiaDefines::DYNAMIC_NATIVE, "SGAS", false);
if (this->cellScalarResults(scalarIndexSGAS).size() > timeStepIndex)
if (m_cellScalarResults[scalarIndexSGAS].size() > timeStepIndex)
{
std::vector<double>& values = this->cellScalarResults(scalarIndexSGAS)[timeStepIndex];
std::vector<double>& values = m_cellScalarResults[scalarIndexSGAS][timeStepIndex];
if (values.size() > 0) return;
}
@@ -1503,7 +1514,7 @@ void RigCaseCellResultsData::testAndComputeSgasForTimeStep(size_t timeStepIndex)
size_t swatTimeStepCount = 0;
{
std::vector<double>& swatForTimeStep = this->cellScalarResults(scalarIndexSWAT, timeStepIndex);
std::vector<double>& swatForTimeStep = m_cellScalarResults[scalarIndexSWAT][timeStepIndex];
if (swatForTimeStep.size() > 0)
{
swatResultValueCount = swatForTimeStep.size();
@@ -1511,26 +1522,26 @@ void RigCaseCellResultsData::testAndComputeSgasForTimeStep(size_t timeStepIndex)
}
}
this->cellScalarResults(scalarIndexSGAS).resize(swatTimeStepCount);
m_cellScalarResults[scalarIndexSGAS].resize(swatTimeStepCount);
if (this->cellScalarResults(scalarIndexSGAS, timeStepIndex).size() > 0)
if (m_cellScalarResults[scalarIndexSGAS][timeStepIndex].size() > 0)
{
return;
}
this->cellScalarResults(scalarIndexSGAS, timeStepIndex).resize(swatResultValueCount);
m_cellScalarResults[scalarIndexSGAS][timeStepIndex].resize(swatResultValueCount);
std::vector<double>* swatForTimeStep = nullptr;
{
swatForTimeStep = &(this->cellScalarResults(scalarIndexSWAT, timeStepIndex));
swatForTimeStep = &(m_cellScalarResults[scalarIndexSWAT][timeStepIndex]);
if (swatForTimeStep->size() == 0)
{
swatForTimeStep = nullptr;
}
}
std::vector<double>& sgasForTimeStep = this->cellScalarResults(scalarIndexSGAS, timeStepIndex);
std::vector<double>& sgasForTimeStep = m_cellScalarResults[scalarIndexSGAS][timeStepIndex];
#pragma omp parallel for
for (int idx = 0; idx < static_cast<int>(swatResultValueCount); idx++)
@@ -1604,12 +1615,12 @@ void RigCaseCellResultsData::computeDepthRelatedResults()
computeBottom = true;
}
std::vector<std::vector<double>>& depth = this->cellScalarResults(depthResultIndex);
std::vector<std::vector<double>>& dx = this->cellScalarResults(dxResultIndex);
std::vector<std::vector<double>>& dy = this->cellScalarResults(dyResultIndex);
std::vector<std::vector<double>>& dz = this->cellScalarResults(dzResultIndex);
std::vector<std::vector<double>>& tops = this->cellScalarResults(topsResultIndex);
std::vector<std::vector<double>>& bottom = this->cellScalarResults(bottomResultIndex);
std::vector<std::vector<double>>& depth = m_cellScalarResults[depthResultIndex];
std::vector<std::vector<double>>& dx = m_cellScalarResults[dxResultIndex];
std::vector<std::vector<double>>& dy = m_cellScalarResults[dyResultIndex];
std::vector<std::vector<double>>& dz = m_cellScalarResults[dzResultIndex];
std::vector<std::vector<double>>& tops = m_cellScalarResults[topsResultIndex];
std::vector<std::vector<double>>& bottom = m_cellScalarResults[bottomResultIndex];
// Make sure the size is at least active cells
{
@@ -1837,22 +1848,22 @@ void RigCaseCellResultsData::computeRiTransComponent(const QString& riTransCompo
// Get the result count, to handle that one of them might be globally defined
size_t permxResultValueCount = this->cellScalarResults(permResultIdx)[0].size();
size_t permxResultValueCount = m_cellScalarResults[permResultIdx][0].size();
size_t resultValueCount = permxResultValueCount;
if (hasNTGResults)
{
size_t ntgResultValueCount = this->cellScalarResults(ntgResultIdx)[0].size();
size_t ntgResultValueCount = m_cellScalarResults[ntgResultIdx][0].size();
resultValueCount = CVF_MIN(permxResultValueCount, ntgResultValueCount);
}
// Get all the actual result values
std::vector<double>& permResults = this->cellScalarResults(permResultIdx)[0];
std::vector<double>& riTransResults = this->cellScalarResults(riTransResultIdx)[0];
std::vector<double>& permResults = m_cellScalarResults[permResultIdx][0];
std::vector<double>& riTransResults = m_cellScalarResults[riTransResultIdx][0];
std::vector<double>* ntgResults = nullptr;
if (hasNTGResults)
{
ntgResults = &(this->cellScalarResults(ntgResultIdx)[0]);
ntgResults = &( m_cellScalarResults[ntgResultIdx][0]);
}
// Set up output container to correct number of results
@@ -1864,12 +1875,12 @@ void RigCaseCellResultsData::computeRiTransComponent(const QString& riTransCompo
ResultIndexFunction permIdxFunc = nullptr;
ResultIndexFunction ntgIdxFunc = nullptr;
{
bool isPermUsingResIdx = this->isUsingGlobalActiveIndex(permResultIdx);
bool isTransUsingResIdx = this->isUsingGlobalActiveIndex(riTransResultIdx);
bool isPermUsingResIdx = this->isUsingGlobalActiveIndex(RigEclipseResultAddress(permResultIdx));
bool isTransUsingResIdx = this->isUsingGlobalActiveIndex(RigEclipseResultAddress(riTransResultIdx));
bool isNtgUsingResIdx = false;
if (hasNTGResults)
{
isNtgUsingResIdx = this->isUsingGlobalActiveIndex(ntgResultIdx);
isNtgUsingResIdx = this->isUsingGlobalActiveIndex(RigEclipseResultAddress(ntgResultIdx));
}
// Set up result index function pointers
@@ -1995,9 +2006,9 @@ void RigCaseCellResultsData::computeNncCombRiTrans()
// Get all the actual result values
std::vector<double>& permXResults = this->cellScalarResults(permXResultIdx)[0];
std::vector<double>& permYResults = this->cellScalarResults(permYResultIdx)[0];
std::vector<double>& permZResults = this->cellScalarResults(permZResultIdx)[0];
std::vector<double>& permXResults = m_cellScalarResults[permXResultIdx][0];
std::vector<double>& permYResults = m_cellScalarResults[permYResultIdx][0];
std::vector<double>& permZResults = m_cellScalarResults[permZResultIdx][0];
std::vector<double>& riCombTransResults =
m_ownerMainGrid->nncData()->makeStaticConnectionScalarResult(RigNNCData::propertyNameRiCombTrans());
m_ownerMainGrid->nncData()->setScalarResultIndex(RigNNCData::propertyNameRiCombTrans(), riCombTransScalarResultIndex);
@@ -2005,7 +2016,7 @@ void RigCaseCellResultsData::computeNncCombRiTrans()
std::vector<double>* ntgResults = nullptr;
if (hasNTGResults)
{
ntgResults = &(this->cellScalarResults(ntgResultIdx)[0]);
ntgResults = &(m_cellScalarResults[ntgResultIdx][0]);
}
// Prepare how to index the result values:
@@ -2014,13 +2025,13 @@ void RigCaseCellResultsData::computeNncCombRiTrans()
ResultIndexFunction permZIdxFunc = nullptr;
ResultIndexFunction ntgIdxFunc = nullptr;
{
bool isPermXUsingResIdx = this->isUsingGlobalActiveIndex(permXResultIdx);
bool isPermYUsingResIdx = this->isUsingGlobalActiveIndex(permYResultIdx);
bool isPermZUsingResIdx = this->isUsingGlobalActiveIndex(permZResultIdx);
bool isPermXUsingResIdx = this->isUsingGlobalActiveIndex(RigEclipseResultAddress(permXResultIdx));
bool isPermYUsingResIdx = this->isUsingGlobalActiveIndex(RigEclipseResultAddress(permYResultIdx));
bool isPermZUsingResIdx = this->isUsingGlobalActiveIndex(RigEclipseResultAddress(permZResultIdx));
bool isNtgUsingResIdx = false;
if (hasNTGResults)
{
isNtgUsingResIdx = this->isUsingGlobalActiveIndex(ntgResultIdx);
isNtgUsingResIdx = this->isUsingGlobalActiveIndex(RigEclipseResultAddress(ntgResultIdx));
}
// Set up result index function pointers
@@ -2205,16 +2216,15 @@ void RigCaseCellResultsData::computeRiMULTComponent(const QString& riMultCompNam
// Get the result count, to handle that one of them might be globally defined
CVF_ASSERT(this->cellScalarResults(riTransResultIdx)[0].size() == this->cellScalarResults(transResultIdx)[0].size());
CVF_ASSERT(m_cellScalarResults[riTransResultIdx][0].size() == m_cellScalarResults[transResultIdx][0].size());
size_t resultValueCount = this->cellScalarResults(transResultIdx)[0].size();
size_t resultValueCount = m_cellScalarResults[transResultIdx][0].size();
// Get all the actual result values
std::vector<double>& riTransResults = this->cellScalarResults(riTransResultIdx)[0];
std::vector<double>& transResults = this->cellScalarResults(transResultIdx)[0];
std::vector<double>& riMultResults = this->cellScalarResults(riMultResultIdx)[0];
std::vector<double>& riTransResults = m_cellScalarResults[riTransResultIdx][0];
std::vector<double>& transResults = m_cellScalarResults[transResultIdx][0];
std::vector<double>& riMultResults = m_cellScalarResults[riMultResultIdx][0];
// Set up output container to correct number of results
@@ -2295,12 +2305,12 @@ void RigCaseCellResultsData::computeRiTRANSbyAreaComponent(const QString& riTran
// Get the result count, to handle that one of them might be globally defined
size_t resultValueCount = this->cellScalarResults(tranCompScResIdx)[0].size();
size_t resultValueCount = m_cellScalarResults[tranCompScResIdx][0].size();
// Get all the actual result values
std::vector<double>& transResults = this->cellScalarResults(tranCompScResIdx)[0];
std::vector<double>& riTransByAreaResults = this->cellScalarResults(riTranByAreaScResIdx)[0];
std::vector<double>& transResults = m_cellScalarResults[tranCompScResIdx][0];
std::vector<double>& riTransByAreaResults = m_cellScalarResults[riTranByAreaScResIdx][0];
// Set up output container to correct number of results
@@ -2308,7 +2318,7 @@ void RigCaseCellResultsData::computeRiTRANSbyAreaComponent(const QString& riTran
// Prepare how to index the result values:
bool isUsingResIdx = this->isUsingGlobalActiveIndex(tranCompScResIdx);
bool isUsingResIdx = this->isUsingGlobalActiveIndex(RigEclipseResultAddress(tranCompScResIdx));
// Set up result index function pointers
@@ -2400,12 +2410,12 @@ void RigCaseCellResultsData::computeCompletionTypeForTimeStep(size_t timeStep)
size_t completionTypeResultIndex =
this->findScalarResultIndex(RiaDefines::DYNAMIC_NATIVE, RiaDefines::completionTypeResultName());
if (this->cellScalarResults(completionTypeResultIndex).size() < this->maxTimeStepCount())
if (m_cellScalarResults[completionTypeResultIndex].size() < this->maxTimeStepCount())
{
this->cellScalarResults(completionTypeResultIndex).resize(this->maxTimeStepCount());
m_cellScalarResults[completionTypeResultIndex].resize(this->maxTimeStepCount());
}
std::vector<double>& completionTypeResult = this->cellScalarResults(completionTypeResultIndex, timeStep);
std::vector<double>& completionTypeResult = m_cellScalarResults[completionTypeResultIndex][timeStep];
size_t resultValues = m_ownerMainGrid->globalCellArray().size();
@@ -2439,11 +2449,11 @@ void RigCaseCellResultsData::computeCellVolumes()
{
size_t cellVolIdx = this->findOrCreateScalarResultIndex(RiaDefines::STATIC_NATIVE, RiaDefines::riCellVolumeResultName(), false);
if (this->cellScalarResults(cellVolIdx).empty())
if (m_cellScalarResults[cellVolIdx].empty())
{
this->cellScalarResults(cellVolIdx).resize(1);
m_cellScalarResults[cellVolIdx].resize(1);
}
std::vector<double>& cellVolumeResults = this->cellScalarResults(cellVolIdx)[0];
std::vector<double>& cellVolumeResults = m_cellScalarResults[cellVolIdx][0];
size_t cellResultCount = m_activeCellInfo->reservoirCellResultCount();
cellVolumeResults.resize(cellResultCount, std::numeric_limits<double>::infinity());
@@ -2472,17 +2482,17 @@ void RigCaseCellResultsData::computeCellVolumes()
void RigCaseCellResultsData::computeOilVolumes()
{
size_t cellVolIdx = this->findOrCreateScalarResultIndex(RiaDefines::STATIC_NATIVE, RiaDefines::riCellVolumeResultName(), false);
const std::vector<double>& cellVolumeResults = this->cellScalarResults(cellVolIdx)[0];
const std::vector<double>& cellVolumeResults = m_cellScalarResults[cellVolIdx][0];
size_t soilIdx = this->findOrLoadScalarResult(RiaDefines::DYNAMIC_NATIVE, "SOIL");
size_t oilVolIdx = this->findOrCreateScalarResultIndex(RiaDefines::DYNAMIC_NATIVE, RiaDefines::riOilVolumeResultName(), false);
this->cellScalarResults(oilVolIdx).resize(this->maxTimeStepCount());
m_cellScalarResults[oilVolIdx].resize(this->maxTimeStepCount());
size_t cellResultCount = m_activeCellInfo->reservoirCellResultCount();
for (size_t timeStepIdx = 0; timeStepIdx < this->maxTimeStepCount(); timeStepIdx++)
{
const std::vector<double>& soilResults = this->cellScalarResults(soilIdx)[timeStepIdx];
std::vector<double>& oilVolumeResults = this->cellScalarResults(oilVolIdx)[timeStepIdx];
const std::vector<double>& soilResults = m_cellScalarResults[soilIdx][timeStepIdx];
std::vector<double>& oilVolumeResults = m_cellScalarResults[oilVolIdx][timeStepIdx];
oilVolumeResults.resize(cellResultCount, 0u);
#pragma omp parallel for
@@ -2525,7 +2535,7 @@ void RigCaseCellResultsData::computeMobilePV()
size_t mobPVIdx = this->findOrCreateScalarResultIndex(RiaDefines::STATIC_NATIVE, RiaDefines::mobilePoreVolumeName(), false);
std::vector<double>& mobPVResults = this->cellScalarResults(mobPVIdx)[0];
std::vector<double>& mobPVResults = m_cellScalarResults[mobPVIdx][0];
// Set up output container to correct number of results
mobPVResults.resize(porvResults->size());
@@ -2587,7 +2597,7 @@ bool RigCaseCellResultsData::isDataPresent(size_t scalarResultIndex) const
return false;
}
const std::vector<std::vector<double>>& data = this->cellScalarResults(scalarResultIndex);
const std::vector<std::vector<double>>& data = m_cellScalarResults[scalarResultIndex];
for (size_t tsIdx = 0; tsIdx < data.size(); ++tsIdx)
{
@@ -2656,3 +2666,11 @@ void RigCaseCellResultsData::assignValuesToTemporaryLgrs(const QString& re
RiaLogging::warning("Detected invalid/undefined cells when assigning result values to temporary LGRs");
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigStatisticsDataCache* RigCaseCellResultsData::statistics(const RigEclipseResultAddress& resVarAddr)
{
return m_statisticsDataCache[resVarAddr.scalarResultIndex].p();
}

View File

@@ -37,6 +37,38 @@ class RigStatisticsDataCache;
class RigEclipseTimeStepInfo;
class RigEclipseCaseData;
class RigEclipseResultAddress
{
public:
RigEclipseResultAddress()
: scalarResultIndex(-1)
, m_resultCatType(RiaDefines::UNDEFINED)
{}
explicit RigEclipseResultAddress(size_t ascalarResultIndex)
: scalarResultIndex(ascalarResultIndex)
, m_resultCatType(RiaDefines::UNDEFINED)
{}
explicit RigEclipseResultAddress(RiaDefines::ResultCatType type, const QString& resultName)
: scalarResultIndex(-1)
, m_resultCatType(type)
, m_resultName(resultName)
{}
bool isValid() const
{
return (scalarResultIndex != -1);
// Todo
}
size_t scalarResultIndex;
RiaDefines::ResultCatType m_resultCatType;
QString m_resultName;
};
//==================================================================================================
/// Class containing the results for the complete number of active cells. Both main grid and LGR's
//==================================================================================================
@@ -54,39 +86,39 @@ public:
const RigActiveCellInfo* activeCellInfo() const;
// Max and min values of the results
void recalculateStatistics(size_t scalarResultIndex);
void minMaxCellScalarValues(size_t scalarResultIndex, double& min, double& max);
void minMaxCellScalarValues(size_t scalarResultIndex, size_t timeStepIndex, double& min, double& max);
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);
const std::vector<int>& 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, double& meanValue);
void mobileVolumeWeightedMean(size_t scalarResultIndex, size_t timeStepIndex, double& meanValue);
void recalculateStatistics(const RigEclipseResultAddress& resVarAddr);
void minMaxCellScalarValues(const RigEclipseResultAddress& resVarAddr, double& min, double& max);
void minMaxCellScalarValues(const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex, double& min, double& max);
void posNegClosestToZero(const RigEclipseResultAddress& resVarAddr, double& pos, double& neg);
void posNegClosestToZero(const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex, double& pos, double& neg);
const std::vector<size_t>& cellScalarValuesHistogram(const RigEclipseResultAddress& resVarAddr);
const std::vector<size_t>& cellScalarValuesHistogram(const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex);
void p10p90CellScalarValues(const RigEclipseResultAddress& resVarAddr, double& p10, double& p90);
void p10p90CellScalarValues(const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex, double& p10, double& p90);
void meanCellScalarValues(const RigEclipseResultAddress& resVarAddr, double& meanValue);
void meanCellScalarValues(const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex, double& meanValue);
const std::vector<int>& uniqueCellScalarValues(const RigEclipseResultAddress& resVarAddr);
void sumCellScalarValues(const RigEclipseResultAddress& resVarAddr, double& sumValue);
void sumCellScalarValues(const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex, double& sumValue);
void mobileVolumeWeightedMean(const RigEclipseResultAddress& resVarAddr, double& meanValue);
void mobileVolumeWeightedMean(const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex, double& meanValue);
// Access meta-information about the results
size_t resultCount() const;
size_t timeStepCount(size_t scalarResultIndex) const;
size_t timeStepCount(const RigEclipseResultAddress& resVarAddr) const;
size_t maxTimeStepCount(size_t* scalarResultIndex = nullptr) const;
QStringList resultNames(RiaDefines::ResultCatType type) const;
bool isUsingGlobalActiveIndex(size_t scalarResultIndex) const;
bool isUsingGlobalActiveIndex(const RigEclipseResultAddress& resVarAddr) const;
bool hasFlowDiagUsableFluxes() const;
std::vector<QDateTime> allTimeStepDatesFromEclipseReader() const;
std::vector<QDateTime> timeStepDates() const;
std::vector<QDateTime> timeStepDates(size_t scalarResultIndex) const;
std::vector<QDateTime> timeStepDates(const RigEclipseResultAddress& resVarAddr) const;
std::vector<double> daysSinceSimulationStart() const;
std::vector<double> daysSinceSimulationStart(size_t scalarResultIndex) const;
int reportStepNumber(size_t scalarResultIndex, size_t timeStepIndex) const;
std::vector<double> daysSinceSimulationStart(const RigEclipseResultAddress& resVarAddr) const;
int reportStepNumber(const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex) const;
std::vector<RigEclipseTimeStepInfo> timeStepInfos(size_t scalarResultIndex) const;
void setTimeStepInfos(size_t scalarResultIndex, const std::vector<RigEclipseTimeStepInfo>& timeStepInfos);
std::vector<RigEclipseTimeStepInfo> timeStepInfos(const RigEclipseResultAddress& resVarAddr) const;
void setTimeStepInfos(const RigEclipseResultAddress& resVarAddr, const std::vector<RigEclipseTimeStepInfo>& timeStepInfos);
size_t findOrLoadScalarResultForTimeStep(RiaDefines::ResultCatType type, const QString& resultName, size_t timeStepIndex);
size_t findOrLoadScalarResult(RiaDefines::ResultCatType type, const QString& resultName);
@@ -113,9 +145,10 @@ public:
// Access the results data
const std::vector< std::vector<double> > & cellScalarResults(size_t scalarResultIndex) const;
std::vector< std::vector<double> > & cellScalarResults(size_t scalarResultIndex);
std::vector<double>& cellScalarResults(size_t scalarResultIndex, size_t timeStepIndex);
const std::vector< std::vector<double> > & cellScalarResults(const RigEclipseResultAddress& resVarAddr) const;
std::vector< std::vector<double> > & cellScalarResults(const RigEclipseResultAddress& resVarAddr);
const std::vector<double>& cellScalarResults(const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex) const;
std::vector<double>& cellScalarResults(const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex);
bool updateResultName(RiaDefines::ResultCatType resultType, QString& oldName, const QString& newName);
@@ -167,7 +200,7 @@ private: // from RimReservoirCellResultsStorage
private:
std::vector< std::vector< std::vector<double> > > m_cellScalarResults; ///< Scalar results on the complete reservoir for each Result index (ResultVariable) and timestep
cvf::Collection<RigStatisticsDataCache> m_statisticsDataCache;
RigStatisticsDataCache* statistics(const RigEclipseResultAddress& resVarAddr);
private:
std::vector<RigEclipseResultInfo> m_resultInfos;

View File

@@ -683,7 +683,7 @@ void RigEclipseCaseData::setActiveFormationNames(RigFormationNames* activeFormat
false,
totalGlobCellCount);
std::vector<double>& fnData = m_matrixModelResults->cellScalarResults(resIndex,0);
std::vector<double>& fnData = m_matrixModelResults->cellScalarResults(RigEclipseResultAddress(resIndex),0);
if (m_activeFormationNamesData.isNull())
{
@@ -790,7 +790,7 @@ const std::vector<double>* RigEclipseCaseData::resultValues(RiaDefines::Porosity
const std::vector<double>* swatResults = nullptr;
if (scalarResultIndex != cvf::UNDEFINED_SIZE_T)
{
swatResults = &(gridCellResults->cellScalarResults(scalarResultIndex, timeStepIndex));
swatResults = &(gridCellResults->cellScalarResults(RigEclipseResultAddress(scalarResultIndex), timeStepIndex));
}
return swatResults;

View File

@@ -93,7 +93,7 @@ void RigEclipseNativeStatCalc::valueSumAndSampleCount(size_t timeStepIndex, doub
//--------------------------------------------------------------------------------------------------
size_t RigEclipseNativeStatCalc::timeStepCount()
{
return m_resultsData->timeStepCount(m_scalarResultIndex);
return m_resultsData->timeStepCount(RigEclipseResultAddress(m_scalarResultIndex));
}
//--------------------------------------------------------------------------------------------------
@@ -110,10 +110,10 @@ void RigEclipseNativeStatCalc::mobileVolumeWeightedMean(size_t timeStepIndex, do
return;
}
const std::vector<double>& weights = m_resultsData->cellScalarResults(mobPVResultIndex, 0);
const std::vector<double>& values = m_resultsData->cellScalarResults(m_scalarResultIndex, timeStepIndex);
const std::vector<double>& weights = m_resultsData->cellScalarResults(RigEclipseResultAddress(mobPVResultIndex), 0);
const std::vector<double>& values = m_resultsData->cellScalarResults(RigEclipseResultAddress(m_scalarResultIndex), timeStepIndex);
const RigActiveCellInfo* actCellInfo = m_resultsData->activeCellInfo();
RigWeightedMeanCalc::weightedMeanOverCells(&weights, &values, nullptr, false, actCellInfo, m_resultsData->isUsingGlobalActiveIndex(m_scalarResultIndex), &mean);
RigWeightedMeanCalc::weightedMeanOverCells(&weights, &values, nullptr, false, actCellInfo, m_resultsData->isUsingGlobalActiveIndex(RigEclipseResultAddress(m_scalarResultIndex)), &mean);
}

View File

@@ -50,12 +50,12 @@ private:
template <typename StatisticsAccumulator>
void traverseCells(StatisticsAccumulator& accumulator, size_t timeStepIndex)
{
if (timeStepIndex >= m_resultsData->cellScalarResults(m_scalarResultIndex).size())
if (timeStepIndex >= m_resultsData->cellScalarResults(RigEclipseResultAddress(m_scalarResultIndex)).size())
{
return;
}
std::vector<double>& values = m_resultsData->cellScalarResults(m_scalarResultIndex, timeStepIndex);
std::vector<double>& values = m_resultsData->cellScalarResults(RigEclipseResultAddress(m_scalarResultIndex), timeStepIndex);
if (values.empty())
{
@@ -72,7 +72,7 @@ private:
if (!actCellInfo->isActive(cIdx)) continue;
size_t cellResultIndex = cIdx;
if (m_resultsData->isUsingGlobalActiveIndex(m_scalarResultIndex))
if (m_resultsData->isUsingGlobalActiveIndex(RigEclipseResultAddress(m_scalarResultIndex)))
{
cellResultIndex = actCellInfo->cellResultIndex(cIdx);
}

View File

@@ -31,10 +31,10 @@
///
//--------------------------------------------------------------------------------------------------
RigEclipseNativeVisibleCellsStatCalc::RigEclipseNativeVisibleCellsStatCalc(RigCaseCellResultsData* cellResultsData,
size_t scalarResultIndex,
const RigEclipseResultAddress& scalarResultIndex,
const cvf::UByteArray* cellVisibilities)
: m_caseData(cellResultsData),
m_scalarResultIndex(scalarResultIndex),
m_resultAddress(scalarResultIndex),
m_cellVisibilities(cellVisibilities)
{
@@ -97,7 +97,7 @@ void RigEclipseNativeVisibleCellsStatCalc::uniqueValues(size_t timeStepIndex, st
//--------------------------------------------------------------------------------------------------
size_t RigEclipseNativeVisibleCellsStatCalc::timeStepCount()
{
return m_caseData->timeStepCount(m_scalarResultIndex);
return m_caseData->timeStepCount(m_resultAddress);
}
//--------------------------------------------------------------------------------------------------
@@ -107,11 +107,11 @@ void RigEclipseNativeVisibleCellsStatCalc::mobileVolumeWeightedMean(size_t timeS
{
size_t mobPVResultIndex = m_caseData->findOrLoadScalarResult(RiaDefines::ResultCatType::STATIC_NATIVE, RiaDefines::mobilePoreVolumeName());
const std::vector<double>& weights = m_caseData->cellScalarResults(mobPVResultIndex)[0];
const std::vector<double>& values = m_caseData->cellScalarResults(m_scalarResultIndex, timeStepIndex);
const std::vector<double>& weights = m_caseData->cellScalarResults(RigEclipseResultAddress(mobPVResultIndex), 0);
const std::vector<double>& values = m_caseData->cellScalarResults(m_resultAddress, timeStepIndex);
const RigActiveCellInfo* actCellInfo = m_caseData->activeCellInfo();
RigWeightedMeanCalc::weightedMeanOverCells(&weights, &values, m_cellVisibilities.p(), true, actCellInfo, m_caseData->isUsingGlobalActiveIndex(m_scalarResultIndex), &result);
RigWeightedMeanCalc::weightedMeanOverCells(&weights, &values, m_cellVisibilities.p(), true, actCellInfo, m_caseData->isUsingGlobalActiveIndex(m_resultAddress), &result);
}

View File

@@ -36,7 +36,7 @@ class RigEclipseNativeVisibleCellsStatCalc : public RigStatisticsCalculator
{
public:
RigEclipseNativeVisibleCellsStatCalc(RigCaseCellResultsData* cellResultsData,
size_t scalarResultIndex,
const RigEclipseResultAddress& scalarResultIndex,
const cvf::UByteArray* cellVisibilities);
void minMaxCellScalarValues(size_t timeStepIndex, double& min, double& max) override;
@@ -50,13 +50,13 @@ public:
private:
RigCaseCellResultsData* m_caseData;
size_t m_scalarResultIndex;
RigEclipseResultAddress m_resultAddress;
cvf::cref<cvf::UByteArray> m_cellVisibilities;
template <typename StatisticsAccumulator>
void traverseCells(StatisticsAccumulator& accumulator, size_t timeStepIndex)
{
std::vector<double>& values = m_caseData->cellScalarResults(m_scalarResultIndex, timeStepIndex);
std::vector<double>& values = m_caseData->cellScalarResults(m_resultAddress, timeStepIndex);
if (values.empty())
{
@@ -74,7 +74,7 @@ private:
if (!(*m_cellVisibilities)[cIdx]) continue;
size_t cellResultIndex = cIdx;
if (m_caseData->isUsingGlobalActiveIndex(m_scalarResultIndex))
if (m_caseData->isUsingGlobalActiveIndex(m_resultAddress))
{
cellResultIndex = actCellInfo->cellResultIndex(cIdx);
}

View File

@@ -324,7 +324,7 @@ RigFlowDiagTimeStepResult RigFlowDiagSolverInterface::calculate(size_t timeStepI
size_t resultIndexWithMaxTimeSteps = cvf::UNDEFINED_SIZE_T;
m_eclipseCase->eclipseCaseData()->results(RiaDefines::MATRIX_MODEL)->maxTimeStepCount(&resultIndexWithMaxTimeSteps);
int reportStepNumber = m_eclipseCase->eclipseCaseData()->results(RiaDefines::MATRIX_MODEL)->reportStepNumber(resultIndexWithMaxTimeSteps, timeStepIndex);
int reportStepNumber = m_eclipseCase->eclipseCaseData()->results(RiaDefines::MATRIX_MODEL)->reportStepNumber(RigEclipseResultAddress(resultIndexWithMaxTimeSteps), timeStepIndex);
if ( !currentRestartData->selectReportStep(reportStepNumber) )
{

View File

@@ -122,7 +122,7 @@ void RigFlowDiagStatCalc::mobileVolumeWeightedMean(size_t timeStepIndex, double&
size_t mobPVResultIndex = caseCellResultsData->findOrLoadScalarResult(RiaDefines::ResultCatType::STATIC_NATIVE, RiaDefines::mobilePoreVolumeName());
const std::vector<double>& weights = caseCellResultsData->cellScalarResults(mobPVResultIndex, 0);
const std::vector<double>& weights = caseCellResultsData->cellScalarResults(RigEclipseResultAddress(mobPVResultIndex), 0);
const std::vector<double>* values = m_resultsData->resultValues(m_resVarAddr, timeStepIndex);
const RigActiveCellInfo* actCellInfo = m_resultsData->activeCellInfo(m_resVarAddr);

View File

@@ -111,7 +111,7 @@ void RigFlowDiagVisibleCellsStatCalc::mobileVolumeWeightedMean(size_t timeStepIn
size_t mobPVResultIndex = caseCellResultsData->findOrLoadScalarResult(RiaDefines::ResultCatType::STATIC_NATIVE, RiaDefines::mobilePoreVolumeName());
const std::vector<double>& weights = caseCellResultsData->cellScalarResults(mobPVResultIndex, 0);
const std::vector<double>& weights = caseCellResultsData->cellScalarResults(RigEclipseResultAddress(mobPVResultIndex), 0);
const std::vector<double>* values = m_resultsData->resultValues(m_resVarAddr, timeStepIndex);
const RigActiveCellInfo* actCellInfo = m_resultsData->activeCellInfo(m_resVarAddr);

View File

@@ -109,7 +109,7 @@ RigNumberOfFloodedPoreVolumesCalculator::RigNumberOfFloodedPoreVolumesCalculator
const std::vector<double>* flowrateI = nullptr;
if (scalarResultIndexFlowrateI != cvf::UNDEFINED_SIZE_T)
{
flowrateI = &(eclipseCaseData->results(RiaDefines::MATRIX_MODEL)->cellScalarResults(scalarResultIndexFlowrateI,
flowrateI = &(eclipseCaseData->results(RiaDefines::MATRIX_MODEL)->cellScalarResults(RigEclipseResultAddress(scalarResultIndexFlowrateI),
timeStep));
}
flowrateIatAllTimeSteps.push_back(flowrateI);
@@ -118,7 +118,7 @@ RigNumberOfFloodedPoreVolumesCalculator::RigNumberOfFloodedPoreVolumesCalculator
const std::vector<double>* flowrateJ = nullptr;
if (scalarResultIndexFlowrateJ != cvf::UNDEFINED_SIZE_T)
{
flowrateJ = &(eclipseCaseData->results(RiaDefines::MATRIX_MODEL)->cellScalarResults(scalarResultIndexFlowrateJ,
flowrateJ = &(eclipseCaseData->results(RiaDefines::MATRIX_MODEL)->cellScalarResults(RigEclipseResultAddress(scalarResultIndexFlowrateJ),
timeStep));
}
flowrateJatAllTimeSteps.push_back(flowrateJ);
@@ -127,7 +127,7 @@ RigNumberOfFloodedPoreVolumesCalculator::RigNumberOfFloodedPoreVolumesCalculator
const std::vector<double>* flowrateK = nullptr;
if (scalarResultIndexFlowrateK != cvf::UNDEFINED_SIZE_T)
{
flowrateK = &(eclipseCaseData->results(RiaDefines::MATRIX_MODEL)->cellScalarResults(scalarResultIndexFlowrateK,
flowrateK = &(eclipseCaseData->results(RiaDefines::MATRIX_MODEL)->cellScalarResults(RigEclipseResultAddress(scalarResultIndexFlowrateK),
timeStep));
}
flowrateKatAllTimeSteps.push_back(flowrateK);
@@ -144,7 +144,7 @@ RigNumberOfFloodedPoreVolumesCalculator::RigNumberOfFloodedPoreVolumesCalculator
{
if (tracerIndex != cvf::UNDEFINED_SIZE_T)
{
const std::vector<double>* tracerResult = &(eclipseCaseData->results(RiaDefines::MATRIX_MODEL)->cellScalarResults(tracerIndex, timeStep));
const std::vector<double>* tracerResult = &(eclipseCaseData->results(RiaDefines::MATRIX_MODEL)->cellScalarResults(RigEclipseResultAddress(tracerIndex), timeStep));
for (size_t i = 0; i < summedTracerValues.size(); i++)
{

View File

@@ -91,7 +91,7 @@ cvf::ref<RigResultAccessor> RigResultAccessorFactory::createFromNameAndType(cons
adjustedTimeStepIndex = 0;
}
return createFromResultIdx(eclipseCase, gridIndex, porosityModel, adjustedTimeStepIndex, scalarSetIndex);
return createFromResultIdx(eclipseCase, gridIndex, porosityModel, adjustedTimeStepIndex, RigEclipseResultAddress(scalarSetIndex));
}
//--------------------------------------------------------------------------------------------------
@@ -154,7 +154,7 @@ cvf::ref<RigResultAccessor> RigResultAccessorFactory::createNativeFromUiResultNa
return nullptr;
}
return createFromResultIdx(eclipseCase, gridIndex, porosityModel, timeStepIndex, scalarSetIndex);
return createFromResultIdx(eclipseCase, gridIndex, porosityModel, timeStepIndex, RigEclipseResultAddress(scalarSetIndex));
}
//--------------------------------------------------------------------------------------------------
@@ -306,9 +306,9 @@ cvf::ref<RigResultAccessor> RigResultAccessorFactory::createFromResultIdx(const
size_t gridIndex,
RiaDefines::PorosityModelType porosityModel,
size_t timeStepIndex,
size_t resultIndex)
const RigEclipseResultAddress& resultIndex)
{
if ( resultIndex == cvf::UNDEFINED_SIZE_T )
if ( !resultIndex.isValid() )
{
return new RigHugeValResultAccessor;
}
@@ -318,7 +318,7 @@ cvf::ref<RigResultAccessor> RigResultAccessorFactory::createFromResultIdx(const
const RigGridBase* grid = eclipseCase->grid(gridIndex);
if (!grid) return nullptr;
const std::vector< std::vector<double> >& scalarSetResults = eclipseCase->results(porosityModel)->cellScalarResults(resultIndex);
const std::vector< std::vector<double> >& scalarSetResults = eclipseCase->results(porosityModel)->cellScalarResults(RigEclipseResultAddress(resultIndex));
if (timeStepIndex >= scalarSetResults.size())
{
@@ -336,7 +336,7 @@ cvf::ref<RigResultAccessor> RigResultAccessorFactory::createFromResultIdx(const
return new RigHugeValResultAccessor;
}
bool useGlobalActiveIndex = eclipseCase->results(porosityModel)->isUsingGlobalActiveIndex(resultIndex);
bool useGlobalActiveIndex = eclipseCase->results(porosityModel)->isUsingGlobalActiveIndex(RigEclipseResultAddress(resultIndex));
if (useGlobalActiveIndex)
{
cvf::ref<RigResultAccessor> object = new RigActiveCellsResultAccessor(grid, resultValues, eclipseCase->activeCellInfo(porosityModel));

View File

@@ -28,6 +28,7 @@ class RigActiveCellInfo;
class RigGridBase;
class RimEclipseResultDefinition;
class RigEclipseResultAddress;
class RigResultAccessorFactory
{
@@ -58,7 +59,7 @@ public:
size_t gridIndex,
RiaDefines::PorosityModelType porosityModel,
size_t timeStepIndex,
size_t resultIndex);
const RigEclipseResultAddress& resultIndex);

View File

@@ -74,7 +74,7 @@ cvf::ref<RigResultModifier> RigResultModifierFactory::createResultModifier(RigEc
return nullptr;
}
std::vector< std::vector<double> >& scalarSetResults = eclipseCase->results(porosityModel)->cellScalarResults(scalarResultIndex);
std::vector< std::vector<double> >& scalarSetResults = eclipseCase->results(porosityModel)->cellScalarResults(RigEclipseResultAddress(scalarResultIndex));
if (timeStepIndex >= scalarSetResults.size())
{
@@ -87,7 +87,7 @@ cvf::ref<RigResultModifier> RigResultModifierFactory::createResultModifier(RigEc
resultValues = &(scalarSetResults[timeStepIndex]);
}
bool useGlobalActiveIndex = eclipseCase->results(porosityModel)->isUsingGlobalActiveIndex(scalarResultIndex);
bool useGlobalActiveIndex = eclipseCase->results(porosityModel)->isUsingGlobalActiveIndex(RigEclipseResultAddress(scalarResultIndex));
if (useGlobalActiveIndex)
{
cvf::ref<RigResultModifier> object = new RigActiveCellsResultModifier(grid, eclipseCase->activeCellInfo(porosityModel), resultValues);