mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Stop ResInsight from crashing when calculating cell volume (#8374)
* Stop ResInsight from crashing when calculating cell volume
This commit is contained in:
parent
985a2c8f30
commit
3bb6642900
@ -25,7 +25,6 @@
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RigActiveCellInfo::RigActiveCellInfo()
|
||||
: m_reservoirActiveCellCount( 0 )
|
||||
, m_reservoirCellResultCount( 0 )
|
||||
, m_activeCellPositionMin( cvf::Vec3d::ZERO )
|
||||
, m_activeCellPositionMax( cvf::Vec3d::ZERO )
|
||||
{
|
||||
@ -47,14 +46,6 @@ size_t RigActiveCellInfo::reservoirCellCount() const
|
||||
return m_cellIndexToResultIndex.size();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
size_t RigActiveCellInfo::reservoirCellResultCount() const
|
||||
{
|
||||
return m_reservoirCellResultCount;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -75,11 +66,6 @@ bool RigActiveCellInfo::isActive( size_t reservoirCellIndex ) const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
size_t RigActiveCellInfo::cellResultIndex( size_t reservoirCellIndex ) const
|
||||
{
|
||||
if ( m_cellIndexToResultIndex.size() == 0 )
|
||||
{
|
||||
return reservoirCellIndex;
|
||||
}
|
||||
|
||||
CVF_TIGHT_ASSERT( reservoirCellIndex < m_cellIndexToResultIndex.size() );
|
||||
|
||||
return m_cellIndexToResultIndex[reservoirCellIndex];
|
||||
@ -94,11 +80,11 @@ void RigActiveCellInfo::setCellResultIndex( size_t reservoirCellIndex, size_t re
|
||||
|
||||
m_cellIndexToResultIndex[reservoirCellIndex] = reservoirCellResultIndex;
|
||||
|
||||
if ( reservoirCellResultIndex >= m_reservoirCellResultCount )
|
||||
{
|
||||
#pragma omp critical
|
||||
m_reservoirCellResultCount = reservoirCellResultIndex + 1;
|
||||
}
|
||||
// if ( reservoirCellResultIndex >= m_reservoirActiveCellCount )
|
||||
// {
|
||||
//#pragma omp critical
|
||||
// m_reservoirActiveCellCount = reservoirCellResultIndex + 1;
|
||||
// }
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -215,14 +201,6 @@ void RigActiveCellInfo::addLgr( size_t cellCount )
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RigActiveCellInfo::isCoarseningActive() const
|
||||
{
|
||||
return m_reservoirCellResultCount != m_reservoirActiveCellCount;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -34,8 +34,6 @@ public:
|
||||
void setReservoirCellCount( size_t reservoirCellCount );
|
||||
size_t reservoirCellCount() const;
|
||||
size_t reservoirActiveCellCount() const;
|
||||
size_t reservoirCellResultCount() const;
|
||||
bool isCoarseningActive() const;
|
||||
|
||||
bool isActive( size_t reservoirCellIndex ) const;
|
||||
size_t cellResultIndex( size_t reservoirCellIndex ) const;
|
||||
@ -75,7 +73,6 @@ private:
|
||||
std::vector<size_t> m_cellIndexToResultIndex;
|
||||
|
||||
size_t m_reservoirActiveCellCount;
|
||||
size_t m_reservoirCellResultCount;
|
||||
|
||||
cvf::Vec3st m_activeCellPositionMin;
|
||||
cvf::Vec3st m_activeCellPositionMax;
|
||||
|
@ -820,7 +820,7 @@ const std::vector<double>*
|
||||
QString resultName,
|
||||
std::vector<double>& activeCellsResultsTempContainer )
|
||||
{
|
||||
size_t resultCellCount = actCellInfo->reservoirCellResultCount();
|
||||
size_t resultCellCount = actCellInfo->reservoirActiveCellCount();
|
||||
size_t reservoirCellCount = actCellInfo->reservoirCellCount();
|
||||
RigEclipseResultAddress resVarAddr( RiaDefines::ResultCatType::STATIC_NATIVE, resultName );
|
||||
|
||||
@ -2897,7 +2897,7 @@ void RigCaseCellResultsData::computeCellVolumes()
|
||||
}
|
||||
std::vector<double>& cellVolumeResults = m_cellScalarResults[cellVolIdx][0];
|
||||
|
||||
size_t cellResultCount = m_activeCellInfo->reservoirCellResultCount();
|
||||
size_t cellResultCount = m_activeCellInfo->reservoirActiveCellCount();
|
||||
cellVolumeResults.resize( cellResultCount, std::numeric_limits<double>::infinity() );
|
||||
|
||||
#pragma omp parallel for
|
||||
@ -2938,7 +2938,7 @@ void RigCaseCellResultsData::computeOilVolumes()
|
||||
false );
|
||||
m_cellScalarResults[oilVolIdx].resize( this->maxTimeStepCount() );
|
||||
|
||||
size_t cellResultCount = m_activeCellInfo->reservoirCellResultCount();
|
||||
size_t cellResultCount = m_activeCellInfo->reservoirActiveCellCount();
|
||||
for ( size_t timeStepIdx = 0; timeStepIdx < this->maxTimeStepCount(); timeStepIdx++ )
|
||||
{
|
||||
const std::vector<double>& soilResults = m_cellScalarResults[soilIdx][timeStepIdx];
|
||||
|
@ -46,7 +46,7 @@ RigNumberOfFloodedPoreVolumesCalculator::RigNumberOfFloodedPoreVolumesCalculator
|
||||
|
||||
RigActiveCellInfo* actCellInfo =
|
||||
caseToApply->eclipseCaseData()->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL );
|
||||
size_t resultCellCount = actCellInfo->reservoirCellResultCount();
|
||||
size_t resultCellCount = actCellInfo->reservoirActiveCellCount();
|
||||
|
||||
size_t timeStepCount =
|
||||
caseToApply->eclipseCaseData()->results( RiaDefines::PorosityModelType::MATRIX_MODEL )->maxTimeStepCount();
|
||||
@ -207,7 +207,7 @@ void RigNumberOfFloodedPoreVolumesCalculator::calculate( RigMainGrid*
|
||||
// size_t totalNumberOfCells = mainGrid->globalCellArray().size();
|
||||
RigActiveCellInfo* actCellInfo =
|
||||
caseToApply->eclipseCaseData()->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL );
|
||||
size_t resultCellCount = actCellInfo->reservoirCellResultCount();
|
||||
size_t resultCellCount = actCellInfo->reservoirActiveCellCount();
|
||||
|
||||
caf::ProgressInfo progress( 2 * daysSinceSimulationStart.size(), "" );
|
||||
|
||||
|
@ -468,9 +468,6 @@ public:
|
||||
socketStream >> m_bytesPerTimeStepToRead;
|
||||
}
|
||||
|
||||
// std::cout << "RiaSetActiveCellProperty: " << propertyName.data() << " timeStepCount " <<
|
||||
// m_timeStepCountToRead << " bytesPerTimeStep " << m_bytesPerTimeStepToRead;
|
||||
|
||||
// Create a list of all the requested timesteps
|
||||
|
||||
m_requestedTimesteps.clear();
|
||||
@ -531,8 +528,6 @@ public:
|
||||
|
||||
bool interpretMore( RiaSocketServer* server, QTcpSocket* currentClient ) override
|
||||
{
|
||||
// std::cout << "RiaSetActiveCellProperty, interpretMore: scalarIndex : " << m_currentScalarIndex;
|
||||
|
||||
if ( m_invalidActiveCellCountDetected ) return true;
|
||||
|
||||
// If nothing should be read, or we already have read everything, do nothing
|
||||
@ -555,9 +550,6 @@ public:
|
||||
|
||||
size_t activeCellCountReservoir = activeCellInfo->reservoirActiveCellCount();
|
||||
size_t totalCellCount = activeCellInfo->reservoirCellCount();
|
||||
size_t reservoirCellResultCount = activeCellInfo->reservoirCellResultCount();
|
||||
|
||||
bool isCoarseningActive = reservoirCellResultCount != activeCellCountReservoir;
|
||||
|
||||
if ( cellCountFromOctave != activeCellCountReservoir )
|
||||
{
|
||||
@ -602,18 +594,12 @@ public:
|
||||
for ( size_t tIdx = 0; tIdx < m_timeStepCountToRead; ++tIdx )
|
||||
{
|
||||
size_t tsId = m_requestedTimesteps[tIdx];
|
||||
m_scalarResultsToAdd->at( tsId ).resize( reservoirCellResultCount, HUGE_VAL );
|
||||
m_scalarResultsToAdd->at( tsId ).resize( activeCellCountReservoir, HUGE_VAL );
|
||||
}
|
||||
|
||||
std::vector<double> readBuffer;
|
||||
double* internalMatrixData = nullptr;
|
||||
|
||||
if ( isCoarseningActive )
|
||||
{
|
||||
readBuffer.resize( cellCountFromOctave, HUGE_VAL );
|
||||
internalMatrixData = readBuffer.data();
|
||||
}
|
||||
|
||||
QDataStream socketStream( currentClient );
|
||||
socketStream.setVersion( riOctavePlugin::qtDataStreamVersion );
|
||||
|
||||
@ -622,11 +608,7 @@ public:
|
||||
while ( ( currentClient->bytesAvailable() >= (int)m_bytesPerTimeStepToRead ) &&
|
||||
( m_currentTimeStepNumberToRead < m_timeStepCountToRead ) )
|
||||
{
|
||||
if ( !isCoarseningActive )
|
||||
{
|
||||
internalMatrixData =
|
||||
m_scalarResultsToAdd->at( m_requestedTimesteps[m_currentTimeStepNumberToRead] ).data();
|
||||
}
|
||||
internalMatrixData = m_scalarResultsToAdd->at( m_requestedTimesteps[m_currentTimeStepNumberToRead] ).data();
|
||||
|
||||
QStringList errorMessages;
|
||||
if ( !RiaSocketDataTransfer::readBlockDataFromSocket( currentClient,
|
||||
@ -643,22 +625,6 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
// Map data from active to result index based container ( Coarsening is active)
|
||||
if ( isCoarseningActive )
|
||||
{
|
||||
size_t acIdx = 0;
|
||||
for ( size_t gcIdx = 0; gcIdx < totalCellCount; ++gcIdx )
|
||||
{
|
||||
if ( activeCellInfo->isActive( gcIdx ) )
|
||||
{
|
||||
m_scalarResultsToAdd->at(
|
||||
m_requestedTimesteps[m_currentTimeStepNumberToRead] )[activeCellInfo->cellResultIndex( gcIdx )] =
|
||||
readBuffer[acIdx];
|
||||
++acIdx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
++m_currentTimeStepNumberToRead;
|
||||
}
|
||||
|
||||
|
@ -251,7 +251,7 @@ protected:
|
||||
m_resultValues = caseData->results( porosityModel )->modifiableCellScalarResult( resVarAddr, timeStepIndex );
|
||||
if ( m_resultValues->empty() )
|
||||
{
|
||||
m_resultValues->resize( activeCellInfo->reservoirCellResultCount() );
|
||||
m_resultValues->resize( activeCellInfo->reservoirActiveCellCount() );
|
||||
}
|
||||
m_cellCount = activeCellInfo->reservoirActiveCellCount();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user