From 83e471245946dd83387340b887860ded949b4583 Mon Sep 17 00:00:00 2001
From: acrovato <170-acrovato@users.noreply.gitlab.uliege.be>
Date: Sat, 21 Mar 2020 21:42:01 +0100
Subject: [PATCH] fix for tbb

---
 flow/src/wNewton.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/flow/src/wNewton.cpp b/flow/src/wNewton.cpp
index 0408374d..52eb88df 100644
--- a/flow/src/wNewton.cpp
+++ b/flow/src/wNewton.cpp
@@ -348,13 +348,13 @@ void Newton::buildJac(Eigen::SparseMatrix<double, Eigen::RowMajor> &J)
             // first grab upper row values...
             std::vector<Eigen::Triplet<double>> tUp;
             tUp.reserve(pbl->msh->nodes.size() / 10);
+            tbb::spin_mutex::scoped_lock lock(mutex);
             for (Eigen::SparseMatrix<double, Eigen::RowMajor>::InnerIterator it(J, idxUp); it; ++it)
             {
                 tUp.push_back(Eigen::Triplet<double>(it.row(), it.col(), it.value()));
                 it.valueRef() = 0.;
             }
             // ...then add them to lower row values
-            tbb::spin_mutex::scoped_lock lock(mutex);
             for (auto t : tUp)
                 J.coeffRef(idxLw, t.col()) += t.value();
         });
-- 
GitLab