diff --git a/applications/utilities/mesh/manipulation/createPatch/createPatch.C b/applications/utilities/mesh/manipulation/createPatch/createPatch.C index d27d6df829..545fe26f84 100644 --- a/applications/utilities/mesh/manipulation/createPatch/createPatch.C +++ b/applications/utilities/mesh/manipulation/createPatch/createPatch.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2016-2022 OpenCFD Ltd. + Copyright (C) 2016-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -568,12 +568,8 @@ void syncPoints } } - OPstream toNbr - ( - Pstream::commsTypes::blocking, - procPatch.neighbProcNo() - ); - toNbr << patchInfo; + // buffered send + OPstream::bsend(patchInfo, procPatch.neighbProcNo()); } } @@ -587,17 +583,12 @@ void syncPoints if (pp.nPoints() && !procPatch.owner()) { - pointField nbrPatchInfo(procPatch.nPoints()); - { - // We do not know the number of points on the other side - // so cannot use UIPstream::read - IPstream fromNbr - ( - Pstream::commsTypes::blocking, - procPatch.neighbProcNo() - ); - fromNbr >> nbrPatchInfo; - } + pointField nbrPatchInfo; + + // We do not know the number of points on the other side + // so cannot use UIPstream::read + IPstream::recv(nbrPatchInfo, procPatch.neighbProcNo()); + // Null any value which is not on neighbouring processor nbrPatchInfo.setSize(procPatch.nPoints(), nullValue); diff --git a/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C b/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C index d2cc137639..eb84cc3ff6 100644 --- a/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C +++ b/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2015-2023 OpenCFD Ltd. + Copyright (C) 2015-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -379,11 +379,10 @@ void getInterfaceSizes if (Pstream::master()) { // Receive and add to my sizes - for (const int slave : Pstream::subProcs()) + for (const int proci : UPstream::subProcs()) { - IPstream fromSlave(Pstream::commsTypes::blocking, slave); - - EdgeMap> slaveSizes(fromSlave); + EdgeMap> slaveSizes; + IPstream::recv(slaveSizes, proci); forAllConstIters(slaveSizes, slaveIter) { @@ -421,15 +420,8 @@ void getInterfaceSizes } else { - // Send to master - { - OPstream toMaster - ( - Pstream::commsTypes::blocking, - Pstream::masterNo() - ); - toMaster << regionsToSize; - } + // buffered send to master + OPstream::bsend(regionsToSize, UPstream::masterNo()); } } diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/PstreamCombineGather.C b/src/OpenFOAM/db/IOstreams/Pstreams/PstreamCombineGather.C index 6b280517e0..ac47fdef69 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/PstreamCombineGather.C +++ b/src/OpenFOAM/db/IOstreams/Pstreams/PstreamCombineGather.C @@ -36,8 +36,8 @@ Description \*---------------------------------------------------------------------------*/ -#include "OPstream.H" #include "IPstream.H" +#include "OPstream.H" #include "IOstreams.H" #include "contiguous.H" @@ -129,15 +129,7 @@ void Foam::Pstream::combineGather } else { - OPstream toAbove - ( - UPstream::commsTypes::scheduled, - myComm.above(), - 0, // bufsize - tag, - comm - ); - toAbove << value; + OPstream::send(value, myComm.above(), tag, comm); } } } @@ -255,15 +247,7 @@ void Foam::Pstream::listCombineGather } else { - OPstream toAbove - ( - UPstream::commsTypes::scheduled, - myComm.above(), - 0, // bufsize - tag, - comm - ); - toAbove << values; + OPstream::send(values, myComm.above(), tag, comm); } } } @@ -357,15 +341,7 @@ void Foam::Pstream::mapCombineGather << " data:" << values << endl; } - OPstream toAbove - ( - UPstream::commsTypes::scheduled, - myComm.above(), - 0, // bufsize - tag, - comm - ); - toAbove << values; + OPstream::send(values, myComm.above(), tag, comm); } } } diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/PstreamGather.C b/src/OpenFOAM/db/IOstreams/Pstreams/PstreamGather.C index 920a9a2216..ce2a1b34ae 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/PstreamGather.C +++ b/src/OpenFOAM/db/IOstreams/Pstreams/PstreamGather.C @@ -32,8 +32,8 @@ Description \*---------------------------------------------------------------------------*/ -#include "OPstream.H" #include "IPstream.H" +#include "OPstream.H" #include "contiguous.H" // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // @@ -73,15 +73,7 @@ void Foam::Pstream::gather } else { - IPstream fromBelow - ( - UPstream::commsTypes::scheduled, - belowID, - 0, // bufsize - tag, - comm - ); - fromBelow >> received; + IPstream::recv(received, belowID, tag, comm); } value = bop(value, received); @@ -104,15 +96,7 @@ void Foam::Pstream::gather } else { - OPstream toAbove - ( - UPstream::commsTypes::scheduled, - myComm.above(), - 0, // bufsize - tag, - comm - ); - toAbove << value; + OPstream::send(value, myComm.above(), tag, comm); } } } @@ -166,28 +150,12 @@ Foam::List Foam::Pstream::listGatherValues for (int proci = 1; proci < numProc; ++proci) { - IPstream fromProc - ( - UPstream::commsTypes::scheduled, - proci, - 0, // bufsize - tag, - comm - ); - fromProc >> allValues[proci]; + IPstream::recv(allValues[proci], proci, tag, comm); } } else if (UPstream::is_rank(comm)) { - OPstream toProc - ( - UPstream::commsTypes::scheduled, - UPstream::masterNo(), - 0, // bufsize - tag, - comm - ); - toProc << localValue; + OPstream::send(localValue, UPstream::masterNo(), tag, comm); } } } @@ -269,15 +237,7 @@ T Foam::Pstream::listScatterValues } else if (UPstream::is_rank(comm)) { - IPstream fromProc - ( - UPstream::commsTypes::scheduled, - UPstream::masterNo(), - 0, // bufsize - tag, - comm - ); - fromProc >> localValue; + IPstream::recv(localValue, UPstream::masterNo(), tag, comm); } } } diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/PstreamGatherList.C b/src/OpenFOAM/db/IOstreams/Pstreams/PstreamGatherList.C index 74af324b34..e3705feed5 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/PstreamGatherList.C +++ b/src/OpenFOAM/db/IOstreams/Pstreams/PstreamGatherList.C @@ -99,7 +99,7 @@ void Foam::Pstream::gatherList ( UPstream::commsTypes::scheduled, belowID, - 0, + 0, // bufsize tag, comm ); @@ -167,7 +167,7 @@ void Foam::Pstream::gatherList ( UPstream::commsTypes::scheduled, myComm.above(), - 0, + 0, // bufsize tag, comm ); @@ -248,7 +248,7 @@ void Foam::Pstream::scatterList ( UPstream::commsTypes::scheduled, myComm.above(), - 0, + 0, // bufsize tag, comm ); @@ -298,7 +298,7 @@ void Foam::Pstream::scatterList ( UPstream::commsTypes::scheduled, belowID, - 0, + 0, // bufsize tag, comm ); diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.C b/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.C index 5c96b9a380..bdf79dd6cd 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.C +++ b/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.C @@ -50,10 +50,9 @@ const Foam::Enum > Foam::UPstream::commsTypeNames ({ - { commsTypes::blocking, "blocking" }, + { commsTypes::blocking, "blocking" }, // "buffered" { commsTypes::scheduled, "scheduled" }, - // { commsTypes::nonBlocking, "non-blocking" }, - { commsTypes::nonBlocking, "nonBlocking" }, + { commsTypes::nonBlocking, "nonBlocking" }, // "immediate" }); diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.H b/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.H index de61d0e46a..f4ebe300a3 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.H +++ b/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.H @@ -70,9 +70,9 @@ public: //- Communications types enum class commsTypes : char { - blocking, //!< "blocking" : (MPI_Bsend, MPI_Recv) - scheduled, //!< "scheduled" : (MPI_Send, MPI_Recv) - nonBlocking //!< "nonBlocking" : (MPI_Isend, MPI_Irecv) + blocking, //!< "blocking" (buffered) : (MPI_Bsend, MPI_Recv) + scheduled, //!< "scheduled" (MPI standard) : (MPI_Send, MPI_Recv) + nonBlocking //!< "nonBlocking" (immediate) : (MPI_Isend, MPI_Irecv) }; //- Enumerated names for the communication types diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBase.C b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBase.C index 42905a08d1..87d8da0913 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBase.C +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBase.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2015-2017 OpenFOAM Foundation - Copyright (C) 2015-2023 OpenCFD Ltd. + Copyright (C) 2015-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -227,15 +227,8 @@ Foam::List Foam::mapDistributeBase::schedule // Receive and merge for (const int proci : UPstream::subProcs(comm)) { - IPstream fromProc - ( - UPstream::commsTypes::scheduled, - proci, - 0, - tag, - comm - ); - List nbrData(fromProc); + List nbrData; + IPstream::recv(nbrData, proci, tag, comm); for (const labelPair& connection : nbrData) { @@ -247,15 +240,7 @@ Foam::List Foam::mapDistributeBase::schedule { if (UPstream::parRun()) { - OPstream toMaster - ( - UPstream::commsTypes::scheduled, - UPstream::masterNo(), - 0, - tag, - comm - ); - toMaster << allComms; + OPstream::send(allComms, UPstream::masterNo(), tag, comm); } } diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBaseTemplates.C b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBaseTemplates.C index a7279cfd24..a14b4cc2b1 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBaseTemplates.C +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBaseTemplates.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2015-2017 OpenFOAM Foundation - Copyright (C) 2015-2023 OpenCFD Ltd. + Copyright (C) 2015-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -503,20 +503,13 @@ void Foam::mapDistributeBase::distribute if (proci != myRank && map.size()) { - OPstream os - ( - UPstream::commsTypes::blocking, - proci, - 0, - tag, - comm - ); List subField ( accessAndFlip(field, map, subHasFlip, negOp) ); - os << subField; + // buffered send + OPstream::bsend(subField, proci, tag, comm); } } @@ -552,15 +545,8 @@ void Foam::mapDistributeBase::distribute if (proci != myRank && map.size()) { - IPstream is - ( - UPstream::commsTypes::blocking, - proci, - 0, - tag, - comm - ); - List subField(is); + List subField; + IPstream::recv(subField, proci, tag, comm); checkReceivedSize(proci, map.size(), subField.size()); @@ -620,15 +606,6 @@ void Foam::mapDistributeBase::distribute const label nbrProc = twoProcs.second(); { - OPstream os - ( - UPstream::commsTypes::scheduled, - nbrProc, - 0, - tag, - comm - ); - const labelList& map = subMap[nbrProc]; List subField @@ -636,18 +613,12 @@ void Foam::mapDistributeBase::distribute accessAndFlip(field, map, subHasFlip, negOp) ); - os << subField; + OPstream::send(subField, nbrProc, tag, comm); } { - IPstream is - ( - UPstream::commsTypes::scheduled, - nbrProc, - 0, - tag, - comm - ); - List subField(is); + List subField; + IPstream::recv(subField, nbrProc, tag, comm); + const labelList& map = constructMap[nbrProc]; checkReceivedSize(nbrProc, map.size(), subField.size()); @@ -669,15 +640,9 @@ void Foam::mapDistributeBase::distribute const label nbrProc = twoProcs.first(); { - IPstream is - ( - UPstream::commsTypes::scheduled, - nbrProc, - 0, - tag, - comm - ); - List subField(is); + List subField; + IPstream::recv(subField, nbrProc, tag, comm); + const labelList& map = constructMap[nbrProc]; checkReceivedSize(nbrProc, map.size(), subField.size()); @@ -693,15 +658,6 @@ void Foam::mapDistributeBase::distribute ); } { - OPstream os - ( - UPstream::commsTypes::scheduled, - nbrProc, - 0, - tag, - comm - ); - const labelList& map = subMap[nbrProc]; List subField @@ -709,7 +665,7 @@ void Foam::mapDistributeBase::distribute accessAndFlip(field, map, subHasFlip, negOp) ); - os << subField; + OPstream::send(subField, nbrProc, tag, comm); } } } @@ -730,13 +686,12 @@ void Foam::mapDistributeBase::distribute if (proci != myRank && map.size()) { - UOPstream os(proci, pBufs); - List subField ( accessAndFlip(field, map, subHasFlip, negOp) ); + UOPstream os(proci, pBufs); os << subField; } } @@ -992,21 +947,13 @@ void Foam::mapDistributeBase::distribute if (proci != myRank && map.size()) { - OPstream os - ( - UPstream::commsTypes::blocking, - proci, - 0, - tag, - comm - ); - List subField ( accessAndFlip(field, map, subHasFlip, negOp) ); - os << subField; + // buffered send + OPstream::bsend(subField, proci, tag, comm); } } @@ -1041,15 +988,8 @@ void Foam::mapDistributeBase::distribute if (proci != myRank && map.size()) { - IPstream is - ( - UPstream::commsTypes::blocking, - proci, - 0, - tag, - comm - ); - List subField(is); + List subField; + IPstream::recv(subField, proci, tag, comm); checkReceivedSize(proci, map.size(), subField.size()); @@ -1107,33 +1047,17 @@ void Foam::mapDistributeBase::distribute const label nbrProc = twoProcs.second(); { - OPstream os - ( - UPstream::commsTypes::scheduled, - nbrProc, - 0, - tag, - comm - ); - const labelList& map = subMap[nbrProc]; List subField ( accessAndFlip(field, map, subHasFlip, negOp) ); - os << subField; + OPstream::send(subField, nbrProc, tag, comm); } { - IPstream is - ( - UPstream::commsTypes::scheduled, - nbrProc, - 0, - tag, - comm - ); - List subField(is); + List subField; + IPstream::recv(subField, nbrProc, tag, comm); const labelList& map = constructMap[nbrProc]; @@ -1156,15 +1080,8 @@ void Foam::mapDistributeBase::distribute const label nbrProc = twoProcs.first(); { - IPstream is - ( - UPstream::commsTypes::scheduled, - nbrProc, - 0, - tag, - comm - ); - List subField(is); + List subField; + IPstream::recv(subField, nbrProc, tag, comm); const labelList& map = constructMap[nbrProc]; @@ -1181,22 +1098,13 @@ void Foam::mapDistributeBase::distribute ); } { - OPstream os - ( - UPstream::commsTypes::scheduled, - nbrProc, - 0, - tag, - comm - ); - const labelList& map = subMap[nbrProc]; List subField ( accessAndFlip(field, map, subHasFlip, negOp) ); - os << subField; + OPstream::send(subField, nbrProc, tag, comm); } } } @@ -1217,13 +1125,12 @@ void Foam::mapDistributeBase::distribute if (proci != myRank && map.size()) { - UOPstream os(proci, pBufs); - List subField ( accessAndFlip(field, map, subHasFlip, negOp) ); + UOPstream os(proci, pBufs); os << subField; } } @@ -1433,13 +1340,12 @@ void Foam::mapDistributeBase::send if (map.size()) { - UOPstream os(proci, pBufs); - List subField ( accessAndFlip(field, map, subHasFlip_, flipOp()) ); + UOPstream os(proci, pBufs); os << subField; } } diff --git a/src/OpenFOAM/meshes/polyMesh/syncTools/syncToolsTemplates.C b/src/OpenFOAM/meshes/polyMesh/syncTools/syncToolsTemplates.C index 874a3726b3..4148c24427 100644 --- a/src/OpenFOAM/meshes/polyMesh/syncTools/syncToolsTemplates.C +++ b/src/OpenFOAM/meshes/polyMesh/syncTools/syncToolsTemplates.C @@ -324,8 +324,8 @@ void Foam::syncTools::syncPointMap // Receive the edges using shared points from other procs for (const int proci : UPstream::subProcs()) { - IPstream fromProc(UPstream::commsTypes::scheduled, proci); - Map nbrValues(fromProc); + Map nbrValues; + IPstream::recv(nbrValues, proci); // Merge neighbouring values with my values forAllConstIters(nbrValues, iter) @@ -343,12 +343,7 @@ void Foam::syncTools::syncPointMap else { // Send to master - OPstream toMaster - ( - UPstream::commsTypes::scheduled, - UPstream::masterNo() - ); - toMaster << sharedPointValues; + OPstream::send(sharedPointValues, UPstream::masterNo()); } // Broadcast: send merged values to all @@ -687,8 +682,8 @@ void Foam::syncTools::syncEdgeMap // Receive the edges using shared points from other procs for (const int proci : UPstream::subProcs()) { - IPstream fromProc(UPstream::commsTypes::scheduled, proci); - EdgeMap nbrValues(fromProc); + EdgeMap nbrValues; + IPstream::recv(nbrValues, proci); // Merge neighbouring values with my values forAllConstIters(nbrValues, iter) @@ -706,14 +701,7 @@ void Foam::syncTools::syncEdgeMap else { // Send to master - { - OPstream toMaster - ( - UPstream::commsTypes::scheduled, - UPstream::masterNo() - ); - toMaster << sharedEdgeValues; - } + OPstream::send(sharedEdgeValues, UPstream::masterNo()); } // Broadcast: send merged values to all diff --git a/src/OpenFOAM/parallel/globalIndex/globalIndexTemplates.C b/src/OpenFOAM/parallel/globalIndex/globalIndexTemplates.C index 71c6672754..9de90ba469 100644 --- a/src/OpenFOAM/parallel/globalIndex/globalIndexTemplates.C +++ b/src/OpenFOAM/parallel/globalIndex/globalIndexTemplates.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2017 OpenFOAM Foundation - Copyright (C) 2019-2023 OpenCFD Ltd. + Copyright (C) 2019-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -170,8 +170,7 @@ void Foam::globalIndex::gatherValues } else { - IPstream fromProc(commsType, procIDs[i], 0, tag, comm); - fromProc >> allValues[i]; + IPstream::recv(allValues[i], procIDs[i], tag, comm); } } } @@ -193,8 +192,7 @@ void Foam::globalIndex::gatherValues } else { - OPstream toMaster(commsType, masterProci, 0, tag, comm); - toMaster << localValue; + OPstream::send(localValue, commsType, masterProci, tag, comm); } } @@ -269,8 +267,7 @@ void Foam::globalIndex::gather } else { - IPstream fromProc(commsType, procIDs[i], 0, tag, comm); - fromProc >> procSlot; + IPstream::recv(procSlot, procIDs[i], tag, comm); } } } @@ -294,8 +291,7 @@ void Foam::globalIndex::gather } else { - OPstream toMaster(commsType, masterProci, 0, tag, comm); - toMaster << fld; + OPstream::send(fld, commsType, masterProci, tag, comm); } } @@ -378,8 +374,7 @@ void Foam::globalIndex::gather } else { - IPstream fromProc(commsType, procIDs[i], 0, tag, comm); - fromProc >> procSlot; + IPstream::recv(procSlot, procIDs[i], tag, comm); } } } @@ -391,8 +386,7 @@ void Foam::globalIndex::gather } else { - OPstream toMaster(commsType, masterProci, 0, tag, comm); - toMaster << fld; + OPstream::send(fld, commsType, masterProci, tag, comm); } } @@ -962,8 +956,7 @@ void Foam::globalIndex::scatter } else { - OPstream toProc(commsType, procIDs[i], 0, tag, comm); - toProc << procSlot; + OPstream::send(procSlot, commsType, procIDs[i], tag, comm); } } @@ -999,8 +992,7 @@ void Foam::globalIndex::scatter } else { - IPstream fromMaster(commsType, masterProci, 0, tag, comm); - fromMaster >> fld; + IPstream::recv(fld, masterProci, tag, comm); } } diff --git a/src/sampling/surface/isoSurface/isoSurfacePoint.C b/src/sampling/surface/isoSurface/isoSurfacePoint.C index 464af60d82..0c0d0ac5d8 100644 --- a/src/sampling/surface/isoSurface/isoSurfacePoint.C +++ b/src/sampling/surface/isoSurface/isoSurfacePoint.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2015-2022 OpenCFD Ltd. + Copyright (C) 2015-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -164,12 +164,8 @@ void Foam::isoSurfacePoint::syncUnseparatedPoints patchInfo[nbrPointi] = pointValues[meshPts[pointi]]; } - OPstream toNbr - ( - Pstream::commsTypes::blocking, - procPatch.neighbProcNo() - ); - toNbr << patchInfo; + // buffered send + OPstream::bsend(patchInfo, procPatch.neighbProcNo()); } } @@ -181,17 +177,11 @@ void Foam::isoSurfacePoint::syncUnseparatedPoints if (pp.nPoints() && collocatedPatch(pp)) { - pointField nbrPatchInfo(procPatch.nPoints()); - { - // We do not know the number of points on the other side - // so cannot use UIPstream::read - IPstream fromNbr - ( - Pstream::commsTypes::blocking, - procPatch.neighbProcNo() - ); - fromNbr >> nbrPatchInfo; - } + pointField nbrPatchInfo; + + // We do not know the number of points on the other side + // so cannot use UIPstream::read + IPstream::recv(nbrPatchInfo, procPatch.neighbProcNo()); const labelList& meshPts = procPatch.meshPoints();