diff --git a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalPoints.C b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalPoints.C index f34b7c542d789f9dac2dc00626295ed1b53246b5..5466f411304383e8da664a93c88ad1cd0e3e0caa 100644 --- a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalPoints.C +++ b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalPoints.C @@ -891,19 +891,22 @@ void Foam::globalPoints::calculateSharedPoints // a point or edge. initOwnPoints(meshToPatchPoint, true, changedPoints); + // Note: to use 'scheduled' would have to intersperse send and receive. + // So for now just use nonBlocking. Also globalPoints itself gets + // constructed by mesh.globalData().patchSchedule() so creates a loop. + PstreamBuffers pBufs + ( + ( + Pstream::defaultCommsType == Pstream::commsTypes::scheduled + ? Pstream::commsTypes::nonBlocking + : Pstream::defaultCommsType + ) + ); + // Do one exchange iteration to get neighbour points. { - // Note: to use 'scheduled' would have to intersperse send and receive. - // So for now just use nonBlocking. Also globalPoints itself gets - // constructed by mesh.globalData().patchSchedule() so creates a loop. - PstreamBuffers pBufs - ( - ( - Pstream::defaultCommsType == Pstream::commsTypes::scheduled - ? Pstream::commsTypes::nonBlocking - : Pstream::defaultCommsType - ) - ); + pBufs.clear(); + sendPatchPoints ( mergeSeparated, @@ -911,7 +914,9 @@ void Foam::globalPoints::calculateSharedPoints pBufs, changedPoints ); + pBufs.finishedSends(); + receivePatchPoints ( mergeSeparated, @@ -933,14 +938,8 @@ void Foam::globalPoints::calculateSharedPoints do { - PstreamBuffers pBufs - ( - ( - Pstream::defaultCommsType == Pstream::commsTypes::scheduled - ? Pstream::commsTypes::nonBlocking - : Pstream::defaultCommsType - ) - ); + pBufs.clear(); + sendPatchPoints ( mergeSeparated, @@ -948,7 +947,9 @@ void Foam::globalPoints::calculateSharedPoints pBufs, changedPoints ); + pBufs.finishedSends(); + receivePatchPoints ( mergeSeparated, diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.C index 8802246e9269e4b674427a592e8cb9d467b9dfe6..f0441afd67e811afce9f183355157714fdec84b4 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.C @@ -452,31 +452,6 @@ Foam::label Foam::addPatchCellLayer::addSideFace } -Foam::label Foam::addPatchCellLayer::findProcPatch -( - const polyMesh& mesh, - const label nbrProcID -) -{ - const polyBoundaryMesh& patches = mesh.boundaryMesh(); - - forAll(mesh.globalData().processorPatches(), i) - { - label patchi = mesh.globalData().processorPatches()[i]; - - if - ( - refCast<const processorPolyPatch>(patches[patchi]).neighbProcNo() - == nbrProcID - ) - { - return patchi; - } - } - return -1; -} - - void Foam::addPatchCellLayer::setFaceProps ( const polyMesh& mesh, diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.H b/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.H index b0d12af7ed6bdbe71644f206ee3218d214fd87e2..fe59a8f6080b4e613f750a0b203e090a98ced277 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.H +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.H @@ -202,9 +202,6 @@ class addPatchCellLayer polyTopoChange& ) const; - //- Find patch to neighbouring processor - static label findProcPatch(const polyMesh&, const label nbrProcID); - //- Extract properties from mesh face static void setFaceProps ( diff --git a/src/meshTools/algorithms/MeshWave/FaceCellWave.C b/src/meshTools/algorithms/MeshWave/FaceCellWave.C index aeb893032488c6f491c9bcb712c2e6829e2eec66..325f93ba9440181fa1eec7a28613427d6057cfbc 100644 --- a/src/meshTools/algorithms/MeshWave/FaceCellWave.C +++ b/src/meshTools/algorithms/MeshWave/FaceCellWave.C @@ -526,13 +526,15 @@ void Foam::FaceCellWave<Type, TrackingData>::handleProcPatches() // Which patches are processor patches const labelList& procPatches = pData.processorPatches(); - // Send all + // Which processors this processor is connected to + const labelList& neighbourProcs = pData.topology().procNeighbours(); - PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking); + // Reset buffers + pBufs_.clear(); for (const label patchi : procPatches) { - const processorPolyPatch& procPatch = + const auto& procPatch = refCast<const processorPolyPatch>(mesh_.boundaryMesh()[patchi]); // Allocate buffers @@ -567,20 +569,20 @@ void Foam::FaceCellWave<Type, TrackingData>::handleProcPatches() << endl; } - UOPstream toNeighbour(procPatch.neighbProcNo(), pBufs); + UOPstream toNeighbour(procPatch.neighbProcNo(), pBufs_); //writeFaces(nSendFaces, sendFaces, sendFacesInfo, toNeighbour); toNeighbour << SubList<label>(sendFaces, nSendFaces) << SubList<Type>(sendFacesInfo, nSendFaces); } - pBufs.finishedSends(); + // Finished sends + pBufs_.finishedNeighbourSends(neighbourProcs); - // Receive all for (const label patchi : procPatches) { - const processorPolyPatch& procPatch = + const auto& procPatch = refCast<const processorPolyPatch>(mesh_.boundaryMesh()[patchi]); // Allocate buffers @@ -588,7 +590,7 @@ void Foam::FaceCellWave<Type, TrackingData>::handleProcPatches() List<Type> receiveFacesInfo; { - UIPstream fromNeighbour(procPatch.neighbProcNo(), pBufs); + UIPstream fromNeighbour(procPatch.neighbProcNo(), pBufs_); fromNeighbour >> receiveFaces >> receiveFacesInfo; } diff --git a/src/meshTools/algorithms/MeshWave/FaceCellWave.H b/src/meshTools/algorithms/MeshWave/FaceCellWave.H index e98f41d4131bc4c19d60e731fe0afd762d9f12ab..e2dd118bd4255c7a2dff2417bc5759580e3f27e0 100644 --- a/src/meshTools/algorithms/MeshWave/FaceCellWave.H +++ b/src/meshTools/algorithms/MeshWave/FaceCellWave.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2018-2022 OpenCFD Ltd. + Copyright (C) 2018-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -51,9 +51,10 @@ SourceFiles #define Foam_FaceCellWave_H #include "bitSet.H" +#include "labelPair.H" #include "DynamicList.H" #include "primitiveFieldsFwd.H" -#include "labelPair.H" +#include "PstreamBuffers.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -83,6 +84,9 @@ protected: //- Reference to mesh const polyMesh& mesh_; + //- Buffers when updating processor patches + PstreamBuffers pBufs_; + //- Track if face has changed bitSet changedFace_; @@ -115,7 +119,7 @@ public: // Constructors //- Construct with mesh reference and set initial sizes - FaceCellWaveBase(const polyMesh& mesh); + explicit FaceCellWaveBase(const polyMesh& mesh); // Static Functions diff --git a/src/meshTools/algorithms/MeshWave/FaceCellWaveBase.C b/src/meshTools/algorithms/MeshWave/FaceCellWaveBase.C index 0666052af5c9b81781fb6da43fb933bdd0f61e0d..9cbeb1e675d40d7154061f6935a0562a1c9705e0 100644 --- a/src/meshTools/algorithms/MeshWave/FaceCellWaveBase.C +++ b/src/meshTools/algorithms/MeshWave/FaceCellWaveBase.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2012 OpenFOAM Foundation - Copyright (C) 2022 OpenCFD Ltd. + Copyright (C) 2022-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -52,6 +52,7 @@ Foam::FaceCellWaveBase::FaceCellWaveBase ) : mesh_(mesh), + pBufs_(UPstream::commsTypes::nonBlocking), changedFace_(mesh_.nFaces()), changedCell_(mesh_.nCells()), changedFaces_(mesh_.nFaces()), diff --git a/src/meshTools/algorithms/PointEdgeWave/PointEdgeWave.C b/src/meshTools/algorithms/PointEdgeWave/PointEdgeWave.C index 9ccf3e3762eea7ac85d73dbdd57661d4b953eb52..215be1c467452d91495b9cbd8f2802975da897ed 100644 --- a/src/meshTools/algorithms/PointEdgeWave/PointEdgeWave.C +++ b/src/meshTools/algorithms/PointEdgeWave/PointEdgeWave.C @@ -305,16 +305,24 @@ void Foam::PointEdgeWave<Type, TrackingData>::handleProcPatches() { // 1. Send all point info on processor patches. - PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking); + const globalMeshData& pData = mesh_.globalData(); + + // Which patches are processor patches + const labelList& procPatches = pData.processorPatches(); + + // Which processors this processor is connected to + const labelList& neighbourProcs = pData.topology().procNeighbours(); + + // Reset buffers + pBufs_.clear(); DynamicList<Type> patchInfo; DynamicList<label> thisPoints; DynamicList<label> nbrPoints; - forAll(mesh_.globalData().processorPatches(), i) + for (const label patchi : procPatches) { - label patchi = mesh_.globalData().processorPatches()[i]; - const processorPolyPatch& procPatch = + const auto& procPatch = refCast<const processorPolyPatch>(mesh_.boundaryMesh()[patchi]); patchInfo.clear(); @@ -347,28 +355,28 @@ void Foam::PointEdgeWave<Type, TrackingData>::handleProcPatches() // << " Sending:" << patchInfo.size() << endl; //} - UOPstream toNeighbour(procPatch.neighbProcNo(), pBufs); + UOPstream toNeighbour(procPatch.neighbProcNo(), pBufs_); toNeighbour << nbrPoints << patchInfo; } - pBufs.finishedSends(); + // Finished sends + pBufs_.finishedNeighbourSends(neighbourProcs); // // 2. Receive all point info on processor patches. // - forAll(mesh_.globalData().processorPatches(), i) + for (const label patchi : procPatches) { - label patchi = mesh_.globalData().processorPatches()[i]; - const processorPolyPatch& procPatch = + const auto& procPatch = refCast<const processorPolyPatch>(mesh_.boundaryMesh()[patchi]); List<Type> patchInfo; labelList patchPoints; { - UIPstream fromNeighbour(procPatch.neighbProcNo(), pBufs); + UIPstream fromNeighbour(procPatch.neighbProcNo(), pBufs_); fromNeighbour >> patchPoints >> patchInfo; } diff --git a/src/meshTools/algorithms/PointEdgeWave/PointEdgeWave.H b/src/meshTools/algorithms/PointEdgeWave/PointEdgeWave.H index 453d6e4b17d22b3b4605886e4c9da14c8cea698b..10af737920c6728f27b9d4e7ed911ddf0c4f9751 100644 --- a/src/meshTools/algorithms/PointEdgeWave/PointEdgeWave.H +++ b/src/meshTools/algorithms/PointEdgeWave/PointEdgeWave.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2020-2022 OpenCFD Ltd. + Copyright (C) 2020-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -64,6 +64,7 @@ SourceFiles #include "bitSet.H" #include "scalarField.H" #include "tensorField.H" +#include "PstreamBuffers.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -95,6 +96,9 @@ protected: //- Reference to mesh const polyMesh& mesh_; + //- Buffers when updating processor patches + PstreamBuffers pBufs_; + //- Track if point has changed bitSet changedPoint_; @@ -127,7 +131,7 @@ public: // Constructors //- Construct with mesh reference and set initial sizes - PointEdgeWaveBase(const polyMesh& mesh); + explicit PointEdgeWaveBase(const polyMesh& mesh); // Static Functions diff --git a/src/meshTools/algorithms/PointEdgeWave/PointEdgeWaveBase.C b/src/meshTools/algorithms/PointEdgeWave/PointEdgeWaveBase.C index 2af77fb4f279d63f2236b17b59e3186843dcd3ad..2b67798974471eca794239b066d66987e271806f 100644 --- a/src/meshTools/algorithms/PointEdgeWave/PointEdgeWaveBase.C +++ b/src/meshTools/algorithms/PointEdgeWave/PointEdgeWaveBase.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2012 OpenFOAM Foundation - Copyright (C) 2022 OpenCFD Ltd. + Copyright (C) 2022-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -50,6 +50,7 @@ Foam::PointEdgeWaveBase::PointEdgeWaveBase ) : mesh_(mesh), + pBufs_(UPstream::commsTypes::nonBlocking), changedPoint_(mesh_.nPoints()), changedEdge_(mesh_.nEdges()), changedPoints_(mesh_.nPoints()),