mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Revert OpenMP for detection of faults
The use of OpenMP is not stable, and produce wrong geometry in some cases.
This commit is contained in:
parent
e815a02758
commit
f731153c22
@ -467,39 +467,18 @@ void RigMainGrid::calculateFaults( const RigActiveCellInfo* activeCellInfo )
|
|||||||
|
|
||||||
const std::vector<cvf::Vec3d>& vxs = m_mainGrid->nodes();
|
const std::vector<cvf::Vec3d>& vxs = m_mainGrid->nodes();
|
||||||
|
|
||||||
int numberOfThreads = RiaOpenMPTools::availableThreadCount();
|
|
||||||
|
|
||||||
std::vector<std::vector<RigFault::FaultFace>> threadFaultFaces( numberOfThreads );
|
|
||||||
std::vector<std::vector<RigFault::FaultFace>> threadInactiveFaultFaces( numberOfThreads );
|
|
||||||
|
|
||||||
#pragma omp parallel
|
|
||||||
{
|
|
||||||
int myThread = RiaOpenMPTools::currentThreadIndex();
|
|
||||||
|
|
||||||
// NB! We are inside a parallel section, do not use "parallel for" here
|
|
||||||
#pragma omp for
|
|
||||||
for ( int gcIdx = 0; gcIdx < static_cast<int>( m_cells.size() ); ++gcIdx )
|
|
||||||
{
|
|
||||||
addUnNamedFaultFaces( gcIdx,
|
|
||||||
activeCellInfo,
|
|
||||||
vxs,
|
|
||||||
unNamedFaultIdx,
|
|
||||||
unNamedFaultWithInactiveIdx,
|
|
||||||
threadFaultFaces[myThread],
|
|
||||||
threadInactiveFaultFaces[myThread],
|
|
||||||
m_faultsPrCellAcc.p() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<RigFault::FaultFace>& unNamedFaultFaces = unNamedFault->faultFaces();
|
std::vector<RigFault::FaultFace>& unNamedFaultFaces = unNamedFault->faultFaces();
|
||||||
std::vector<RigFault::FaultFace>& unNamedFaultFacesInactive = unNamedFaultWithInactive->faultFaces();
|
std::vector<RigFault::FaultFace>& unNamedFaultFacesInactive = unNamedFaultWithInactive->faultFaces();
|
||||||
|
for ( int gcIdx = 0; gcIdx < static_cast<int>( m_cells.size() ); ++gcIdx )
|
||||||
for ( int i = 0; i < numberOfThreads; i++ )
|
|
||||||
{
|
{
|
||||||
unNamedFaultFaces.insert( unNamedFaultFaces.end(), threadFaultFaces[i].begin(), threadFaultFaces[i].end() );
|
addUnNamedFaultFaces( gcIdx,
|
||||||
unNamedFaultFacesInactive.insert( unNamedFaultFacesInactive.end(),
|
activeCellInfo,
|
||||||
threadInactiveFaultFaces[i].begin(),
|
vxs,
|
||||||
threadInactiveFaultFaces[i].end() );
|
unNamedFaultIdx,
|
||||||
|
unNamedFaultWithInactiveIdx,
|
||||||
|
unNamedFaultFaces,
|
||||||
|
unNamedFaultFacesInactive,
|
||||||
|
m_faultsPrCellAcc.p() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -592,16 +571,8 @@ void RigMainGrid::addUnNamedFaultFaces( int gcIdx,
|
|||||||
int faultIdx = unNamedFaultIdx;
|
int faultIdx = unNamedFaultIdx;
|
||||||
if ( !( isCellActive && isNeighborCellActive ) ) faultIdx = unNamedFaultWithInactiveIdx;
|
if ( !( isCellActive && isNeighborCellActive ) ) faultIdx = unNamedFaultWithInactiveIdx;
|
||||||
|
|
||||||
#pragma omp critical( faultsPrCellAcc_modification )
|
faultsPrCellAcc->setFaultIdx( gcIdx, face, faultIdx );
|
||||||
{
|
faultsPrCellAcc->setFaultIdx( neighborReservoirCellIdx, StructGridInterface::oppositeFace( face ), faultIdx );
|
||||||
// Best practice is to avoid critical sections. The number of cells related to a fault is usually very
|
|
||||||
// small compared to the total number of cells, so the performance of this function should be good. The
|
|
||||||
// main computation is related to the 'pointDistance' functions above. The refactoring of this structure
|
|
||||||
// to avoid critical section is considered too much compared to the gain.
|
|
||||||
|
|
||||||
faultsPrCellAcc->setFaultIdx( gcIdx, face, faultIdx );
|
|
||||||
faultsPrCellAcc->setFaultIdx( neighborReservoirCellIdx, StructGridInterface::oppositeFace( face ), faultIdx );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add as fault face only if the grid index is less than the neighbors
|
// Add as fault face only if the grid index is less than the neighbors
|
||||||
|
|
||||||
@ -617,6 +588,10 @@ void RigMainGrid::addUnNamedFaultFaces( int gcIdx,
|
|||||||
unNamedFaultFacesInactive.push_back( ff );
|
unNamedFaultFacesInactive.push_back( ff );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CVF_FAIL_MSG( "Found fault with global neighbor index less than the native index. " );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user