From 542645a4dacf24b7252e20f97dc73ae400c6842f Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Mon, 13 Mar 2017 19:20:05 +0000
Subject: [PATCH] workaround ANN (not thread safe?) - should move to flann

---
 Mesh/Field.cpp | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/Mesh/Field.cpp b/Mesh/Field.cpp
index 915c42c50b..ac8f5916b8 100644
--- a/Mesh/Field.cpp
+++ b/Mesh/Field.cpp
@@ -1921,6 +1921,9 @@ class AttractorAnisoCurveField : public Field {
     if(update_needed)
       update();
     double xyz[3] = { x, y, z };
+#if defined(_OPENMP)
+#pragma omp critical
+#endif
     kdtree->annkSearch(xyz, 1, index, dist);
     double d = sqrt(dist[0]);
     double lTg = d < dMin ? lMinTangent : d > dMax ? lMaxTangent :
@@ -1938,6 +1941,9 @@ class AttractorAnisoCurveField : public Field {
     if(update_needed)
       update();
     double xyz[3] = { X, Y, Z };
+#if defined(_OPENMP)
+#pragma omp critical
+#endif
     kdtree->annkSearch(xyz, 1, index, dist);
     double d = sqrt(dist[0]);
     return std::max(d, 0.05);
@@ -2168,6 +2174,9 @@ class AttractorField : public Field
 
     double xyz[3];
     getCoord(X, Y, Z, xyz[0], xyz[1], xyz[2], ge);
+#if defined(_OPENMP)
+#pragma omp critical
+#endif
     kdtree->annkSearch(xyz, 1, index, dist);
     return sqrt(dist[0]);
   }
-- 
GitLab