From 77eccfd869a42f8bc65f56b2a14940581e757a79 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Thu, 11 Aug 2022 08:32:42 +0200 Subject: [PATCH] fixed: avoid vector in fvbasediscretization writes to vector is not thread safe --- opm/models/discretization/common/fvbasediscretization.hh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/opm/models/discretization/common/fvbasediscretization.hh b/opm/models/discretization/common/fvbasediscretization.hh index 2a097564c..eee4115a0 100644 --- a/opm/models/discretization/common/fvbasediscretization.hh +++ b/opm/models/discretization/common/fvbasediscretization.hh @@ -730,7 +730,7 @@ public: return; intensiveQuantityCache_[timeIdx][globalIdx] = intQuants; - intensiveQuantityCacheUpToDate_[timeIdx][globalIdx] = true; + intensiveQuantityCacheUpToDate_[timeIdx][globalIdx] = 1; } /*! @@ -747,7 +747,7 @@ public: if (!storeIntensiveQuantities()) return; - intensiveQuantityCacheUpToDate_[timeIdx][globalIdx] = newValue; + intensiveQuantityCacheUpToDate_[timeIdx][globalIdx] = newValue ? 1 : 0; } /*! @@ -760,7 +760,7 @@ public: if (storeIntensiveQuantities()) { std::fill(intensiveQuantityCacheUpToDate_[timeIdx].begin(), intensiveQuantityCacheUpToDate_[timeIdx].end(), - /*value=*/false); + /*value=*/0); } } @@ -1960,7 +1960,8 @@ protected: // cur is the current iterative solution, prev the converged // solution of the previous time step mutable IntensiveQuantitiesVector intensiveQuantityCache_[historySize]; - mutable std::vector intensiveQuantityCacheUpToDate_[historySize]; + // while these are logically bools, concurrent writes to vector are not thread safe. + mutable std::vector intensiveQuantityCacheUpToDate_[historySize]; DiscreteFunctionSpace space_; mutable std::array< std::unique_ptr< DiscreteFunction >, historySize > solution_;