From 1b2db894bfcdcd0a72b8ed2548fc4dd4b412462b Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 27 Jan 2020 08:57:32 +0100 Subject: [PATCH] #5405 Faults : Use openMP when computing NNCs --- .../RigCellFaceGeometryTools.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.cpp b/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.cpp index 80538e72e9..6896e43b8d 100644 --- a/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCellFaceGeometryTools.cpp @@ -183,8 +183,12 @@ std::vector RigCellFaceGeometryTools::computeOtherNncs( const Rig const RigFault* fault = faults.at( faultIdx ); const std::vector& faultFaces = fault->faultFaces(); - for ( const auto& f : faultFaces ) + +#pragma omp parallel for + for ( int faceIdx = 0; faceIdx < static_cast( faultFaces.size() ); faceIdx++ ) { + const RigFault::FaultFace& f = faultFaces[faceIdx]; + size_t sourceReservoirCellIndex = f.m_nativeReservoirCellIndex; cvf::StructGridInterface::FaceType sourceCellFace = f.m_nativeFace; @@ -300,8 +304,6 @@ std::vector RigCellFaceGeometryTools::computeOtherNncs( const Rig if ( foundOverlap ) { - otherCellPairs.emplace( candidate ); - RigConnection conn; conn.m_c1GlobIdx = sourceReservoirCellIndex; conn.m_c1Face = sourceCellFace; @@ -309,7 +311,11 @@ std::vector RigCellFaceGeometryTools::computeOtherNncs( const Rig conn.m_polygon = RigCellFaceGeometryTools::extractPolygon( mainGridNodes, polygon, intersections ); - otherConnections.emplace_back( conn ); +#pragma omp critical( critical_section_nnc_computations ) + { + otherCellPairs.emplace( candidate ); + otherConnections.emplace_back( conn ); + } } } }