From 1d5b95b5febe356a2040eabb99261c401f92a328 Mon Sep 17 00:00:00 2001
From: mattijs <mattijs>
Date: Thu, 18 Apr 2024 11:50:52 +0100
Subject: [PATCH] BUG: redistributePar: Distributing refinement data. Fixes
 #3137.

- was using blocking (=buffered) comms
- was running out of MPI_COMM_SIZE buffer space
- now using PstreamBuffers to have non-blocing comms
---
 .../polyTopoChange/hexRef8/refinementHistory.C        | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/refinementHistory.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/refinementHistory.C
index 18ac3e6dc2e..7919d228e18 100644
--- a/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/refinementHistory.C
+++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/refinementHistory.C
@@ -1271,6 +1271,9 @@ void Foam::refinementHistory::distribute(const mapDistributePolyMesh& map)
 
     // Create subsetted refinement tree consisting of all parents that
     // move in their whole to other processor.
+
+    PstreamBuffers pBufs(UPstream::commsTypes::nonBlocking);
+
     for (const int proci : Pstream::allProcs())
     {
         //Pout<< "-- Subetting for processor " << proci << endl;
@@ -1364,11 +1367,15 @@ void Foam::refinementHistory::distribute(const mapDistributePolyMesh& map)
 
 
         // Send to neighbours
-        OPstream toNbr(Pstream::commsTypes::blocking, proci);
+        UOPstream toNbr(proci, pBufs);
         toNbr << newSplitCells << newVisibleCells;
     }
 
 
+    // Wait for finish
+    pBufs.finishedSends();
+
+
     // Receive from neighbours and merge
     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
@@ -1382,7 +1389,7 @@ void Foam::refinementHistory::distribute(const mapDistributePolyMesh& map)
 
     for (const int proci : Pstream::allProcs())
     {
-        IPstream fromNbr(Pstream::commsTypes::blocking, proci);
+        UIPstream fromNbr(proci, pBufs);
         List<splitCell8> newSplitCells(fromNbr);
         labelList newVisibleCells(fromNbr);
 
-- 
GitLab