From 74a66846c58b1259ee8f96a8d8951dee6f7a29a0 Mon Sep 17 00:00:00 2001 From: Timo Koch Date: Mon, 2 May 2022 19:05:18 +0200 Subject: [PATCH 1/2] [doc][gridgeometry] Fix typos in code doc --- dumux/discretization/basegridgeometry.hh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dumux/discretization/basegridgeometry.hh b/dumux/discretization/basegridgeometry.hh index 7ffc3dfb9d..9ebb8ef7a0 100644 --- a/dumux/discretization/basegridgeometry.hh +++ b/dumux/discretization/basegridgeometry.hh @@ -73,7 +73,7 @@ public: /*! * \ingroup Discretization - * \brief Constructor computes the bouding box of the entire domain, for e.g. setting boundary conditions + * \brief Constructor computes the bounding box of the entire domain, for e.g. setting boundary conditions * \param gridView the grid view on which to construct the grid geometry */ BaseGridGeometry(const GridView& gridView) @@ -222,7 +222,7 @@ private: return VertexMapper(gridView); } - //! Compute the bouding box of the entire domain, for e.g. setting boundary conditions + //! Compute the bounding box of the entire domain, for e.g. setting boundary conditions void computeGlobalBoundingBox_() { // calculate the bounding box of the local partition of the grid view @@ -261,7 +261,7 @@ private: else Deprecated::update(vertexMapper_); - //! Compute the bouding box of the entire domain, for e.g. setting boundary conditions + //! Compute the bounding box of the entire domain, for e.g. setting boundary conditions computeGlobalBoundingBox_(); //! reset bounding box tree and the element map until requested the next time @@ -276,7 +276,7 @@ private: ElementMapper elementMapper_; VertexMapper vertexMapper_; - //! the bounding box tree of the grid view for effecient element intersections + //! the bounding box tree of the grid view for efficient element intersections mutable std::unique_ptr boundingBoxTree_; //! a map from element index to elements (needed in the bounding box tree and for assembling cell-centered discretization) -- GitLab From a63f1f4039809f661fd59a1c209260741985ddc1 Mon Sep 17 00:00:00 2001 From: Timo Koch Date: Mon, 2 May 2022 19:05:58 +0200 Subject: [PATCH 2/2] [bugfix][gridgeometry] Make lazy initializer of elementMap/bBoxTree thread-safe --- dumux/discretization/basegridgeometry.hh | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/dumux/discretization/basegridgeometry.hh b/dumux/discretization/basegridgeometry.hh index 9ebb8ef7a0..c14853150c 100644 --- a/dumux/discretization/basegridgeometry.hh +++ b/dumux/discretization/basegridgeometry.hh @@ -26,6 +26,7 @@ #include #include +#include #include @@ -149,11 +150,14 @@ public: */ const BoundingBoxTree& boundingBoxTree() const { - if(!boundingBoxTree_) + if (!boundingBoxTree_) { - elementMap(); // make sure the element map is built - boundingBoxTree_ = std::make_unique - ( std::make_shared(gridView_, elementMapper(), elementMap_) ); + std::scoped_lock{ boundingBoxTreeMutex_ }; + if (!boundingBoxTree_) + elementMap(); // make sure the element map is built + boundingBoxTree_ = std::make_unique( + std::make_shared(gridView_, elementMapper(), elementMap_) + ); } return *boundingBoxTree_; @@ -164,8 +168,12 @@ public: */ const ElementMap& elementMap() const { - if(!elementMap_) - elementMap_ = std::make_shared(gridView_.grid(), elementMapper_); + if (!elementMap_) + { + std::scoped_lock{ elementMapMutex_ }; + if (!elementMap_) + elementMap_ = std::make_shared(gridView_.grid(), elementMapper_); + } return *elementMap_; } @@ -278,9 +286,11 @@ private: //! the bounding box tree of the grid view for efficient element intersections mutable std::unique_ptr boundingBoxTree_; + mutable std::mutex boundingBoxTreeMutex_; //! a map from element index to elements (needed in the bounding box tree and for assembling cell-centered discretization) mutable std::shared_ptr elementMap_; + mutable std::mutex elementMapMutex_; //! the bounding box of the whole domain GlobalCoordinate bBoxMin_; -- GitLab