#3958 Refactoring CaseCellResultsData to propagate result address with timelapse info all the way.

This commit is contained in:
Jacob Støren committed 2019-01-29 12:44:23 +01:00
1 parent 0a22515a3e
commit 8a5cbf60fd
5 files changed
+280 -265

No files matched your search

@@ -263,67 +263,14 @@ const std::vector<double>& RigCaseCellResultsData::cellScalarResults(const RigEc
return m_cellScalarResults[scalarResultIndex][timeStepIndex]; return m_cellScalarResults[scalarResultIndex][timeStepIndex];
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RigCaseCellResultsData::findScalarResultIndex(RiaDefines::ResultCatType type, const QString& resultName) const
{
std::vector<RigEclipseResultInfo>::const_iterator it;
for (it = m_resultInfos.begin(); it != m_resultInfos.end(); ++it)
{
if (it->resultType() == type && it->resultName() == resultName)
{
return it->gridScalarResultIndex();
}
}
return cvf::UNDEFINED_SIZE_T;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RigCaseCellResultsData::findScalarResultIndex(const QString& resultName) const
{
size_t scalarResultIndex = this->findScalarResultIndex(RiaDefines::STATIC_NATIVE, resultName);
if (scalarResultIndex == cvf::UNDEFINED_SIZE_T)
{
scalarResultIndex = this->findScalarResultIndex(RiaDefines::DYNAMIC_NATIVE, resultName);
}
if (scalarResultIndex == cvf::UNDEFINED_SIZE_T)
{
scalarResultIndex = this->findScalarResultIndex(RiaDefines::SOURSIMRL, resultName);
}
if (scalarResultIndex == cvf::UNDEFINED_SIZE_T)
{
scalarResultIndex = this->findScalarResultIndex(RiaDefines::GENERATED, resultName);
}
if (scalarResultIndex == cvf::UNDEFINED_SIZE_T)
{
scalarResultIndex = this->findScalarResultIndex(RiaDefines::INPUT_PROPERTY, resultName);
}
if (scalarResultIndex == cvf::UNDEFINED_SIZE_T)
{
scalarResultIndex = this->findScalarResultIndex(RiaDefines::FORMATION_NAMES, resultName);
}
return scalarResultIndex;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// Adds an empty scalar set, and returns the scalarResultIndex to it. /// Adds an empty scalar set, and returns the scalarResultIndex to it.
/// if resultName already exists, it just returns the scalarResultIndex to the existing result. /// if resultName already exists, it just returns the scalarResultIndex to the existing result.
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
size_t RigCaseCellResultsData::findOrCreateScalarResultIndex(RiaDefines::ResultCatType type, size_t RigCaseCellResultsData::findOrCreateScalarResultIndex(const RigEclipseResultAddress& resVarAddr,
const QString& resultName,
bool needsToBeStored) bool needsToBeStored)
{ {
size_t scalarResultIndex = this->findScalarResultIndex(type, resultName); size_t scalarResultIndex = this->findScalarResultIndexFromAddress(resVarAddr);
// If the result exists, do nothing // If the result exists, do nothing
@@ -336,11 +283,15 @@ size_t RigCaseCellResultsData::findOrCreateScalarResultIndex(RiaDefines::ResultC
scalarResultIndex = this->resultCount(); scalarResultIndex = this->resultCount();
m_cellScalarResults.push_back(std::vector<std::vector<double>>()); m_cellScalarResults.push_back(std::vector<std::vector<double>>());
RigEclipseResultInfo resInfo(type, resultName, needsToBeStored, false, scalarResultIndex);
RigEclipseResultInfo resInfo(resVarAddr, needsToBeStored, false, scalarResultIndex);
m_resultInfos.push_back(resInfo); m_resultInfos.push_back(resInfo);
// Create statistics calculator and add statistics cache object // Create statistics calculator and add statistics cache object
// Todo: Move to a "factory" method // Todo: Move to a "factory" method
QString resultName = resVarAddr.m_resultName;
cvf::ref<RigStatisticsCalculator> statisticsCalculator; cvf::ref<RigStatisticsCalculator> statisticsCalculator;
@@ -435,7 +386,7 @@ size_t RigCaseCellResultsData::findOrCreateScalarResultIndex(RiaDefines::ResultC
} }
else else
{ {
statisticsCalculator = new RigEclipseNativeStatCalc(this, RigEclipseResultAddress(type, resultName)); statisticsCalculator = new RigEclipseNativeStatCalc(this, resVarAddr);
} }
cvf::ref<RigStatisticsDataCache> dataCache = new RigStatisticsDataCache(statisticsCalculator.p()); cvf::ref<RigStatisticsDataCache> dataCache = new RigStatisticsDataCache(statisticsCalculator.p());
@@ -646,13 +597,11 @@ size_t RigCaseCellResultsData::maxTimeStepCount(RigEclipseResultAddress* resultA
QString RigCaseCellResultsData::makeResultNameUnique(const QString& resultNameProposal) const QString RigCaseCellResultsData::makeResultNameUnique(const QString& resultNameProposal) const
{ {
QString newResultName = resultNameProposal; QString newResultName = resultNameProposal;
size_t resultIndex = cvf::UNDEFINED_SIZE_T;
int nameNum = 1; int nameNum = 1;
int stringLength = newResultName.size(); int stringLength = newResultName.size();
while (true) while (true)
{ {
resultIndex = this->findScalarResultIndex(newResultName); if( !this->hasResultEntry(RigEclipseResultAddress(newResultName))) break;
if (resultIndex == cvf::UNDEFINED_SIZE_T) break;
newResultName.truncate(stringLength); newResultName.truncate(stringLength);
newResultName += "_" + QString::number(nameNum); newResultName += "_" + QString::number(nameNum);
@@ -739,7 +688,7 @@ size_t RigCaseCellResultsData::addStaticScalarResult(RiaDefines::ResultCatType t
bool needsToBeStored, bool needsToBeStored,
size_t resultValueCount) size_t resultValueCount)
{ {
size_t resultIdx = findOrCreateScalarResultIndex(type, resultName, needsToBeStored); size_t resultIdx = findOrCreateScalarResultIndex(RigEclipseResultAddress(type, resultName), needsToBeStored);
m_cellScalarResults[resultIdx].resize(1, std::vector<double>()); m_cellScalarResults[resultIdx].resize(1, std::vector<double>());
m_cellScalarResults[resultIdx][0].resize(resultValueCount, HUGE_VAL); m_cellScalarResults[resultIdx][0].resize(resultValueCount, HUGE_VAL);
@@ -772,19 +721,20 @@ bool RigCaseCellResultsData::updateResultName(RiaDefines::ResultCatType resultTy
const std::vector<double>* const std::vector<double>*
RigCaseCellResultsData::getResultIndexableStaticResult(RigActiveCellInfo* actCellInfo, RigCaseCellResultsData::getResultIndexableStaticResult(RigActiveCellInfo* actCellInfo,
RigCaseCellResultsData* gridCellResults, RigCaseCellResultsData* gridCellResults,
QString porvResultName, QString resultName,
std::vector<double>& activeCellsResultsTempContainer) std::vector<double>& activeCellsResultsTempContainer)
{ {
size_t resultCellCount = actCellInfo->reservoirCellResultCount(); size_t resultCellCount = actCellInfo->reservoirCellResultCount();
size_t reservoirCellCount = actCellInfo->reservoirCellCount(); size_t reservoirCellCount = actCellInfo->reservoirCellCount();
RigEclipseResultAddress resVarAddr(RiaDefines::STATIC_NATIVE, resultName);
size_t scalarResultIndexPorv = gridCellResults->findOrLoadKnownScalarResult(RiaDefines::STATIC_NATIVE, porvResultName); size_t scalarResultIndexPorv = gridCellResults->findOrLoadKnownScalarResult(resVarAddr);
if (scalarResultIndexPorv == cvf::UNDEFINED_SIZE_T) return nullptr; if (scalarResultIndexPorv == cvf::UNDEFINED_SIZE_T) return nullptr;
const std::vector<double>* porvResults = &(gridCellResults->cellScalarResults(RigEclipseResultAddress(RiaDefines::STATIC_NATIVE, porvResultName), 0)); const std::vector<double>* porvResults = &(gridCellResults->cellScalarResults(resVarAddr, 0));
if (!gridCellResults->isUsingGlobalActiveIndex(RigEclipseResultAddress(RiaDefines::STATIC_NATIVE, porvResultName))) if (!gridCellResults->isUsingGlobalActiveIndex(resVarAddr))
{ {
// PORV is given for all cells // PORV is given for all cells
@@ -868,15 +818,12 @@ void RigCaseCellResultsData::createPlaceholderResultEntries()
{ {
// SOIL // SOIL
{ {
size_t soilIndex = findScalarResultIndex(RiaDefines::DYNAMIC_NATIVE, "SOIL"); if (!hasResultEntry(RigEclipseResultAddress(RiaDefines::DYNAMIC_NATIVE, "SOIL")))
if (soilIndex == cvf::UNDEFINED_SIZE_T)
{ {
size_t swatIndex = findScalarResultIndex(RiaDefines::DYNAMIC_NATIVE, "SWAT"); if ( hasResultEntry(RigEclipseResultAddress(RiaDefines::DYNAMIC_NATIVE, "SWAT"))
size_t sgasIndex = findScalarResultIndex(RiaDefines::DYNAMIC_NATIVE, "SGAS"); || hasResultEntry(RigEclipseResultAddress(RiaDefines::DYNAMIC_NATIVE, "SGAS")) )
if (swatIndex != cvf::UNDEFINED_SIZE_T || sgasIndex != cvf::UNDEFINED_SIZE_T)
{ {
soilIndex = findOrCreateScalarResultIndex(RiaDefines::DYNAMIC_NATIVE, "SOIL", false); size_t soilIndex = findOrCreateScalarResultIndex(RigEclipseResultAddress(RiaDefines::DYNAMIC_NATIVE, "SOIL"), false);
this->setMustBeCalculated(soilIndex); this->setMustBeCalculated(soilIndex);
} }
} }
@@ -885,47 +832,39 @@ void RigCaseCellResultsData::createPlaceholderResultEntries()
// Oil Volume // Oil Volume
if (RiaApplication::enableDevelopmentFeatures()) if (RiaApplication::enableDevelopmentFeatures())
{ {
size_t soilIndex = findOrCreateScalarResultIndex(RiaDefines::DYNAMIC_NATIVE, "SOIL", false); if (hasResultEntry(RigEclipseResultAddress(RiaDefines::DYNAMIC_NATIVE, "SOIL")))
if (soilIndex != cvf::UNDEFINED_SIZE_T)
{ {
findOrCreateScalarResultIndex(RiaDefines::DYNAMIC_NATIVE, RiaDefines::riOilVolumeResultName(), false); findOrCreateScalarResultIndex(RigEclipseResultAddress(RiaDefines::DYNAMIC_NATIVE, RiaDefines::riOilVolumeResultName()), false);
} }
} }
// Completion type // Completion type
{ {
size_t completionTypeIndex = findScalarResultIndex(RiaDefines::DYNAMIC_NATIVE, RiaDefines::completionTypeResultName()); findOrCreateScalarResultIndex(RigEclipseResultAddress (RiaDefines::DYNAMIC_NATIVE, RiaDefines::completionTypeResultName()), false);
if (completionTypeIndex == cvf::UNDEFINED_SIZE_T)
{
findOrCreateScalarResultIndex(RiaDefines::DYNAMIC_NATIVE, RiaDefines::completionTypeResultName(), false);
}
} }
// FLUX // FLUX
{ {
size_t waterIndex = findScalarResultIndex(RiaDefines::DYNAMIC_NATIVE, RiaDefines::combinedWaterFluxResultName()); if ( hasResultEntry(RigEclipseResultAddress(RiaDefines::DYNAMIC_NATIVE, "FLRWATI+"))
if (waterIndex == cvf::UNDEFINED_SIZE_T && && hasResultEntry(RigEclipseResultAddress(RiaDefines::DYNAMIC_NATIVE, "FLRWATJ+"))
findScalarResultIndex(RiaDefines::DYNAMIC_NATIVE, "FLRWATI+") != cvf::UNDEFINED_SIZE_T && && hasResultEntry(RigEclipseResultAddress(RiaDefines::DYNAMIC_NATIVE, "FLRWATK+")))
findScalarResultIndex(RiaDefines::DYNAMIC_NATIVE, "FLRWATJ+") != cvf::UNDEFINED_SIZE_T &&
findScalarResultIndex(RiaDefines::DYNAMIC_NATIVE, "FLRWATK+") != cvf::UNDEFINED_SIZE_T)
{ {
findOrCreateScalarResultIndex(RiaDefines::DYNAMIC_NATIVE, RiaDefines::combinedWaterFluxResultName(), false); findOrCreateScalarResultIndex(RigEclipseResultAddress(RiaDefines::DYNAMIC_NATIVE, RiaDefines::combinedWaterFluxResultName()), false);
} }
size_t oilIndex = findScalarResultIndex(RiaDefines::DYNAMIC_NATIVE, RiaDefines::combinedOilFluxResultName());
if (oilIndex == cvf::UNDEFINED_SIZE_T && if ( hasResultEntry(RigEclipseResultAddress(RiaDefines::DYNAMIC_NATIVE, "FLROILI+"))
findScalarResultIndex(RiaDefines::DYNAMIC_NATIVE, "FLROILI+") != cvf::UNDEFINED_SIZE_T && && hasResultEntry(RigEclipseResultAddress(RiaDefines::DYNAMIC_NATIVE, "FLROILJ+"))
findScalarResultIndex(RiaDefines::DYNAMIC_NATIVE, "FLROILJ+") != cvf::UNDEFINED_SIZE_T && && hasResultEntry(RigEclipseResultAddress(RiaDefines::DYNAMIC_NATIVE, "FLROILK+")))
findScalarResultIndex(RiaDefines::DYNAMIC_NATIVE, "FLROILK+") != cvf::UNDEFINED_SIZE_T)
{ {
findOrCreateScalarResultIndex(RiaDefines::DYNAMIC_NATIVE, RiaDefines::combinedOilFluxResultName(), false); findOrCreateScalarResultIndex(RigEclipseResultAddress(RiaDefines::DYNAMIC_NATIVE, RiaDefines::combinedOilFluxResultName()), false);
} }
size_t gasIndex = findScalarResultIndex(RiaDefines::DYNAMIC_NATIVE, RiaDefines::combinedGasFluxResultName());
if (gasIndex == cvf::UNDEFINED_SIZE_T && if (
findScalarResultIndex(RiaDefines::DYNAMIC_NATIVE, "FLRGASI+") != cvf::UNDEFINED_SIZE_T && hasResultEntry(RigEclipseResultAddress(RiaDefines::DYNAMIC_NATIVE, "FLRGASI+"))
findScalarResultIndex(RiaDefines::DYNAMIC_NATIVE, "FLRGASJ+") != cvf::UNDEFINED_SIZE_T && && hasResultEntry(RigEclipseResultAddress(RiaDefines::DYNAMIC_NATIVE, "FLRGASJ+"))
findScalarResultIndex(RiaDefines::DYNAMIC_NATIVE, "FLRGASK+") != cvf::UNDEFINED_SIZE_T) && hasResultEntry(RigEclipseResultAddress(RiaDefines::DYNAMIC_NATIVE, "FLRGASK+")))
{ {
findOrCreateScalarResultIndex(RiaDefines::DYNAMIC_NATIVE, RiaDefines::combinedGasFluxResultName(), false); findOrCreateScalarResultIndex(RigEclipseResultAddress(RiaDefines::DYNAMIC_NATIVE, RiaDefines::combinedGasFluxResultName()), false);
} }
} }
@@ -943,9 +882,9 @@ void RigCaseCellResultsData::createPlaceholderResultEntries()
// riTRANSXYZ and X,Y,Z // riTRANSXYZ and X,Y,Z
{ {
if (findScalarResultIndex(RiaDefines::STATIC_NATIVE, "PERMX") != cvf::UNDEFINED_SIZE_T && if (hasResultEntry(RigEclipseResultAddress(RiaDefines::STATIC_NATIVE, "PERMX")) &&
findScalarResultIndex(RiaDefines::STATIC_NATIVE, "PERMY") != cvf::UNDEFINED_SIZE_T && hasResultEntry(RigEclipseResultAddress(RiaDefines::STATIC_NATIVE, "PERMY")) &&
findScalarResultIndex(RiaDefines::STATIC_NATIVE, "PERMZ") != cvf::UNDEFINED_SIZE_T) hasResultEntry(RigEclipseResultAddress(RiaDefines::STATIC_NATIVE, "PERMZ")))
{ {
addStaticScalarResult(RiaDefines::STATIC_NATIVE, RiaDefines::riTranXResultName(), false, 0); addStaticScalarResult(RiaDefines::STATIC_NATIVE, RiaDefines::riTranXResultName(), false, 0);
addStaticScalarResult(RiaDefines::STATIC_NATIVE, RiaDefines::riTranYResultName(), false, 0); addStaticScalarResult(RiaDefines::STATIC_NATIVE, RiaDefines::riTranYResultName(), false, 0);
@@ -958,9 +897,9 @@ void RigCaseCellResultsData::createPlaceholderResultEntries()
{ {
if (hasCompleteTransmissibilityResults() && if (hasCompleteTransmissibilityResults() &&
findScalarResultIndex(RiaDefines::STATIC_NATIVE, RiaDefines::riTranXResultName()) != cvf::UNDEFINED_SIZE_T && hasResultEntry(RigEclipseResultAddress(RiaDefines::STATIC_NATIVE, RiaDefines::riTranXResultName())) &&
findScalarResultIndex(RiaDefines::STATIC_NATIVE, RiaDefines::riTranYResultName()) != cvf::UNDEFINED_SIZE_T && hasResultEntry(RigEclipseResultAddress(RiaDefines::STATIC_NATIVE, RiaDefines::riTranYResultName())) &&
findScalarResultIndex(RiaDefines::STATIC_NATIVE, RiaDefines::riTranZResultName()) != cvf::UNDEFINED_SIZE_T) hasResultEntry(RigEclipseResultAddress(RiaDefines::STATIC_NATIVE, RiaDefines::riTranZResultName())))
{ {
addStaticScalarResult(RiaDefines::STATIC_NATIVE, RiaDefines::riMultXResultName(), false, 0); addStaticScalarResult(RiaDefines::STATIC_NATIVE, RiaDefines::riMultXResultName(), false, 0);
addStaticScalarResult(RiaDefines::STATIC_NATIVE, RiaDefines::riMultYResultName(), false, 0); addStaticScalarResult(RiaDefines::STATIC_NATIVE, RiaDefines::riMultYResultName(), false, 0);
@@ -971,17 +910,17 @@ void RigCaseCellResultsData::createPlaceholderResultEntries()
// riTRANSXYZbyArea and X, Y, Z // riTRANSXYZbyArea and X, Y, Z
{ {
if (findScalarResultIndex(RiaDefines::STATIC_NATIVE, "TRANX") != cvf::UNDEFINED_SIZE_T) if (hasResultEntry(RigEclipseResultAddress(RiaDefines::STATIC_NATIVE, "TRANX")))
{ {
addStaticScalarResult(RiaDefines::STATIC_NATIVE, RiaDefines::riAreaNormTranXResultName(), false, 0); addStaticScalarResult(RiaDefines::STATIC_NATIVE, RiaDefines::riAreaNormTranXResultName(), false, 0);
} }
if (findScalarResultIndex(RiaDefines::STATIC_NATIVE, "TRANY") != cvf::UNDEFINED_SIZE_T) if (hasResultEntry(RigEclipseResultAddress(RiaDefines::STATIC_NATIVE, "TRANY")))
{ {
addStaticScalarResult(RiaDefines::STATIC_NATIVE, RiaDefines::riAreaNormTranYResultName(), false, 0); addStaticScalarResult(RiaDefines::STATIC_NATIVE, RiaDefines::riAreaNormTranYResultName(), false, 0);
} }
if (findScalarResultIndex(RiaDefines::STATIC_NATIVE, "TRANZ") != cvf::UNDEFINED_SIZE_T) if (hasResultEntry(RigEclipseResultAddress(RiaDefines::STATIC_NATIVE, "TRANZ")))
{ {
addStaticScalarResult(RiaDefines::STATIC_NATIVE, RiaDefines::riAreaNormTranZResultName(), false, 0); addStaticScalarResult(RiaDefines::STATIC_NATIVE, RiaDefines::riAreaNormTranZResultName(), false, 0);
} }
@@ -999,7 +938,7 @@ void RigCaseCellResultsData::createPlaceholderResultEntries()
// Mobile Pore Volume // Mobile Pore Volume
{ {
if (findScalarResultIndex(RiaDefines::STATIC_NATIVE, "PORV") != cvf::UNDEFINED_SIZE_T) if (hasResultEntry(RigEclipseResultAddress(RiaDefines::STATIC_NATIVE, "PORV")) )
{ {
addStaticScalarResult(RiaDefines::STATIC_NATIVE, RiaDefines::mobilePoreVolumeName(), false, 0); addStaticScalarResult(RiaDefines::STATIC_NATIVE, RiaDefines::mobilePoreVolumeName(), false, 0);
} }
@@ -1011,18 +950,14 @@ void RigCaseCellResultsData::createPlaceholderResultEntries()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RigCaseCellResultsData::hasCompleteTransmissibilityResults() const bool RigCaseCellResultsData::hasCompleteTransmissibilityResults() const
{ {
size_t tranX; size_t tranY; size_t tranZ; if ( hasResultEntry(RigEclipseResultAddress(RiaDefines::STATIC_NATIVE, "TRANX"))
&& hasResultEntry(RigEclipseResultAddress(RiaDefines::STATIC_NATIVE, "TRANY"))
tranX = findScalarResultIndex(RiaDefines::STATIC_NATIVE, "TRANX"); && hasResultEntry(RigEclipseResultAddress(RiaDefines::STATIC_NATIVE, "TRANZ")))
tranY = findScalarResultIndex(RiaDefines::STATIC_NATIVE, "TRANY");
tranZ = findScalarResultIndex(RiaDefines::STATIC_NATIVE, "TRANZ");
if (tranX == cvf::UNDEFINED_SIZE_T || tranY == cvf::UNDEFINED_SIZE_T || tranZ == cvf::UNDEFINED_SIZE_T)
{ {
return false; return true;
} }
return true; return false;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -1050,59 +985,80 @@ const RigEclipseResultInfo* RigCaseCellResultsData::resultInfo(const RigEclipseR
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
size_t RigCaseCellResultsData::findOrLoadKnownScalarResult(const QString& resultName) size_t RigCaseCellResultsData::findOrLoadKnownScalarResult(const RigEclipseResultAddress& resVarAddr)
{ {
size_t scalarResultIndex = this->findOrLoadKnownScalarResult(RiaDefines::STATIC_NATIVE, resultName); if (!resVarAddr.isValid())
if (scalarResultIndex == cvf::UNDEFINED_SIZE_T)
{ {
scalarResultIndex = this->findOrLoadKnownScalarResult(RiaDefines::DYNAMIC_NATIVE, resultName); return cvf::UNDEFINED_SIZE_T;
} }
else if (resVarAddr.m_resultCatType == RiaDefines::UNDEFINED)
if (scalarResultIndex == cvf::UNDEFINED_SIZE_T)
{ {
scalarResultIndex = this->findOrLoadKnownScalarResult(RiaDefines::SOURSIMRL, resultName); RigEclipseResultAddress resVarAddressWithType = resVarAddr;
resVarAddressWithType.m_resultCatType = RiaDefines::STATIC_NATIVE;
size_t scalarResultIndex = this->findOrLoadKnownScalarResult(resVarAddressWithType);
if (scalarResultIndex == cvf::UNDEFINED_SIZE_T)
{
resVarAddressWithType.m_resultCatType = RiaDefines::DYNAMIC_NATIVE;
scalarResultIndex = this->findOrLoadKnownScalarResult(resVarAddressWithType);
}
if (scalarResultIndex == cvf::UNDEFINED_SIZE_T)
{
resVarAddressWithType.m_resultCatType = RiaDefines::SOURSIMRL;
scalarResultIndex = this->findOrLoadKnownScalarResult(resVarAddressWithType);
}
if (scalarResultIndex == cvf::UNDEFINED_SIZE_T)
{
resVarAddressWithType.m_resultCatType = RiaDefines::GENERATED;
scalarResultIndex = this->findScalarResultIndexFromAddress(resVarAddressWithType);
}
if (scalarResultIndex == cvf::UNDEFINED_SIZE_T)
{
resVarAddressWithType.m_resultCatType = RiaDefines::INPUT_PROPERTY;
scalarResultIndex = this->findScalarResultIndexFromAddress(resVarAddressWithType);
}
if (scalarResultIndex == cvf::UNDEFINED_SIZE_T)
{
resVarAddressWithType.m_resultCatType = RiaDefines::FORMATION_NAMES;
scalarResultIndex = this->findScalarResultIndexFromAddress(resVarAddressWithType); // Use Load ?
}
return scalarResultIndex;
} }
if (scalarResultIndex == cvf::UNDEFINED_SIZE_T) size_t scalarResultIndex = this->findScalarResultIndexFromAddress(resVarAddr);
{
scalarResultIndex = this->findScalarResultIndex(RiaDefines::GENERATED, resultName);
}
if (scalarResultIndex == cvf::UNDEFINED_SIZE_T)
{
scalarResultIndex = this->findScalarResultIndex(RiaDefines::INPUT_PROPERTY, resultName);
}
return scalarResultIndex;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RigCaseCellResultsData::findOrLoadKnownScalarResult(RiaDefines::ResultCatType type, const QString& resultName)
{
size_t scalarResultIndex = this->findScalarResultIndex(type, resultName);
if (scalarResultIndex == cvf::UNDEFINED_SIZE_T) return cvf::UNDEFINED_SIZE_T; if (scalarResultIndex == cvf::UNDEFINED_SIZE_T) return cvf::UNDEFINED_SIZE_T;
RiaDefines::ResultCatType type = resVarAddr.m_resultCatType;
QString resultName = resVarAddr.m_resultName;
// Load dependency data sets // Load dependency data sets
if (type == RiaDefines::STATIC_NATIVE) if (type == RiaDefines::STATIC_NATIVE)
{ {
if (resultName == RiaDefines::combinedTransmissibilityResultName()) if (resultName == RiaDefines::combinedTransmissibilityResultName())
{ {
this->findOrLoadKnownScalarResult(type, "TRANX"); this->findOrLoadKnownScalarResult(RigEclipseResultAddress(type, "TRANX"));
this->findOrLoadKnownScalarResult(type, "TRANY"); this->findOrLoadKnownScalarResult(RigEclipseResultAddress(type, "TRANY"));
this->findOrLoadKnownScalarResult(type, "TRANZ"); this->findOrLoadKnownScalarResult(RigEclipseResultAddress(type, "TRANZ"));
} }
else if (resultName == RiaDefines::combinedMultResultName()) else if (resultName == RiaDefines::combinedMultResultName())
{ {
this->findOrLoadKnownScalarResult(type, "MULTX"); this->findOrLoadKnownScalarResult(RigEclipseResultAddress(type, "MULTX" ));
this->findOrLoadKnownScalarResult(type, "MULTX-"); this->findOrLoadKnownScalarResult(RigEclipseResultAddress(type, "MULTX-"));
this->findOrLoadKnownScalarResult(type, "MULTY"); this->findOrLoadKnownScalarResult(RigEclipseResultAddress(type, "MULTY" ));
this->findOrLoadKnownScalarResult(type, "MULTY-"); this->findOrLoadKnownScalarResult(RigEclipseResultAddress(type, "MULTY-"));
this->findOrLoadKnownScalarResult(type, "MULTZ"); this->findOrLoadKnownScalarResult(RigEclipseResultAddress(type, "MULTZ" ));
this->findOrLoadKnownScalarResult(type, "MULTZ-"); this->findOrLoadKnownScalarResult(RigEclipseResultAddress(type, "MULTZ-"));
} }
else if (resultName == RiaDefines::combinedRiTranResultName()) else if (resultName == RiaDefines::combinedRiTranResultName())
{ {
@@ -1146,21 +1102,21 @@ size_t RigCaseCellResultsData::findOrLoadKnownScalarResult(RiaDefines::ResultCat
{ {
if (resultName == RiaDefines::combinedWaterFluxResultName()) if (resultName == RiaDefines::combinedWaterFluxResultName())
{ {
this->findOrLoadKnownScalarResult(type, "FLRWATI+"); this->findOrLoadKnownScalarResult(RigEclipseResultAddress(type, "FLRWATI+"));
this->findOrLoadKnownScalarResult(type, "FLRWATJ+"); this->findOrLoadKnownScalarResult(RigEclipseResultAddress(type, "FLRWATJ+"));
this->findOrLoadKnownScalarResult(type, "FLRWATK+"); this->findOrLoadKnownScalarResult(RigEclipseResultAddress(type, "FLRWATK+"));
} }
else if (resultName == RiaDefines::combinedOilFluxResultName()) else if (resultName == RiaDefines::combinedOilFluxResultName())
{ {
this->findOrLoadKnownScalarResult(type, "FLROILI+"); this->findOrLoadKnownScalarResult(RigEclipseResultAddress(type, "FLROILI+"));
this->findOrLoadKnownScalarResult(type, "FLROILJ+"); this->findOrLoadKnownScalarResult(RigEclipseResultAddress(type, "FLROILJ+"));
this->findOrLoadKnownScalarResult(type, "FLROILK+"); this->findOrLoadKnownScalarResult(RigEclipseResultAddress(type, "FLROILK+"));
} }
else if (resultName == RiaDefines::combinedGasFluxResultName()) else if (resultName == RiaDefines::combinedGasFluxResultName())
{ {
this->findOrLoadKnownScalarResult(type, "FLRGASI+"); this->findOrLoadKnownScalarResult(RigEclipseResultAddress(type, "FLRGASI+"));
this->findOrLoadKnownScalarResult(type, "FLRGASJ+"); this->findOrLoadKnownScalarResult(RigEclipseResultAddress(type, "FLRGASJ+"));
this->findOrLoadKnownScalarResult(type, "FLRGASK+"); this->findOrLoadKnownScalarResult(RigEclipseResultAddress(type, "FLRGASK+"));
} }
} }
@@ -1174,8 +1130,8 @@ size_t RigCaseCellResultsData::findOrLoadKnownScalarResult(RiaDefines::ResultCat
if (this->mustBeCalculated(scalarResultIndex)) if (this->mustBeCalculated(scalarResultIndex))
{ {
// Trigger loading of SWAT, SGAS to establish time step count if no data has been loaded from file at this point // Trigger loading of SWAT, SGAS to establish time step count if no data has been loaded from file at this point
findOrLoadKnownScalarResult(RiaDefines::DYNAMIC_NATIVE, "SWAT"); findOrLoadKnownScalarResult(RigEclipseResultAddress(RiaDefines::DYNAMIC_NATIVE, "SWAT"));
findOrLoadKnownScalarResult(RiaDefines::DYNAMIC_NATIVE, "SGAS"); findOrLoadKnownScalarResult(RigEclipseResultAddress(RiaDefines::DYNAMIC_NATIVE, "SGAS"));
m_cellScalarResults[scalarResultIndex].resize(this->maxTimeStepCount()); m_cellScalarResults[scalarResultIndex].resize(this->maxTimeStepCount());
for (size_t timeStepIdx = 0; timeStepIdx < this->maxTimeStepCount(); timeStepIdx++) for (size_t timeStepIdx = 0; timeStepIdx < this->maxTimeStepCount(); timeStepIdx++)
@@ -1309,15 +1265,7 @@ size_t RigCaseCellResultsData::findOrLoadKnownScalarResult(RiaDefines::ResultCat
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RigCaseCellResultsData::ensureKnownResultLoaded(const RigEclipseResultAddress& resultAddress) bool RigCaseCellResultsData::ensureKnownResultLoaded(const RigEclipseResultAddress& resultAddress)
{ {
size_t resultIndex = cvf::UNDEFINED_SIZE_T; size_t resultIndex = findOrLoadKnownScalarResult(resultAddress);
if (resultAddress.m_resultCatType != RiaDefines::UNDEFINED)
{
resultIndex = findOrLoadKnownScalarResult(resultAddress.m_resultCatType, resultAddress.m_resultName);
}
else
{
resultIndex = findOrLoadKnownScalarResult(resultAddress.m_resultName);
}
return (resultIndex != cvf::UNDEFINED_SIZE_T); return (resultIndex != cvf::UNDEFINED_SIZE_T);
} }
@@ -1327,15 +1275,7 @@ bool RigCaseCellResultsData::ensureKnownResultLoaded(const RigEclipseResultAddre
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RigCaseCellResultsData::hasResultEntry(const RigEclipseResultAddress& resultAddress) const bool RigCaseCellResultsData::hasResultEntry(const RigEclipseResultAddress& resultAddress) const
{ {
size_t resultIndex = cvf::UNDEFINED_SIZE_T; size_t resultIndex = findScalarResultIndexFromAddress(resultAddress);
if (resultAddress.m_resultCatType != RiaDefines::UNDEFINED)
{
resultIndex = findScalarResultIndex(resultAddress.m_resultCatType, resultAddress.m_resultName);
}
else
{
resultIndex = findScalarResultIndex(resultAddress.m_resultName);
}
return (resultIndex != cvf::UNDEFINED_SIZE_T); return (resultIndex != cvf::UNDEFINED_SIZE_T);
} }
@@ -1345,7 +1285,7 @@ bool RigCaseCellResultsData::hasResultEntry(const RigEclipseResultAddress& resul
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RigCaseCellResultsData::createResultEntry(const RigEclipseResultAddress& resultAddress, bool needsToBeStored) void RigCaseCellResultsData::createResultEntry(const RigEclipseResultAddress& resultAddress, bool needsToBeStored)
{ {
findOrCreateScalarResultIndex(resultAddress.m_resultCatType, resultAddress.m_resultName, needsToBeStored); findOrCreateScalarResultIndex(resultAddress, needsToBeStored);
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -1356,8 +1296,7 @@ void RigCaseCellResultsData::ensureKnownResultLoadedForTimeStep(const RigEclipse
{ {
CAF_ASSERT(resultAddress.m_resultCatType != RiaDefines::UNDEFINED); CAF_ASSERT(resultAddress.m_resultCatType != RiaDefines::UNDEFINED);
findOrLoadKnownScalarResultForTimeStep(resultAddress.m_resultCatType, findOrLoadKnownScalarResultForTimeStep(resultAddress,
resultAddress.m_resultName,
timeStepIndex); timeStepIndex);
} }
@@ -1366,14 +1305,16 @@ void RigCaseCellResultsData::ensureKnownResultLoadedForTimeStep(const RigEclipse
/// This method is intended to be used for multicase cross statistical calculations, when /// This method is intended to be used for multicase cross statistical calculations, when
/// we need process one timestep at a time, freeing memory as we go. /// we need process one timestep at a time, freeing memory as we go.
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
size_t RigCaseCellResultsData::findOrLoadKnownScalarResultForTimeStep(RiaDefines::ResultCatType type, size_t RigCaseCellResultsData::findOrLoadKnownScalarResultForTimeStep(const RigEclipseResultAddress& resVarAddr,
const QString& resultName, size_t timeStepIndex)
size_t timeStepIndex)
{ {
RiaDefines::ResultCatType type = resVarAddr.m_resultCatType;
QString resultName = resVarAddr.m_resultName;
// Special handling for SOIL // Special handling for SOIL
if (type == RiaDefines::DYNAMIC_NATIVE && resultName.toUpper() == "SOIL") if (type == RiaDefines::DYNAMIC_NATIVE && resultName.toUpper() == "SOIL")
{ {
size_t soilScalarResultIndex = this->findScalarResultIndex(type, resultName); size_t soilScalarResultIndex = this->findScalarResultIndexFromAddress(resVarAddr);
if (this->mustBeCalculated(soilScalarResultIndex)) if (this->mustBeCalculated(soilScalarResultIndex))
{ {
@@ -1390,12 +1331,12 @@ size_t RigCaseCellResultsData::findOrLoadKnownScalarResultForTimeStep(RiaDefines
} }
else if (type == RiaDefines::DYNAMIC_NATIVE && resultName == RiaDefines::completionTypeResultName()) else if (type == RiaDefines::DYNAMIC_NATIVE && resultName == RiaDefines::completionTypeResultName())
{ {
size_t completionTypeScalarResultIndex = this->findScalarResultIndex(type, resultName); size_t completionTypeScalarResultIndex = this->findScalarResultIndexFromAddress(resVarAddr);
computeCompletionTypeForTimeStep(timeStepIndex); computeCompletionTypeForTimeStep(timeStepIndex);
return completionTypeScalarResultIndex; return completionTypeScalarResultIndex;
} }
size_t scalarResultIndex = this->findScalarResultIndex(type, resultName); size_t scalarResultIndex = this->findScalarResultIndexFromAddress(resVarAddr);
if (scalarResultIndex == cvf::UNDEFINED_SIZE_T) return cvf::UNDEFINED_SIZE_T; if (scalarResultIndex == cvf::UNDEFINED_SIZE_T) return cvf::UNDEFINED_SIZE_T;
if (type == RiaDefines::GENERATED) if (type == RiaDefines::GENERATED)
@@ -1475,9 +1416,9 @@ void RigCaseCellResultsData::computeSOILForTimeStep(size_t timeStepIndex)
RigEclipseResultAddress SGASAddr(RiaDefines::DYNAMIC_NATIVE, "SGAS"); RigEclipseResultAddress SGASAddr(RiaDefines::DYNAMIC_NATIVE, "SGAS");
RigEclipseResultAddress SSOLAddr(RiaDefines::DYNAMIC_NATIVE, "SSOL"); RigEclipseResultAddress SSOLAddr(RiaDefines::DYNAMIC_NATIVE, "SSOL");
size_t scalarIndexSWAT = findOrLoadKnownScalarResultForTimeStep(RiaDefines::DYNAMIC_NATIVE, "SWAT", timeStepIndex); size_t scalarIndexSWAT = findOrLoadKnownScalarResultForTimeStep(RigEclipseResultAddress(RiaDefines::DYNAMIC_NATIVE, "SWAT"), timeStepIndex);
size_t scalarIndexSGAS = findOrLoadKnownScalarResultForTimeStep(RiaDefines::DYNAMIC_NATIVE, "SGAS", timeStepIndex); size_t scalarIndexSGAS = findOrLoadKnownScalarResultForTimeStep(RigEclipseResultAddress(RiaDefines::DYNAMIC_NATIVE, "SGAS"), timeStepIndex);
size_t scalarIndexSSOL = findOrLoadKnownScalarResultForTimeStep(RiaDefines::DYNAMIC_NATIVE, "SSOL", timeStepIndex); size_t scalarIndexSSOL = findOrLoadKnownScalarResultForTimeStep(RigEclipseResultAddress(RiaDefines::DYNAMIC_NATIVE, "SSOL"), timeStepIndex);
// Early exit if none of SWAT or SGAS is present // Early exit if none of SWAT or SGAS is present
if (scalarIndexSWAT == cvf::UNDEFINED_SIZE_T && scalarIndexSGAS == cvf::UNDEFINED_SIZE_T) if (scalarIndexSWAT == cvf::UNDEFINED_SIZE_T && scalarIndexSGAS == cvf::UNDEFINED_SIZE_T)
@@ -1512,7 +1453,7 @@ void RigCaseCellResultsData::computeSOILForTimeStep(size_t timeStepIndex)
// Make sure memory is allocated for the new SOIL results // Make sure memory is allocated for the new SOIL results
RigEclipseResultAddress SOILAddr(RiaDefines::DYNAMIC_NATIVE, "SOIL"); RigEclipseResultAddress SOILAddr(RiaDefines::DYNAMIC_NATIVE, "SOIL");
size_t soilResultScalarIndex = this->findScalarResultIndex(RiaDefines::DYNAMIC_NATIVE, "SOIL"); size_t soilResultScalarIndex = this->findScalarResultIndexFromAddress(SOILAddr);
m_cellScalarResults[soilResultScalarIndex].resize(soilTimeStepCount); m_cellScalarResults[soilResultScalarIndex].resize(soilTimeStepCount);
if (this->cellScalarResults(SOILAddr, timeStepIndex).size() > 0) if (this->cellScalarResults(SOILAddr, timeStepIndex).size() > 0)
@@ -1584,7 +1525,7 @@ void RigCaseCellResultsData::computeSOILForTimeStep(size_t timeStepIndex)
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RigCaseCellResultsData::testAndComputeSgasForTimeStep(size_t timeStepIndex) void RigCaseCellResultsData::testAndComputeSgasForTimeStep(size_t timeStepIndex)
{ {
size_t scalarIndexSWAT = findOrLoadKnownScalarResultForTimeStep(RiaDefines::DYNAMIC_NATIVE, "SWAT", timeStepIndex); size_t scalarIndexSWAT = findOrLoadKnownScalarResultForTimeStep(RigEclipseResultAddress(RiaDefines::DYNAMIC_NATIVE, "SWAT"), timeStepIndex);
if (scalarIndexSWAT == cvf::UNDEFINED_SIZE_T) if (scalarIndexSWAT == cvf::UNDEFINED_SIZE_T)
{ {
return; return;
@@ -1598,7 +1539,7 @@ void RigCaseCellResultsData::testAndComputeSgasForTimeStep(size_t timeStepIndex)
// Simulation type is gas and water. No SGAS is present, compute SGAS based on SWAT // 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); size_t scalarIndexSGAS = this->findOrCreateScalarResultIndex(RigEclipseResultAddress(RiaDefines::DYNAMIC_NATIVE, "SGAS"), false);
if (m_cellScalarResults[scalarIndexSGAS].size() > timeStepIndex) if (m_cellScalarResults[scalarIndexSGAS].size() > timeStepIndex)
{ {
std::vector<double>& values = m_cellScalarResults[scalarIndexSGAS][timeStepIndex]; std::vector<double>& values = m_cellScalarResults[scalarIndexSGAS][timeStepIndex];
@@ -1660,12 +1601,12 @@ void RigCaseCellResultsData::computeDepthRelatedResults()
size_t actCellCount = activeCellInfo()->reservoirActiveCellCount(); size_t actCellCount = activeCellInfo()->reservoirActiveCellCount();
if (actCellCount == 0) return; if (actCellCount == 0) return;
size_t depthResultIndex = findOrLoadKnownScalarResult(RiaDefines::STATIC_NATIVE, "DEPTH"); size_t depthResultIndex = findOrLoadKnownScalarResult(RigEclipseResultAddress(RiaDefines::STATIC_NATIVE, "DEPTH" ));
size_t dxResultIndex = findOrLoadKnownScalarResult(RiaDefines::STATIC_NATIVE, "DX"); size_t dxResultIndex = findOrLoadKnownScalarResult(RigEclipseResultAddress(RiaDefines::STATIC_NATIVE, "DX" ));
size_t dyResultIndex = findOrLoadKnownScalarResult(RiaDefines::STATIC_NATIVE, "DY"); size_t dyResultIndex = findOrLoadKnownScalarResult(RigEclipseResultAddress(RiaDefines::STATIC_NATIVE, "DY" ));
size_t dzResultIndex = findOrLoadKnownScalarResult(RiaDefines::STATIC_NATIVE, "DZ"); size_t dzResultIndex = findOrLoadKnownScalarResult(RigEclipseResultAddress(RiaDefines::STATIC_NATIVE, "DZ" ));
size_t topsResultIndex = findOrLoadKnownScalarResult(RiaDefines::STATIC_NATIVE, "TOPS"); size_t topsResultIndex = findOrLoadKnownScalarResult(RigEclipseResultAddress(RiaDefines::STATIC_NATIVE, "TOPS" ));
size_t bottomResultIndex = findOrLoadKnownScalarResult(RiaDefines::STATIC_NATIVE, "BOTTOM"); size_t bottomResultIndex = findOrLoadKnownScalarResult(RigEclipseResultAddress(RiaDefines::STATIC_NATIVE, "BOTTOM"));
bool computeDepth = false; bool computeDepth = false;
bool computeDx = false; bool computeDx = false;
@@ -1931,14 +1872,14 @@ void RigCaseCellResultsData::computeRiTransComponent(const QString& riTransCompo
// Get the needed result indices we depend on // Get the needed result indices we depend on
size_t permResultIdx = findOrLoadKnownScalarResult(RiaDefines::STATIC_NATIVE, permCompName); size_t permResultIdx = findOrLoadKnownScalarResult(RigEclipseResultAddress(RiaDefines::STATIC_NATIVE, permCompName));
size_t ntgResultIdx = findOrLoadKnownScalarResult(RiaDefines::STATIC_NATIVE, "NTG"); size_t ntgResultIdx = findOrLoadKnownScalarResult(RigEclipseResultAddress(RiaDefines::STATIC_NATIVE, "NTG"));
bool hasNTGResults = ntgResultIdx != cvf::UNDEFINED_SIZE_T; bool hasNTGResults = ntgResultIdx != cvf::UNDEFINED_SIZE_T;
// Get the result index of the output // Get the result index of the output
size_t riTransResultIdx = this->findScalarResultIndex(RiaDefines::STATIC_NATIVE, riTransComponentResultName); size_t riTransResultIdx = this->findScalarResultIndexFromAddress(RigEclipseResultAddress( RiaDefines::STATIC_NATIVE, riTransComponentResultName));
CVF_ASSERT(riTransResultIdx != cvf::UNDEFINED_SIZE_T); CVF_ASSERT(riTransResultIdx != cvf::UNDEFINED_SIZE_T);
// Get the result count, to handle that one of them might be globally defined // Get the result count, to handle that one of them might be globally defined
@@ -2090,11 +2031,11 @@ void RigCaseCellResultsData::computeNncCombRiTrans()
// Get the needed result indices we depend on // Get the needed result indices we depend on
size_t permXResultIdx = findOrLoadKnownScalarResult(RiaDefines::STATIC_NATIVE, "PERMX"); size_t permXResultIdx = findOrLoadKnownScalarResult(RigEclipseResultAddress(RiaDefines::STATIC_NATIVE, "PERMX"));
size_t permYResultIdx = findOrLoadKnownScalarResult(RiaDefines::STATIC_NATIVE, "PERMY"); size_t permYResultIdx = findOrLoadKnownScalarResult(RigEclipseResultAddress(RiaDefines::STATIC_NATIVE, "PERMY"));
size_t permZResultIdx = findOrLoadKnownScalarResult(RiaDefines::STATIC_NATIVE, "PERMZ"); size_t permZResultIdx = findOrLoadKnownScalarResult(RigEclipseResultAddress(RiaDefines::STATIC_NATIVE, "PERMZ"));
size_t ntgResultIdx = findOrLoadKnownScalarResult(RiaDefines::STATIC_NATIVE, "NTG"); size_t ntgResultIdx = findOrLoadKnownScalarResult(RigEclipseResultAddress(RiaDefines::STATIC_NATIVE, "NTG"));
bool hasNTGResults = ntgResultIdx != cvf::UNDEFINED_SIZE_T; bool hasNTGResults = ntgResultIdx != cvf::UNDEFINED_SIZE_T;
@@ -2300,12 +2241,12 @@ void RigCaseCellResultsData::computeRiMULTComponent(const QString& riMultCompNam
// Get the needed result indices we depend on // Get the needed result indices we depend on
size_t transResultIdx = findOrLoadKnownScalarResult(RiaDefines::STATIC_NATIVE, transCompName); size_t transResultIdx = findOrLoadKnownScalarResult(RigEclipseResultAddress(RiaDefines::STATIC_NATIVE, transCompName ));
size_t riTransResultIdx = findOrLoadKnownScalarResult(RiaDefines::STATIC_NATIVE, riTransCompName); size_t riTransResultIdx = findOrLoadKnownScalarResult(RigEclipseResultAddress(RiaDefines::STATIC_NATIVE, riTransCompName));
// Get the result index of the output // Get the result index of the output
size_t riMultResultIdx = this->findScalarResultIndex(RiaDefines::STATIC_NATIVE, riMultCompName); size_t riMultResultIdx = this->findScalarResultIndexFromAddress( RigEclipseResultAddress(RiaDefines::STATIC_NATIVE, riMultCompName));
CVF_ASSERT(riMultResultIdx != cvf::UNDEFINED_SIZE_T); CVF_ASSERT(riMultResultIdx != cvf::UNDEFINED_SIZE_T);
// Get the result count, to handle that one of them might be globally defined // Get the result count, to handle that one of them might be globally defined
@@ -2390,11 +2331,11 @@ void RigCaseCellResultsData::computeRiTRANSbyAreaComponent(const QString& riTran
// Get the needed result indices we depend on // Get the needed result indices we depend on
size_t tranCompScResIdx = findOrLoadKnownScalarResult(RiaDefines::STATIC_NATIVE, transCompName); size_t tranCompScResIdx = findOrLoadKnownScalarResult(RigEclipseResultAddress(RiaDefines::STATIC_NATIVE, transCompName));
// Get the result index of the output // Get the result index of the output
size_t riTranByAreaScResIdx = this->findScalarResultIndex(RiaDefines::STATIC_NATIVE, riTransByAreaCompResultName); size_t riTranByAreaScResIdx = this->findScalarResultIndexFromAddress( RigEclipseResultAddress(RiaDefines::STATIC_NATIVE, riTransByAreaCompResultName));
CVF_ASSERT(riTranByAreaScResIdx != cvf::UNDEFINED_SIZE_T); CVF_ASSERT(riTranByAreaScResIdx != cvf::UNDEFINED_SIZE_T);
// Get the result count, to handle that one of them might be globally defined // Get the result count, to handle that one of them might be globally defined
@@ -2504,7 +2445,7 @@ void RigCaseCellResultsData::computeNncCombRiTRANSbyArea()
void RigCaseCellResultsData::computeCompletionTypeForTimeStep(size_t timeStep) void RigCaseCellResultsData::computeCompletionTypeForTimeStep(size_t timeStep)
{ {
size_t completionTypeResultIndex = size_t completionTypeResultIndex =
this->findScalarResultIndex(RiaDefines::DYNAMIC_NATIVE, RiaDefines::completionTypeResultName()); this->findScalarResultIndexFromAddress(RigEclipseResultAddress(RiaDefines::DYNAMIC_NATIVE, RiaDefines::completionTypeResultName()));
if (m_cellScalarResults[completionTypeResultIndex].size() < this->maxTimeStepCount()) if (m_cellScalarResults[completionTypeResultIndex].size() < this->maxTimeStepCount())
{ {
@@ -2543,7 +2484,9 @@ double RigCaseCellResultsData::darchysValue()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RigCaseCellResultsData::computeCellVolumes() void RigCaseCellResultsData::computeCellVolumes()
{ {
size_t cellVolIdx = this->findOrCreateScalarResultIndex(RiaDefines::STATIC_NATIVE, RiaDefines::riCellVolumeResultName(), false); size_t cellVolIdx = this->findOrCreateScalarResultIndex(RigEclipseResultAddress(RiaDefines::STATIC_NATIVE,
RiaDefines::riCellVolumeResultName()),
false);
if (m_cellScalarResults[cellVolIdx].empty()) if (m_cellScalarResults[cellVolIdx].empty())
{ {
@@ -2577,11 +2520,15 @@ void RigCaseCellResultsData::computeCellVolumes()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RigCaseCellResultsData::computeOilVolumes() void RigCaseCellResultsData::computeOilVolumes()
{ {
size_t cellVolIdx = this->findOrCreateScalarResultIndex(RiaDefines::STATIC_NATIVE, RiaDefines::riCellVolumeResultName(), false); size_t cellVolIdx = this->findOrCreateScalarResultIndex(RigEclipseResultAddress(RiaDefines::STATIC_NATIVE,
RiaDefines::riCellVolumeResultName()),
false);
const std::vector<double>& cellVolumeResults = m_cellScalarResults[cellVolIdx][0]; const std::vector<double>& cellVolumeResults = m_cellScalarResults[cellVolIdx][0];
size_t soilIdx = this->findOrLoadKnownScalarResult(RiaDefines::DYNAMIC_NATIVE, "SOIL"); size_t soilIdx = this->findOrLoadKnownScalarResult(RigEclipseResultAddress(RiaDefines::DYNAMIC_NATIVE, "SOIL"));
size_t oilVolIdx = this->findOrCreateScalarResultIndex(RiaDefines::DYNAMIC_NATIVE, RiaDefines::riOilVolumeResultName(), false); size_t oilVolIdx = this->findOrCreateScalarResultIndex( RigEclipseResultAddress(RiaDefines::DYNAMIC_NATIVE,
RiaDefines::riOilVolumeResultName()),
false);
m_cellScalarResults[oilVolIdx].resize(this->maxTimeStepCount()); m_cellScalarResults[oilVolIdx].resize(this->maxTimeStepCount());
size_t cellResultCount = m_activeCellInfo->reservoirCellResultCount(); size_t cellResultCount = m_activeCellInfo->reservoirCellResultCount();
@@ -2629,7 +2576,7 @@ void RigCaseCellResultsData::computeMobilePV()
multpvResults = multpvResults =
RigCaseCellResultsData::getResultIndexableStaticResult(this->activeCellInfo(), this, "MULTPV", multpvDataTemp); RigCaseCellResultsData::getResultIndexableStaticResult(this->activeCellInfo(), this, "MULTPV", multpvDataTemp);
size_t mobPVIdx = this->findOrCreateScalarResultIndex(RiaDefines::STATIC_NATIVE, RiaDefines::mobilePoreVolumeName(), false); size_t mobPVIdx = this->findOrCreateScalarResultIndex(RigEclipseResultAddress(RiaDefines::STATIC_NATIVE, RiaDefines::mobilePoreVolumeName()), false);
std::vector<double>& mobPVResults = m_cellScalarResults[mobPVIdx][0]; std::vector<double>& mobPVResults = m_cellScalarResults[mobPVIdx][0];
@@ -2855,11 +2802,56 @@ size_t RigCaseCellResultsData::findScalarResultIndexFromAddress(const RigEclipse
} }
else if (resVarAddr.m_resultCatType == RiaDefines::UNDEFINED) else if (resVarAddr.m_resultCatType == RiaDefines::UNDEFINED)
{ {
return findScalarResultIndex(resVarAddr.m_resultName); RigEclipseResultAddress resVarAddressWithType = resVarAddr;
resVarAddressWithType.m_resultCatType = RiaDefines::STATIC_NATIVE;
size_t scalarResultIndex = this->findScalarResultIndexFromAddress(resVarAddressWithType);
if (scalarResultIndex == cvf::UNDEFINED_SIZE_T)
{
resVarAddressWithType.m_resultCatType = RiaDefines::DYNAMIC_NATIVE;
scalarResultIndex = this->findScalarResultIndexFromAddress(resVarAddressWithType);
}
if (scalarResultIndex == cvf::UNDEFINED_SIZE_T)
{
resVarAddressWithType.m_resultCatType = RiaDefines::SOURSIMRL;
scalarResultIndex = this->findScalarResultIndexFromAddress(resVarAddressWithType);
}
if (scalarResultIndex == cvf::UNDEFINED_SIZE_T)
{
resVarAddressWithType.m_resultCatType = RiaDefines::GENERATED;
scalarResultIndex = this->findScalarResultIndexFromAddress(resVarAddressWithType);
}
if (scalarResultIndex == cvf::UNDEFINED_SIZE_T)
{
resVarAddressWithType.m_resultCatType = RiaDefines::INPUT_PROPERTY;
scalarResultIndex = this->findScalarResultIndexFromAddress(resVarAddressWithType);
}
if (scalarResultIndex == cvf::UNDEFINED_SIZE_T)
{
resVarAddressWithType.m_resultCatType = RiaDefines::FORMATION_NAMES;
scalarResultIndex = this->findScalarResultIndexFromAddress(resVarAddressWithType);
}
return scalarResultIndex;
} }
else else
{ {
return findScalarResultIndex(resVarAddr.m_resultCatType, resVarAddr.m_resultName); std::vector<RigEclipseResultInfo>::const_iterator it;
for (it = m_resultInfos.begin(); it != m_resultInfos.end(); ++it)
{
if (it->toAddress() == resVarAddr)
{
return it->gridScalarResultIndex();
}
}
return cvf::UNDEFINED_SIZE_T;
} }
} }
@@ -2890,21 +2882,26 @@ void RigCaseCellResultsData::copyResultsMetaDataFromMainCase(RigEclipseCaseData*
for ( size_t resIdx = 0; resIdx < resultInfos.size(); resIdx++ ) for ( size_t resIdx = 0; resIdx < resultInfos.size(); resIdx++ )
{ {
RiaDefines::ResultCatType resultType = resultInfos[resIdx].resultType(); RigEclipseResultAddress resVarAddr = resultInfos[resIdx].toAddress();
QString resultName = resultInfos[resIdx].resultName();
bool needsToBeStored = resultInfos[resIdx].needsToBeStored(); bool needsToBeStored = resultInfos[resIdx].needsToBeStored();
bool mustBeCalculated = resultInfos[resIdx].mustBeCalculated(); bool mustBeCalculated = resultInfos[resIdx].mustBeCalculated();
size_t scalarResultIndex = cellResultsStorage->findScalarResultIndex(resultType, resultName); size_t scalarResultIndex = cellResultsStorage->findScalarResultIndexFromAddress(resVarAddr);
if ( scalarResultIndex == cvf::UNDEFINED_SIZE_T ) if ( scalarResultIndex == cvf::UNDEFINED_SIZE_T )
{ {
scalarResultIndex = cellResultsStorage->findOrCreateScalarResultIndex(resultType, resultName, needsToBeStored); cellResultsStorage->createResultEntry(resVarAddr, needsToBeStored);
if ( mustBeCalculated ) cellResultsStorage->setMustBeCalculated(scalarResultIndex); if ( mustBeCalculated )
{
scalarResultIndex = cellResultsStorage->findScalarResultIndexFromAddress(resVarAddr);
cellResultsStorage->setMustBeCalculated(scalarResultIndex);
}
cellResultsStorage->setTimeStepInfos(RigEclipseResultAddress(resultType, resultName), timeStepInfos); cellResultsStorage->setTimeStepInfos(resVarAddr, timeStepInfos);
std::vector< std::vector<double> >& dataValues = cellResultsStorage->modifiableCellScalarResultTimesteps(RigEclipseResultAddress(resultType, resultName)); std::vector< std::vector<double> >& dataValues = cellResultsStorage->modifiableCellScalarResultTimesteps(resVarAddr);
dataValues.resize(timeStepInfos.size()); dataValues.resize(timeStepInfos.size());
} }
} }
@@ -138,14 +138,12 @@ public:
RiaDefines::PorosityModelType poroModel, RiaDefines::PorosityModelType poroModel,
std::vector<RimEclipseCase*> destinationCases); std::vector<RimEclipseCase*> destinationCases);
private: private:
size_t findOrLoadKnownScalarResult(RiaDefines::ResultCatType type, const QString& resultName); size_t findOrLoadKnownScalarResult(const RigEclipseResultAddress& resVarAddr);
size_t findOrLoadKnownScalarResult(const QString& resultName); ///< Simplified search. Assumes unique names across types. size_t findOrLoadKnownScalarResultForTimeStep(const RigEclipseResultAddress& resVarAddr,
size_t findOrLoadKnownScalarResultForTimeStep(RiaDefines::ResultCatType type,
const QString& resultName,
size_t timeStepIndex); size_t timeStepIndex);
size_t findOrCreateScalarResultIndex(RiaDefines::ResultCatType type, const QString& resultName, bool needsToBeStored); size_t findOrCreateScalarResultIndex(const RigEclipseResultAddress& resVarAddr, bool needsToBeStored);
size_t findScalarResultIndex(RiaDefines::ResultCatType type, const QString& resultName) const;
size_t findScalarResultIndex(const QString& resultName) const; size_t findScalarResultIndexFromAddress(const RigEclipseResultAddress& resVarAddr ) const;
size_t addStaticScalarResult(RiaDefines::ResultCatType type, size_t addStaticScalarResult(RiaDefines::ResultCatType type,
const QString& resultName, const QString& resultName,
@@ -182,7 +180,6 @@ private:
void assignValuesToTemporaryLgrs(const QString& resultName, std::vector<double>& values); void assignValuesToTemporaryLgrs(const QString& resultName, std::vector<double>& values);
RigStatisticsDataCache* statistics(const RigEclipseResultAddress& resVarAddr); RigStatisticsDataCache* statistics(const RigEclipseResultAddress& resVarAddr);
size_t findScalarResultIndexFromAddress(const RigEclipseResultAddress& resVarAddr ) const;
private: private:
cvf::ref<RifReaderInterface> m_readerInterface; cvf::ref<RifReaderInterface> m_readerInterface;
@@ -25,16 +25,19 @@ class RigEclipseResultAddress
public: public:
RigEclipseResultAddress() RigEclipseResultAddress()
: m_resultCatType(RiaDefines::UNDEFINED) : m_resultCatType(RiaDefines::UNDEFINED)
, m_timeLapseBaseFrameIdx(NO_TIME_LAPSE)
{} {}
explicit RigEclipseResultAddress(const QString& resultName) explicit RigEclipseResultAddress(const QString& resultName)
: m_resultCatType(RiaDefines::UNDEFINED) : m_resultCatType(RiaDefines::UNDEFINED)
, m_resultName(resultName) , m_resultName(resultName)
, m_timeLapseBaseFrameIdx(NO_TIME_LAPSE)
{} {}
explicit RigEclipseResultAddress(RiaDefines::ResultCatType type, const QString& resultName) explicit RigEclipseResultAddress(RiaDefines::ResultCatType type, const QString& resultName, int timeLapseBaseTimeStep = NO_TIME_LAPSE)
: m_resultCatType(type) : m_resultCatType(type)
, m_resultName(resultName) , m_resultName(resultName)
, m_timeLapseBaseFrameIdx(timeLapseBaseTimeStep)
{} {}
bool isValid() const bool isValid() const
@@ -44,8 +47,19 @@ public:
return false; return false;
} }
static const int ALL_TIME_LAPSES = -2;
static const int NO_TIME_LAPSE = -1;
bool isTimeLapse() const { return m_timeLapseBaseFrameIdx > NO_TIME_LAPSE;}
bool representsAllTimeLapses() const { return m_timeLapseBaseFrameIdx == ALL_TIME_LAPSES;}
bool operator< (const RigEclipseResultAddress& other ) const bool operator< (const RigEclipseResultAddress& other ) const
{ {
if (m_timeLapseBaseFrameIdx != other.m_timeLapseBaseFrameIdx)
{
return (m_timeLapseBaseFrameIdx < other.m_timeLapseBaseFrameIdx);
}
if (m_resultCatType != other.m_resultCatType) if (m_resultCatType != other.m_resultCatType)
{ {
return (m_resultCatType < other.m_resultCatType); return (m_resultCatType < other.m_resultCatType);
@@ -54,8 +68,22 @@ public:
return (m_resultName < other.m_resultName); return (m_resultName < other.m_resultName);
} }
bool operator==(const RigEclipseResultAddress& other ) const
{
if ( m_resultCatType != other.m_resultCatType
|| m_resultName != other.m_resultName
|| m_timeLapseBaseFrameIdx != other.m_timeLapseBaseFrameIdx)
{
return false;
}
return true;
}
RiaDefines::ResultCatType m_resultCatType; RiaDefines::ResultCatType m_resultCatType;
QString m_resultName; QString m_resultName;
int m_timeLapseBaseFrameIdx;
}; };
@@ -53,12 +53,14 @@ std::vector<RigEclipseTimeStepInfo> RigEclipseTimeStepInfo::createTimeStepInfos(
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RigEclipseResultInfo::RigEclipseResultInfo(RiaDefines::ResultCatType resultType, RigEclipseResultInfo::RigEclipseResultInfo(const RigEclipseResultAddress& resultAddress,
QString resultName, bool needsToBeStored, bool mustBeCalculated, size_t gridScalarResultIndex) : m_resultType(resultType), bool needsToBeStored,
m_needsToBeStored(needsToBeStored), bool mustBeCalculated,
m_mustBeCalculated(mustBeCalculated), size_t gridScalarResultIndex)
m_resultName(resultName), : m_resultAddress(resultAddress)
m_gridScalarResultIndex(gridScalarResultIndex) , m_needsToBeStored(needsToBeStored)
, m_mustBeCalculated(mustBeCalculated)
, m_gridScalarResultIndex(gridScalarResultIndex)
{ {
} }
@@ -67,7 +69,7 @@ RigEclipseResultInfo::RigEclipseResultInfo(RiaDefines::ResultCatType resultType,
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RiaDefines::ResultCatType RigEclipseResultInfo::resultType() const RiaDefines::ResultCatType RigEclipseResultInfo::resultType() const
{ {
return m_resultType; return m_resultAddress.m_resultCatType;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -75,7 +77,7 @@ RiaDefines::ResultCatType RigEclipseResultInfo::resultType() const
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RigEclipseResultInfo::setResultType(RiaDefines::ResultCatType newType) void RigEclipseResultInfo::setResultType(RiaDefines::ResultCatType newType)
{ {
m_resultType = newType; m_resultAddress.m_resultCatType = newType;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -83,7 +85,7 @@ void RigEclipseResultInfo::setResultType(RiaDefines::ResultCatType newType)
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
const QString& RigEclipseResultInfo::resultName() const const QString& RigEclipseResultInfo::resultName() const
{ {
return m_resultName; return m_resultAddress.m_resultName;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -91,7 +93,7 @@ const QString& RigEclipseResultInfo::resultName() const
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RigEclipseResultInfo::setResultName(const QString& name) void RigEclipseResultInfo::setResultName(const QString& name)
{ {
m_resultName = name; m_resultAddress.m_resultName = name;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -194,13 +196,5 @@ std::vector<int> RigEclipseResultInfo::reportNumbers() const
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RigEclipseResultInfo::operator<(const RigEclipseResultInfo& rhs) const bool RigEclipseResultInfo::operator<(const RigEclipseResultInfo& rhs) const
{ {
if (m_resultType != rhs.resultType()) return m_resultAddress < rhs.m_resultAddress;
{
return m_resultType < rhs.resultType();
}
if (m_resultName != rhs.resultName())
{
return m_resultName < rhs.resultName();
}
return false;
} }
@@ -51,8 +51,7 @@ public:
class RigEclipseResultInfo class RigEclipseResultInfo
{ {
public: public:
RigEclipseResultInfo(RiaDefines::ResultCatType resultType, RigEclipseResultInfo(const RigEclipseResultAddress& resultAddress,
QString resultName,
bool needsToBeStored = false, bool needsToBeStored = false,
bool mustBeCalculated = false, bool mustBeCalculated = false,
size_t gridScalarResultIndex = 0u); size_t gridScalarResultIndex = 0u);
@@ -67,7 +66,7 @@ public:
bool operator<(const RigEclipseResultInfo& rhs) const; bool operator<(const RigEclipseResultInfo& rhs) const;
RigEclipseResultAddress toAddress() const { return RigEclipseResultAddress (m_resultType, m_resultName );} RigEclipseResultAddress toAddress() const { return m_resultAddress;}
private: private:
friend class RigCaseCellResultsData; friend class RigCaseCellResultsData;
@@ -80,11 +79,11 @@ private:
const std::vector<RigEclipseTimeStepInfo>& timeStepInfos() const; const std::vector<RigEclipseTimeStepInfo>& timeStepInfos() const;
void setTimeStepInfos(const std::vector<RigEclipseTimeStepInfo>& timeSteps); void setTimeStepInfos(const std::vector<RigEclipseTimeStepInfo>& timeSteps);
RiaDefines::ResultCatType m_resultType; RigEclipseResultAddress m_resultAddress;
size_t m_gridScalarResultIndex;
std::vector<RigEclipseTimeStepInfo> m_timeStepInfos;
bool m_needsToBeStored; bool m_needsToBeStored;
bool m_mustBeCalculated; bool m_mustBeCalculated;
QString m_resultName;
size_t m_gridScalarResultIndex;
std::vector<RigEclipseTimeStepInfo> m_timeStepInfos;
}; };