mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-12 16:32:12 -05:00
Grid calculations: Free memory after data has been read
When data has been read for a variable, free the related data to make sure the memory footprint is as low as possible.
This commit is contained in:
1 parent
e1007ca957
commit
d61838940a
3 files changed
+22
-9
No files matched your search
@@ -559,16 +559,18 @@ std::vector<double> RimGridCalculation::getDataForResult( const QString&
|
|||||||
|
|
||||||
auto eclipseCaseData = sourceCase->eclipseCaseData();
|
auto eclipseCaseData = sourceCase->eclipseCaseData();
|
||||||
auto rigCaseCellResultsData = eclipseCaseData->results( porosityModel );
|
auto rigCaseCellResultsData = eclipseCaseData->results( porosityModel );
|
||||||
if ( !rigCaseCellResultsData->ensureKnownResultLoaded( resAddr ) ) return {};
|
if ( !rigCaseCellResultsData->findOrLoadKnownScalarResultForTimeStep( resAddr, timeStepToUse ) ) return {};
|
||||||
|
|
||||||
// Active cell info must always be retrieved from the destination case, as the returned vector must be of the same size as number of
|
// Active cell info must always be retrieved from the destination case, as the returned vector must be of the same size as number of
|
||||||
// active cells in the destination case.
|
// active cells in the destination case. Active cells can be different between source and destination case.
|
||||||
auto activeCellInfoDestination = destinationCase->eclipseCaseData()->activeCellInfo( porosityModel );
|
auto activeCellInfoDestination = destinationCase->eclipseCaseData()->activeCellInfo( porosityModel );
|
||||||
auto activeReservoirCells = activeCellInfoDestination->activeReservoirCellIndices();
|
auto activeReservoirCells = activeCellInfoDestination->activeReservoirCellIndices();
|
||||||
|
|
||||||
std::vector<double> values( activeCellInfoDestination->activeReservoirCellIndices().size() );
|
std::vector<double> values( activeCellInfoDestination->activeReservoirCellIndices().size() );
|
||||||
|
|
||||||
auto resultAccessor = RigResultAccessorFactory::createFromResultAddress( eclipseCaseData, 0, porosityModel, timeStepToUse, resAddr );
|
size_t gridIndex = 0;
|
||||||
|
auto resultAccessor =
|
||||||
|
RigResultAccessorFactory::createFromResultAddress( eclipseCaseData, gridIndex, porosityModel, timeStepToUse, resAddr );
|
||||||
|
|
||||||
#pragma omp parallel for
|
#pragma omp parallel for
|
||||||
for ( int i = 0; i < static_cast<int>( activeReservoirCells.size() ); i++ )
|
for ( int i = 0; i < static_cast<int>( activeReservoirCells.size() ); i++ )
|
||||||
@@ -576,6 +578,11 @@ std::vector<double> RimGridCalculation::getDataForResult( const QString&
|
|||||||
values[i] = resultAccessor->cellScalarGlobIdx( activeReservoirCells[i] );
|
values[i] = resultAccessor->cellScalarGlobIdx( activeReservoirCells[i] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto categoriesToExclude = { RiaDefines::ResultCatType::GENERATED };
|
||||||
|
|
||||||
|
sourceCase->results( RiaDefines::PorosityModelType::MATRIX_MODEL )->freeAllocatedResultsData( categoriesToExclude, timeStepToUse );
|
||||||
|
sourceCase->results( RiaDefines::PorosityModelType::FRACTURE_MODEL )->freeAllocatedResultsData( categoriesToExclude, timeStepToUse );
|
||||||
|
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -742,10 +742,14 @@ void RigCaseCellResultsData::freeAllocatedResultsData( std::vector<RiaDefines::R
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto& dataForTimeStep = m_cellScalarResults[resultIdx][index];
|
auto& dataForTimeStep = m_cellScalarResults[resultIdx][index];
|
||||||
// Using swap with an empty vector as that is the safest way to really get rid of the allocated data in a
|
|
||||||
// vector
|
if ( !dataForTimeStep.empty() )
|
||||||
std::vector<double> empty;
|
{
|
||||||
dataForTimeStep.swap( empty );
|
// Using swap with an empty vector as that is the safest way to really get rid of the allocated data in a
|
||||||
|
// vector
|
||||||
|
std::vector<double> empty;
|
||||||
|
dataForTimeStep.swap( empty );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -131,9 +131,12 @@ public:
|
|||||||
QString makeResultNameUnique( const QString& resultNameProposal ) const;
|
QString makeResultNameUnique( const QString& resultNameProposal ) const;
|
||||||
|
|
||||||
bool ensureKnownResultLoaded( const RigEclipseResultAddress& resultAddress );
|
bool ensureKnownResultLoaded( const RigEclipseResultAddress& resultAddress );
|
||||||
|
|
||||||
bool findAndLoadResultByName( const QString& resultName, const std::vector<RiaDefines::ResultCatType>& resultCategorySearchOrder );
|
bool findAndLoadResultByName( const QString& resultName, const std::vector<RiaDefines::ResultCatType>& resultCategorySearchOrder );
|
||||||
|
|
||||||
|
// Load result for a single time step. This can be used to process data for a single time step
|
||||||
|
// Other data access functions assume all time steps are loaded at the same time
|
||||||
|
size_t findOrLoadKnownScalarResultForTimeStep( const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex );
|
||||||
|
|
||||||
bool hasResultEntry( const RigEclipseResultAddress& resultAddress ) const;
|
bool hasResultEntry( const RigEclipseResultAddress& resultAddress ) const;
|
||||||
bool isResultLoaded( const RigEclipseResultAddress& resultAddress ) const;
|
bool isResultLoaded( const RigEclipseResultAddress& resultAddress ) const;
|
||||||
void createResultEntry( const RigEclipseResultAddress& resultAddress, bool needsToBeStored );
|
void createResultEntry( const RigEclipseResultAddress& resultAddress, bool needsToBeStored );
|
||||||
@@ -167,7 +170,6 @@ private:
|
|||||||
friend class RigOilVolumeResultCalculator;
|
friend class RigOilVolumeResultCalculator;
|
||||||
friend class RigCellVolumeResultCalculator;
|
friend class RigCellVolumeResultCalculator;
|
||||||
friend class RigCellsWithNncsCalculator;
|
friend class RigCellsWithNncsCalculator;
|
||||||
size_t findOrLoadKnownScalarResultForTimeStep( const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex );
|
|
||||||
|
|
||||||
size_t findOrCreateScalarResultIndex( const RigEclipseResultAddress& resVarAddr, bool needsToBeStored );
|
size_t findOrCreateScalarResultIndex( const RigEclipseResultAddress& resVarAddr, bool needsToBeStored );
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user