mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#3958 Refactoring: RigCaseCellResultsData: Remove the final result index based interface
This commit is contained in:
@@ -1304,6 +1304,64 @@ size_t RigCaseCellResultsData::findOrLoadKnownScalarResult(RiaDefines::ResultCat
|
||||
return scalarResultIndex;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RigCaseCellResultsData::ensureKnownResultLoaded(const RigEclipseResultAddress& resultAddress)
|
||||
{
|
||||
size_t resultIndex = cvf::UNDEFINED_SIZE_T;
|
||||
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);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RigCaseCellResultsData::hasResultEntry(const RigEclipseResultAddress& resultAddress) const
|
||||
{
|
||||
size_t resultIndex = cvf::UNDEFINED_SIZE_T;
|
||||
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);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigCaseCellResultsData::createResultEntry(const RigEclipseResultAddress& resultAddress, bool needsToBeStored)
|
||||
{
|
||||
findOrCreateScalarResultIndex(resultAddress.m_resultCatType, resultAddress.m_resultName, needsToBeStored);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigCaseCellResultsData::ensureKnownResultLoadedForTimeStep(const RigEclipseResultAddress& resultAddress,
|
||||
size_t timeStepIndex)
|
||||
{
|
||||
CAF_ASSERT(resultAddress.m_resultCatType != RiaDefines::UNDEFINED);
|
||||
|
||||
findOrLoadKnownScalarResultForTimeStep(resultAddress.m_resultCatType,
|
||||
resultAddress.m_resultName,
|
||||
timeStepIndex);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// 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.
|
||||
|
||||
@@ -115,19 +115,10 @@ public:
|
||||
|
||||
bool updateResultName(RiaDefines::ResultCatType resultType, QString& oldName, const QString& newName);
|
||||
|
||||
// Index based stuff to rewrite/hide -->
|
||||
|
||||
size_t findOrLoadKnownScalarResultForTimeStep(RiaDefines::ResultCatType type, const QString& resultName, size_t timeStepIndex);
|
||||
size_t findOrLoadKnownScalarResult(RiaDefines::ResultCatType type, const QString& resultName);
|
||||
size_t findOrLoadKnownScalarResult(const QString& resultName); ///< Simplified search. Assumes unique names across types.
|
||||
|
||||
// Find or create a slot for the results
|
||||
|
||||
size_t findOrCreateScalarResultIndex(RiaDefines::ResultCatType type, const QString& resultName, bool needsToBeStored);
|
||||
size_t findScalarResultIndex(RiaDefines::ResultCatType type, const QString& resultName) const;
|
||||
size_t findScalarResultIndex(const QString& resultName) const;
|
||||
|
||||
// <---
|
||||
void ensureKnownResultLoadedForTimeStep(const RigEclipseResultAddress& resultAddress, size_t timeStepIndex);
|
||||
bool ensureKnownResultLoaded(const RigEclipseResultAddress& resultAddress);
|
||||
bool hasResultEntry(const RigEclipseResultAddress& resultAddress) const;
|
||||
void createResultEntry(const RigEclipseResultAddress& resultAddress, bool needsToBeStored);
|
||||
|
||||
// Access the results data
|
||||
|
||||
@@ -148,6 +139,15 @@ public:
|
||||
const RigEclipseResultInfo* resultInfo(const RigEclipseResultAddress& resVarAddr) const;
|
||||
|
||||
private:
|
||||
size_t findOrLoadKnownScalarResult(RiaDefines::ResultCatType type, const QString& resultName);
|
||||
size_t findOrLoadKnownScalarResult(const QString& resultName); ///< Simplified search. Assumes unique names across types.
|
||||
size_t findOrLoadKnownScalarResultForTimeStep(RiaDefines::ResultCatType type,
|
||||
const QString& resultName,
|
||||
size_t timeStepIndex);
|
||||
size_t findOrCreateScalarResultIndex(RiaDefines::ResultCatType type, const QString& resultName, bool needsToBeStored);
|
||||
size_t findScalarResultIndex(RiaDefines::ResultCatType type, const QString& resultName) const;
|
||||
size_t findScalarResultIndex(const QString& resultName) const;
|
||||
|
||||
size_t addStaticScalarResult(RiaDefines::ResultCatType type,
|
||||
const QString& resultName,
|
||||
bool needsToBeStored,
|
||||
|
||||
@@ -730,10 +730,9 @@ const std::vector<double>* RigEclipseCaseData::resultValues(RiaDefines::Porosity
|
||||
size_t timeStepIndex)
|
||||
{
|
||||
RigCaseCellResultsData* gridCellResults = this->results(porosityModel);
|
||||
size_t scalarResultIndex = gridCellResults->findOrLoadKnownScalarResult(type, resultName);
|
||||
|
||||
const std::vector<double>* swatResults = nullptr;
|
||||
if (scalarResultIndex != cvf::UNDEFINED_SIZE_T)
|
||||
if (gridCellResults->ensureKnownResultLoaded(RigEclipseResultAddress(type, resultName)))
|
||||
{
|
||||
swatResults = &(gridCellResults->cellScalarResults(RigEclipseResultAddress(type, resultName), timeStepIndex));
|
||||
}
|
||||
|
||||
@@ -101,16 +101,16 @@ size_t RigEclipseNativeStatCalc::timeStepCount()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigEclipseNativeStatCalc::mobileVolumeWeightedMean(size_t timeStepIndex, double& mean)
|
||||
{
|
||||
size_t mobPVResultIndex = m_resultsData->findOrLoadKnownScalarResult(RiaDefines::ResultCatType::STATIC_NATIVE, RiaDefines::mobilePoreVolumeName());
|
||||
RigEclipseResultAddress mobPorvAddress(RiaDefines::ResultCatType::STATIC_NATIVE, RiaDefines::mobilePoreVolumeName());
|
||||
|
||||
// For statistics result cases, the pore volume is not available, as RigCaseCellResultsData::createPlaceholderResultEntries
|
||||
// has not been executed
|
||||
if (mobPVResultIndex == cvf::UNDEFINED_SIZE_T)
|
||||
if (!m_resultsData->ensureKnownResultLoaded(mobPorvAddress))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const std::vector<double>& weights = m_resultsData->cellScalarResults(RigEclipseResultAddress(RiaDefines::ResultCatType::STATIC_NATIVE, RiaDefines::mobilePoreVolumeName()), 0);
|
||||
const std::vector<double>& weights = m_resultsData->cellScalarResults(mobPorvAddress, 0);
|
||||
const std::vector<double>& values = m_resultsData->cellScalarResults(m_eclipseResultAddress, timeStepIndex);
|
||||
|
||||
const RigActiveCellInfo* actCellInfo = m_resultsData->activeCellInfo();
|
||||
|
||||
@@ -105,9 +105,11 @@ size_t RigEclipseNativeVisibleCellsStatCalc::timeStepCount()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigEclipseNativeVisibleCellsStatCalc::mobileVolumeWeightedMean(size_t timeStepIndex, double &result)
|
||||
{
|
||||
m_caseData->findOrLoadKnownScalarResult(RiaDefines::ResultCatType::STATIC_NATIVE, RiaDefines::mobilePoreVolumeName());
|
||||
RigEclipseResultAddress mobPorvAddress(RiaDefines::ResultCatType::STATIC_NATIVE, RiaDefines::mobilePoreVolumeName());
|
||||
|
||||
const std::vector<double>& weights = m_caseData->cellScalarResults(RigEclipseResultAddress(RiaDefines::ResultCatType::STATIC_NATIVE, RiaDefines::mobilePoreVolumeName()), 0);
|
||||
m_caseData->ensureKnownResultLoaded(mobPorvAddress);
|
||||
|
||||
const std::vector<double>& weights = m_caseData->cellScalarResults(mobPorvAddress, 0);
|
||||
const std::vector<double>& values = m_caseData->cellScalarResults(m_resultAddress, timeStepIndex);
|
||||
|
||||
const RigActiveCellInfo* actCellInfo = m_caseData->activeCellInfo();
|
||||
|
||||
@@ -119,10 +119,11 @@ void RigFlowDiagStatCalc::mobileVolumeWeightedMean(size_t timeStepIndex, double&
|
||||
if (!eclCase) return;
|
||||
|
||||
RigCaseCellResultsData* caseCellResultsData = eclCase->results(RiaDefines::MATRIX_MODEL);
|
||||
RigEclipseResultAddress mobPoreVolResAddr(RiaDefines::ResultCatType::STATIC_NATIVE, RiaDefines::mobilePoreVolumeName());
|
||||
|
||||
caseCellResultsData->findOrLoadKnownScalarResult(RiaDefines::ResultCatType::STATIC_NATIVE, RiaDefines::mobilePoreVolumeName());
|
||||
caseCellResultsData->ensureKnownResultLoaded(mobPoreVolResAddr);
|
||||
|
||||
const std::vector<double>& weights = caseCellResultsData->cellScalarResults(RigEclipseResultAddress(RiaDefines::ResultCatType::STATIC_NATIVE, RiaDefines::mobilePoreVolumeName()), 0);
|
||||
const std::vector<double>& weights = caseCellResultsData->cellScalarResults(mobPoreVolResAddr, 0);
|
||||
const std::vector<double>* values = m_resultsData->resultValues(m_resVarAddr, timeStepIndex);
|
||||
|
||||
const RigActiveCellInfo* actCellInfo = m_resultsData->activeCellInfo(m_resVarAddr);
|
||||
|
||||
@@ -109,9 +109,10 @@ void RigFlowDiagVisibleCellsStatCalc::mobileVolumeWeightedMean(size_t timeStepIn
|
||||
|
||||
RigCaseCellResultsData* caseCellResultsData = eclCase->results(RiaDefines::MATRIX_MODEL);
|
||||
|
||||
caseCellResultsData->findOrLoadKnownScalarResult(RiaDefines::ResultCatType::STATIC_NATIVE, RiaDefines::mobilePoreVolumeName());
|
||||
|
||||
const std::vector<double>& weights = caseCellResultsData->cellScalarResults(RigEclipseResultAddress(RiaDefines::ResultCatType::STATIC_NATIVE, RiaDefines::mobilePoreVolumeName()), 0);
|
||||
RigEclipseResultAddress mobPorvAddr(RiaDefines::ResultCatType::STATIC_NATIVE, RiaDefines::mobilePoreVolumeName());
|
||||
|
||||
caseCellResultsData->ensureKnownResultLoaded(mobPorvAddr);
|
||||
const std::vector<double>& weights = caseCellResultsData->cellScalarResults(mobPorvAddr, 0);
|
||||
const std::vector<double>* values = m_resultsData->resultValues(m_resVarAddr, timeStepIndex);
|
||||
|
||||
const RigActiveCellInfo* actCellInfo = m_resultsData->activeCellInfo(m_resVarAddr);
|
||||
|
||||
@@ -71,21 +71,25 @@ RigNumberOfFloodedPoreVolumesCalculator::RigNumberOfFloodedPoreVolumesCalculator
|
||||
std::vector<RigEclipseResultAddress> tracerResAddrs;
|
||||
for (QString tracerName : tracerNames)
|
||||
{
|
||||
if (gridCellResults->findOrLoadKnownScalarResult(RiaDefines::DYNAMIC_NATIVE, tracerName) != cvf::UNDEFINED_SIZE_T)
|
||||
RigEclipseResultAddress tracerResAddr(RiaDefines::DYNAMIC_NATIVE, tracerName);
|
||||
if (gridCellResults->ensureKnownResultLoaded(tracerResAddr) )
|
||||
{
|
||||
tracerResAddrs.push_back(RigEclipseResultAddress(RiaDefines::DYNAMIC_NATIVE, tracerName));
|
||||
tracerResAddrs.push_back(tracerResAddr);
|
||||
}
|
||||
progress.incrementProgress();
|
||||
}
|
||||
std::vector<std::vector<double> > summedTracersAtAllTimesteps;
|
||||
|
||||
//TODO: Option for Oil and Gas instead of water
|
||||
RigEclipseResultAddress flrWatIAddr(RiaDefines::DYNAMIC_NATIVE, "FLRWATI+");
|
||||
RigEclipseResultAddress flrWatJAddr(RiaDefines::DYNAMIC_NATIVE, "FLRWATJ+");
|
||||
RigEclipseResultAddress flrWatKAddr(RiaDefines::DYNAMIC_NATIVE, "FLRWATK+");
|
||||
|
||||
size_t scalarResultIndexFlowrateI = gridCellResults->findOrLoadKnownScalarResult(RiaDefines::DYNAMIC_NATIVE, "FLRWATI+");
|
||||
bool hasFlowrateI = gridCellResults->ensureKnownResultLoaded(flrWatIAddr);
|
||||
progress.incrementProgress();
|
||||
size_t scalarResultIndexFlowrateJ = gridCellResults->findOrLoadKnownScalarResult(RiaDefines::DYNAMIC_NATIVE, "FLRWATJ+");
|
||||
bool hasFlowrateJ = gridCellResults->ensureKnownResultLoaded(flrWatJAddr);
|
||||
progress.incrementProgress();
|
||||
size_t scalarResultIndexFlowrateK = gridCellResults->findOrLoadKnownScalarResult(RiaDefines::DYNAMIC_NATIVE, "FLRWATK+");
|
||||
bool hasFlowrateK = gridCellResults->ensureKnownResultLoaded(flrWatKAddr);
|
||||
progress.incrementProgress();
|
||||
|
||||
std::vector<const std::vector<double>* > flowrateIatAllTimeSteps;
|
||||
@@ -110,27 +114,27 @@ RigNumberOfFloodedPoreVolumesCalculator::RigNumberOfFloodedPoreVolumesCalculator
|
||||
for (size_t timeStep = 0; timeStep < daysSinceSimulationStart.size(); timeStep++)
|
||||
{
|
||||
const std::vector<double>* flowrateI = nullptr;
|
||||
if (scalarResultIndexFlowrateI != cvf::UNDEFINED_SIZE_T)
|
||||
if (hasFlowrateI)
|
||||
{
|
||||
flowrateI = &(eclipseCaseData->results(RiaDefines::MATRIX_MODEL)->cellScalarResults(RigEclipseResultAddress(RiaDefines::DYNAMIC_NATIVE, "FLRWATI+"),
|
||||
flowrateI = &(eclipseCaseData->results(RiaDefines::MATRIX_MODEL)->cellScalarResults(flrWatIAddr,
|
||||
timeStep));
|
||||
}
|
||||
flowrateIatAllTimeSteps.push_back(flowrateI);
|
||||
|
||||
|
||||
const std::vector<double>* flowrateJ = nullptr;
|
||||
if (scalarResultIndexFlowrateJ != cvf::UNDEFINED_SIZE_T)
|
||||
if (hasFlowrateJ)
|
||||
{
|
||||
flowrateJ = &(eclipseCaseData->results(RiaDefines::MATRIX_MODEL)->cellScalarResults(RigEclipseResultAddress(RiaDefines::DYNAMIC_NATIVE, "FLRWATJ+"),
|
||||
flowrateJ = &(eclipseCaseData->results(RiaDefines::MATRIX_MODEL)->cellScalarResults(flrWatJAddr,
|
||||
timeStep));
|
||||
}
|
||||
flowrateJatAllTimeSteps.push_back(flowrateJ);
|
||||
|
||||
|
||||
const std::vector<double>* flowrateK = nullptr;
|
||||
if (scalarResultIndexFlowrateK != cvf::UNDEFINED_SIZE_T)
|
||||
if (hasFlowrateK)
|
||||
{
|
||||
flowrateK = &(eclipseCaseData->results(RiaDefines::MATRIX_MODEL)->cellScalarResults(RigEclipseResultAddress(RiaDefines::DYNAMIC_NATIVE, "FLRWATK+"),
|
||||
flowrateK = &(eclipseCaseData->results(RiaDefines::MATRIX_MODEL)->cellScalarResults(flrWatKAddr,
|
||||
timeStep));
|
||||
}
|
||||
flowrateKatAllTimeSteps.push_back(flowrateK);
|
||||
|
||||
@@ -71,8 +71,7 @@ cvf::ref<RigResultAccessor> RigResultAccessorFactory::createFromNameAndType(cons
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
size_t scalarSetIndex = eclipseCase->results(porosityModel)->findScalarResultIndex(resultType, uiResultName);
|
||||
if (scalarSetIndex == cvf::UNDEFINED_SIZE_T)
|
||||
if (!eclipseCase->results(porosityModel)->hasResultEntry(RigEclipseResultAddress(resultType, uiResultName)))
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
@@ -91,7 +90,7 @@ cvf::ref<RigResultAccessor> RigResultAccessorFactory::createFromNameAndType(cons
|
||||
adjustedTimeStepIndex = 0;
|
||||
}
|
||||
|
||||
return createFromResultIdx(eclipseCase, gridIndex, porosityModel, adjustedTimeStepIndex, RigEclipseResultAddress(resultType, uiResultName));
|
||||
return createFromResultAddress(eclipseCase, gridIndex, porosityModel, adjustedTimeStepIndex, RigEclipseResultAddress(resultType, uiResultName));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -148,13 +147,12 @@ cvf::ref<RigResultAccessor> RigResultAccessorFactory::createNativeFromUiResultNa
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
size_t scalarSetIndex = eclipseCase->results(porosityModel)->findScalarResultIndex(uiResultName);
|
||||
if (scalarSetIndex == cvf::UNDEFINED_SIZE_T)
|
||||
if (!eclipseCase->results(porosityModel)->hasResultEntry(RigEclipseResultAddress(uiResultName)))
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return createFromResultIdx(eclipseCase, gridIndex, porosityModel, timeStepIndex, RigEclipseResultAddress(uiResultName));
|
||||
return createFromResultAddress(eclipseCase, gridIndex, porosityModel, timeStepIndex, RigEclipseResultAddress(uiResultName));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -302,11 +300,11 @@ cvf::ref<RigResultAccessor> RigResultAccessorFactory::createDerivedResultAccesso
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<RigResultAccessor> RigResultAccessorFactory::createFromResultIdx(const RigEclipseCaseData* eclipseCase,
|
||||
size_t gridIndex,
|
||||
RiaDefines::PorosityModelType porosityModel,
|
||||
size_t timeStepIndex,
|
||||
const RigEclipseResultAddress& resultAddress)
|
||||
cvf::ref<RigResultAccessor> RigResultAccessorFactory::createFromResultAddress(const RigEclipseCaseData* eclipseCase,
|
||||
size_t gridIndex,
|
||||
RiaDefines::PorosityModelType porosityModel,
|
||||
size_t timeStepIndex,
|
||||
const RigEclipseResultAddress& resultAddress)
|
||||
{
|
||||
if ( !resultAddress.isValid() )
|
||||
{
|
||||
|
||||
@@ -55,11 +55,11 @@ public:
|
||||
RiaDefines::ResultCatType resultType);
|
||||
|
||||
static cvf::ref<RigResultAccessor>
|
||||
createFromResultIdx(const RigEclipseCaseData* eclipseCase,
|
||||
size_t gridIndex,
|
||||
RiaDefines::PorosityModelType porosityModel,
|
||||
size_t timeStepIndex,
|
||||
const RigEclipseResultAddress& resultIndex);
|
||||
createFromResultAddress(const RigEclipseCaseData* eclipseCase,
|
||||
size_t gridIndex,
|
||||
RiaDefines::PorosityModelType porosityModel,
|
||||
size_t timeStepIndex,
|
||||
const RigEclipseResultAddress& resultIndex);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -26,28 +26,6 @@
|
||||
#include <cmath>
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// This function must be harmonized with RigResultAccessorFactory::createNativeResultAccessor()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<RigResultModifier> RigResultModifierFactory::createResultModifier(RigEclipseCaseData* eclipseCase,
|
||||
size_t gridIndex,
|
||||
RiaDefines::PorosityModelType porosityModel,
|
||||
size_t timeStepIndex,
|
||||
QString& uiResultName)
|
||||
{
|
||||
if (!eclipseCase) return nullptr;
|
||||
|
||||
if (!eclipseCase->results(porosityModel) || !eclipseCase->activeCellInfo(porosityModel))
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
eclipseCase->results(porosityModel)->findScalarResultIndex(uiResultName);
|
||||
|
||||
return createResultModifier(eclipseCase, gridIndex, porosityModel, timeStepIndex, RigEclipseResultAddress(uiResultName));
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -28,13 +28,7 @@ class RigEclipseResultAddress;
|
||||
class RigResultModifierFactory
|
||||
{
|
||||
public:
|
||||
static cvf::ref<RigResultModifier>
|
||||
createResultModifier(RigEclipseCaseData* eclipseCase,
|
||||
size_t gridIndex,
|
||||
RiaDefines::PorosityModelType porosityModel,
|
||||
size_t timeStepIndex,
|
||||
QString& uiResultName);
|
||||
|
||||
|
||||
static cvf::ref<RigResultModifier>
|
||||
createResultModifier(RigEclipseCaseData* eclipseCase,
|
||||
size_t gridIndex,
|
||||
|
||||
Reference in New Issue
Block a user