Janitor : Build AABB search trees before multi threaded loop

The construction of a AABB tree uses OpenMP internally, and will cause crash if started from a OpenMP loop.
This commit is contained in:
Magne Sjaastad 2021-09-30 10:39:19 +02:00
parent 163fc707bd
commit 9bc3036e8a

View File

@ -122,11 +122,17 @@ void RimEnsembleSurface::loadDataAndUpdate()
if ( !sourceSurfaceForStatistics.empty() )
{
cvf::ref<RigSurface> firstSurface = sourceSurfaceForStatistics[0]->surfaceData();
for ( auto& surf : sourceSurfaceForStatistics )
{
// The search tree must be created before the multi threading loop is initiated to avoid crash in
// RigSurfaceResampler::resampleSurface
// NB! Do not use OpenMP on this loop, as the construction of the AABB tree is using OpenMP internally, and
// mixing these causes crash.
// The search tree must be created before the multi threading loop is initiated to avoid crash
firstSurface->ensureIntersectionSearchTreeIsBuilt();
surf->surfaceData()->ensureIntersectionSearchTreeIsBuilt();
}
cvf::ref<RigSurface> firstSurface = sourceSurfaceForStatistics[0]->surfaceData();
auto surfaceCount = static_cast<int>( sourceSurfaceForStatistics.size() );
std::vector<cvf::ref<RigSurface>> sourceSurfaces( surfaceCount );
#pragma omp parallel for