#9887 Roff: fix freeze due combining omp and progress info.

This commit is contained in:
Kristian Bendiksen 2023-03-01 19:40:17 +01:00 committed by Magne Sjaastad
parent d2f435c00a
commit 8a2d9ec83e

View File

@ -182,63 +182,37 @@ bool RifRoffFileTools::openGridFile( const QString& fileName, RigEclipseCaseData
size_t numActiveCells = computeActiveCellMatrixIndex( activeCells );
// Loop over cells and fill them with data
#pragma omp parallel
{
int cellCountPerThread = cellCount;
#ifdef USE_OPENMP
cellCountPerThread = std::max( 1, cellCount / omp_get_num_threads() );
#endif
int computedThreadCellCount = 0;
int cellsPrProgressTick = std::max( 1, cellCountPerThread / progTicks );
int maxProgressCell = cellsPrProgressTick * progTicks;
#pragma omp for
for ( int gridLocalCellIndex = 0; gridLocalCellIndex < cellCount; ++gridLocalCellIndex )
for ( int gridLocalCellIndex = 0; gridLocalCellIndex < cellCount; ++gridLocalCellIndex )
{
RigCell& cell = mainGrid->globalCellArray()[cellStartIndex + gridLocalCellIndex];
cell.setGridLocalCellIndex( gridLocalCellIndex );
// Active cell index
int matrixActiveIndex = activeCells[gridLocalCellIndex];
if ( matrixActiveIndex != -1 )
{
RigCell& cell = mainGrid->globalCellArray()[cellStartIndex + gridLocalCellIndex];
cell.setGridLocalCellIndex( gridLocalCellIndex );
// Active cell index
int matrixActiveIndex = activeCells[gridLocalCellIndex];
if ( matrixActiveIndex != -1 )
{
activeCellInfo->setCellResultIndex( cellStartIndex + gridLocalCellIndex, matrixActiveIndex );
}
cell.setParentCellIndex( cvf::UNDEFINED_SIZE_T );
// Corner coordinates
for ( int cIdx = 0; cIdx < 8; ++cIdx )
{
double* point = mainGrid->nodes()[nodeStartIndex + (size_t)gridLocalCellIndex * 8 + cellMappingECLRi[cIdx]].ptr();
auto corner = getCorner( *mainGrid, cornerLines, zCorners, gridLocalCellIndex, cIdx, offset, scale );
point[0] = corner.x();
point[1] = corner.y();
point[2] = corner.z();
cell.cornerIndices()[cIdx] = nodeStartIndex + (size_t)gridLocalCellIndex * 8 + cIdx;
}
// Mark inactive long pyramid looking cells as invalid
cell.setInvalid( cell.isLongPyramidCell() );
#ifdef USE_OPENMP
if ( omp_get_thread_num() == 0 )
{
computedThreadCellCount++;
if ( computedThreadCellCount <= maxProgressCell && computedThreadCellCount % cellsPrProgressTick == 0 )
progInfo.incrementProgress();
}
#else
computedThreadCellCount++;
if ( computedThreadCellCount <= maxProgressCell && computedThreadCellCount % cellsPrProgressTick == 0 )
progInfo.incrementProgress();
#endif
activeCellInfo->setCellResultIndex( cellStartIndex + gridLocalCellIndex, matrixActiveIndex );
}
cell.setParentCellIndex( cvf::UNDEFINED_SIZE_T );
// Corner coordinates
for ( int cIdx = 0; cIdx < 8; ++cIdx )
{
double* point = mainGrid->nodes()[nodeStartIndex + (size_t)gridLocalCellIndex * 8 + cellMappingECLRi[cIdx]].ptr();
auto corner = getCorner( *mainGrid, cornerLines, zCorners, gridLocalCellIndex, cIdx, offset, scale );
point[0] = corner.x();
point[1] = corner.y();
point[2] = corner.z();
cell.cornerIndices()[cIdx] = nodeStartIndex + (size_t)gridLocalCellIndex * 8 + cIdx;
}
// Mark inactive long pyramid looking cells as invalid
cell.setInvalid( cell.isLongPyramidCell() );
}
activeCellInfo->setGridActiveCellCounts( 0, numActiveCells );