diff --git a/applications/test/processorTopology/Test-processorTopology.C b/applications/test/processorTopology/Test-processorTopology.C index 1d8d7fab1a..c4e87c8868 100644 --- a/applications/test/processorTopology/Test-processorTopology.C +++ b/applications/test/processorTopology/Test-processorTopology.C @@ -44,7 +44,7 @@ int main(int argc, char *argv[]) argList::noFunctionObjects(); argList::addNote ( - "Create a metis graph file representation for an OpenFOAM mesh" + "Create graph of OpenFOAM mesh connections" ); #include "setRootCase.H" @@ -59,9 +59,9 @@ int main(int argc, char *argv[]) #include "createTime.H" #include "createPolyMesh.H" - const globalMeshData& globData = mesh.globalData(); - - const labelListList& connectivity = globData; + // Adjacency table + const labelListList& connectivity = + mesh.globalData().topology().procNeighbours(); if (Pstream::master()) { diff --git a/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C b/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C index 680eb5815e..bc5fba6e60 100644 --- a/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C +++ b/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C @@ -60,6 +60,7 @@ Description #include "wedgePolyPatch.H" #include "planeExtrusion.H" #include "emptyPolyPatch.H" +#include "processorPolyPatch.H" #include "processorMeshes.H" #include "hexRef8Data.H" diff --git a/applications/utilities/mesh/manipulation/createBaffles/createBaffles.C b/applications/utilities/mesh/manipulation/createBaffles/createBaffles.C index 269317bc3b..ca13af55b9 100644 --- a/applications/utilities/mesh/manipulation/createBaffles/createBaffles.C +++ b/applications/utilities/mesh/manipulation/createBaffles/createBaffles.C @@ -57,6 +57,7 @@ Description #include "fvMeshTools.H" #include "topoSet.H" +#include "processorPolyPatch.H" #include "processorMeshes.H" using namespace Foam; diff --git a/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduSchedule/lduSchedule.H b/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduSchedule/lduSchedule.H index 945b1bde37..8af52779e3 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduSchedule/lduSchedule.H +++ b/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduSchedule/lduSchedule.H @@ -32,8 +32,8 @@ Description \*---------------------------------------------------------------------------*/ -#ifndef lduSchedule_H -#define lduSchedule_H +#ifndef Foam_lduSchedule_H +#define Foam_lduSchedule_H #include "List.H" @@ -42,14 +42,17 @@ Description namespace Foam { -// Forward declaration of friend functions and operators +// Forward Declarations struct lduScheduleEntry; Ostream& operator<<(Ostream& os, const lduScheduleEntry& lb); +//- A List of lduSchedule entries. +typedef List lduSchedule; + /*---------------------------------------------------------------------------*\ - Class lduSchedule Declaration + Class lduScheduleEntry Declaration \*---------------------------------------------------------------------------*/ struct lduScheduleEntry @@ -57,11 +60,22 @@ struct lduScheduleEntry label patch; bool init; - friend bool operator!= - ( - const lduScheduleEntry& lb1, - const lduScheduleEntry& lb2 - ) + //- Define patch for initEvaluate() + void setInitEvaluate(const label patchi) noexcept + { + patch = patchi; + init = true; + } + + //- Define patch for evaluate() + void setEvaluate(const label patchi) noexcept + { + patch = patchi; + init = false; + } + + //- Always unequal: each entry is supposed to be unique! + friend bool operator!=(const lduScheduleEntry&, const lduScheduleEntry&) { return true; } @@ -74,9 +88,6 @@ struct lduScheduleEntry }; -typedef List lduSchedule; - - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/OpenFOAM/meshes/ProcessorTopology/ProcessorTopology.C b/src/OpenFOAM/meshes/ProcessorTopology/ProcessorTopology.C deleted file mode 100644 index 359f7ae0b9..0000000000 --- a/src/OpenFOAM/meshes/ProcessorTopology/ProcessorTopology.C +++ /dev/null @@ -1,273 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2022 OpenCFD Ltd. -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -\*---------------------------------------------------------------------------*/ - -#include "ProcessorTopology.H" -#include "ListOps.H" -#include "Pstream.H" -#include "commSchedule.H" - -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -template -Foam::labelList Foam::ProcessorTopology::procNeighbours -( - const label nProcs, - const Container& patches -) -{ - // Determine number of processor neighbours and max neighbour id. - - label nNeighbours = 0; - - label maxNb = 0; - - boolList isNeighbourProc(nProcs, false); - - forAll(patches, patchi) - { - const auto* cpp = isA(patches[patchi]); - if (cpp) - { - const label nbrProci = cpp->neighbProcNo(); - - if (!isNeighbourProc[nbrProci]) - { - isNeighbourProc[nbrProci] = true; - maxNb = max(maxNb, nbrProci); - ++nNeighbours; - } - } - } - - labelList neighbours(nNeighbours, -1); - - nNeighbours = 0; - - forAll(isNeighbourProc, proci) - { - if (isNeighbourProc[proci]) - { - neighbours[nNeighbours++] = proci; - } - } - - procPatchMap_.setSize(maxNb + 1); - procPatchMap_ = -1; - - forAll(patches, patchi) - { - const auto* cpp = isA(patches[patchi]); - if (cpp) - { - const label nbrProci = cpp->neighbProcNo(); - - // Reverse map - procPatchMap_[nbrProci] = patchi; - } - } - - return neighbours; -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -template -Foam::ProcessorTopology::ProcessorTopology -( - const Container& patches, - const label comm -) -: - labelListList(Pstream::nProcs(comm)), - patchSchedule_() -{ - if (Pstream::parRun()) - { - // Fill my 'slot' with my neighbours - operator[](Pstream::myProcNo(comm)) = - procNeighbours(this->size(), patches); - - // Distribute to all processors - Pstream::allGatherList(*this, Pstream::msgType(), comm); - } - - if - ( - Pstream::parRun() - && Pstream::defaultCommsType == Pstream::commsTypes::scheduled - ) - { - patchSchedule_.resize(2*patches.size()); - - label patchEvali = 0; - - // 1. All non-processor patches - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - forAll(patches, patchi) - { - if (!isA(patches[patchi])) - { - patchSchedule_[patchEvali].patch = patchi; - patchSchedule_[patchEvali++].init = true; - patchSchedule_[patchEvali].patch = patchi; - patchSchedule_[patchEvali++].init = false; - } - } - - // 2. All processor patches - // ~~~~~~~~~~~~~~~~~~~~~~~~ - - // Determine the schedule for all. Insert processor pair once - // to determine the schedule. Each processor pair stands for both - // send and receive. - label nComms = 0; - for (const labelList& neighbours : *this) - { - nComms += neighbours.size(); - } - DynamicList comms(nComms); - - forAll(*this, proci) - { - const labelList& neighbours = operator[](proci); - - for (const label nbrProci : neighbours) - { - if (proci < nbrProci) - { - comms.append(labelPair(proci, nbrProci)); - } - } - } - comms.shrink(); - - // Determine a schedule. - labelList mySchedule - ( - commSchedule - ( - Pstream::nProcs(comm), - comms - ).procSchedule()[Pstream::myProcNo(comm)] - ); - - for (const label commI : mySchedule) - { - // Get the other processor - label nb = comms[commI][0]; - if (nb == Pstream::myProcNo(comm)) - { - nb = comms[commI][1]; - } - label patchi = procPatchMap_[nb]; - - if (Pstream::myProcNo(comm) > nb) - { - patchSchedule_[patchEvali].patch = patchi; - patchSchedule_[patchEvali++].init = true; - patchSchedule_[patchEvali].patch = patchi; - patchSchedule_[patchEvali++].init = false; - } - else - { - patchSchedule_[patchEvali].patch = patchi; - patchSchedule_[patchEvali++].init = false; - patchSchedule_[patchEvali].patch = patchi; - patchSchedule_[patchEvali++].init = true; - } - } - } - else - { - patchSchedule_ = nonBlockingSchedule(patches); - } -} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -template -Foam::lduSchedule -Foam::ProcessorTopology::nonBlockingSchedule -( - const Container& patches -) -{ - lduSchedule patchSchedule(2*patches.size()); - - label patchEvali = 0; - - // 1. All non-processor patches - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - // Have evaluate directly after initEvaluate. Could have them separated - // as long as they're not intermingled with processor patches since - // then e.g. any reduce parallel traffic would interfere with the - // processor swaps. - - forAll(patches, patchi) - { - if (!isA(patches[patchi])) - { - patchSchedule[patchEvali].patch = patchi; - patchSchedule[patchEvali++].init = true; - patchSchedule[patchEvali].patch = patchi; - patchSchedule[patchEvali++].init = false; - } - } - - // 2. All processor patches - // ~~~~~~~~~~~~~~~~~~~~~~~~ - - // 2a. initEvaluate - forAll(patches, patchi) - { - if (isA(patches[patchi])) - { - patchSchedule[patchEvali].patch = patchi; - patchSchedule[patchEvali++].init = true; - } - } - - // 2b. evaluate - forAll(patches, patchi) - { - if (isA(patches[patchi])) - { - patchSchedule[patchEvali].patch = patchi; - patchSchedule[patchEvali++].init = false; - } - } - - return patchSchedule; -} - - -// ************************************************************************* // diff --git a/src/OpenFOAM/meshes/ProcessorTopology/ProcessorTopology.H b/src/OpenFOAM/meshes/ProcessorTopology/ProcessorTopology.H deleted file mode 100644 index 3dbcff1777..0000000000 --- a/src/OpenFOAM/meshes/ProcessorTopology/ProcessorTopology.H +++ /dev/null @@ -1,126 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2011-2016 OpenFOAM Foundation -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -Class - Foam::ProcessorTopology - -Description - Determines processor-processor connection. After instantiation contains - on all processors the processor-processor connection table. - - *this[proci] gives the list of neighbouring processors. - - TODO: This does not currently correctly support multiple processor - patches connecting two processors. - -SourceFiles - ProcessorTopology.C - -\*---------------------------------------------------------------------------*/ - -#ifndef Foam_ProcessorTopology_H -#define Foam_ProcessorTopology_H - -#include "labelList.H" -#include "lduSchedule.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class ProcessorTopology Declaration -\*---------------------------------------------------------------------------*/ - -template -class ProcessorTopology -: - public labelListList -{ - // Private Data - - //- Local map from neighbour proc to patchi. Different per processor! - // -1 or patchi for connection to procID - labelList procPatchMap_; - - //- Order in which the patches should be initialised/evaluated - // corresponding to the schedule - lduSchedule patchSchedule_; - - - // Private Member Functions - - //- Return all neighbouring processors of this processor. - // Sets procPatchMap_. - labelList procNeighbours(const label nProcs, const Container&); - -public: - - // Constructors - - //- Construct from boundaryMesh - ProcessorTopology(const Container& patches, const label comm); - - - // Static Functions - - //- Calculate non-blocking (i.e. unscheduled) schedule - static lduSchedule nonBlockingSchedule(const Container& patches); - - - // Member Functions - - //- From neighbour processor to index in boundaryMesh. - // Local information (so not same over all processors) - const labelList& procPatchMap() const noexcept - { - return procPatchMap_; - } - - //- Order in which the patches should be initialised/evaluated - //- corresponding to the schedule - const lduSchedule& patchSchedule() const noexcept - { - return patchSchedule_; - } -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#ifdef NoRepository - #include "ProcessorTopology.C" -#endif - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/OpenFOAM/meshes/lduMesh/lduPrimitiveMeshTemplates.C b/src/OpenFOAM/meshes/lduMesh/lduPrimitiveMeshTemplates.C index ed5929d74a..6b774f304f 100644 --- a/src/OpenFOAM/meshes/lduMesh/lduPrimitiveMeshTemplates.C +++ b/src/OpenFOAM/meshes/lduMesh/lduPrimitiveMeshTemplates.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013 OpenFOAM Foundation + Copyright (C) 2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -36,38 +37,37 @@ Foam::lduSchedule Foam::lduPrimitiveMesh::nonBlockingSchedule ) { lduSchedule schedule(2*interfaces.size()); - label slotI = 0; - forAll(interfaces, i) + // 1. All non-processor patches + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + label patchEvali = 0; + + forAll(interfaces, patchi) { - if (interfaces.set(i) && !isA(interfaces[i])) + if (interfaces.set(patchi) && !isA(interfaces[patchi])) { - schedule[slotI].patch = i; - schedule[slotI].init = true; - slotI++; - schedule[slotI].patch = i; - schedule[slotI].init = false; - slotI++; + schedule[patchEvali++].setInitEvaluate(patchi); + schedule[patchEvali++].setEvaluate(patchi); } } - forAll(interfaces, i) + // 2. All processor patches + // ~~~~~~~~~~~~~~~~~~~~~~~~ + + forAll(interfaces, patchi) { - if (interfaces.set(i) && isA(interfaces[i])) + if (interfaces.set(patchi) && isA(interfaces[patchi])) { - schedule[slotI].patch = i; - schedule[slotI].init = true; - slotI++; + schedule[patchEvali++].setInitEvaluate(patchi); } } - forAll(interfaces, i) + forAll(interfaces, patchi) { - if (interfaces.set(i) && isA(interfaces[i])) + if (interfaces.set(patchi) && isA(interfaces[patchi])) { - schedule[slotI].patch = i; - schedule[slotI].init = false; - slotI++; + schedule[patchEvali++].setEvaluate(patchi); } } diff --git a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C index 0741da6531..8627307f8d 100644 --- a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C +++ b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C @@ -27,14 +27,15 @@ License \*---------------------------------------------------------------------------*/ #include "globalMeshData.H" -#include "Pstream.H" -#include "processorPolyPatch.H" #include "globalPoints.H" #include "polyMesh.H" #include "mapDistribute.H" #include "labelIOList.H" #include "mergePoints.H" +#include "processorPolyPatch.H" +#include "processorTopologyNew.H" #include "globalIndexAndTransform.H" +#include "Pstream.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -61,15 +62,15 @@ public: void Foam::globalMeshData::initProcAddr() { - processorPatchIndices_.setSize(mesh_.boundaryMesh().size()); + processorPatchIndices_.resize_nocopy(mesh_.boundaryMesh().size()); processorPatchIndices_ = -1; - processorPatchNeighbours_.setSize(mesh_.boundaryMesh().size()); + processorPatchNeighbours_.resize_nocopy(mesh_.boundaryMesh().size()); processorPatchNeighbours_ = -1; // Construct processor patch indexing. processorPatchNeighbours_ only // set if running in parallel! - processorPatches_.setSize(mesh_.boundaryMesh().size()); + processorPatches_.resize_nocopy(mesh_.boundaryMesh().size()); label nNeighbours = 0; @@ -81,7 +82,7 @@ void Foam::globalMeshData::initProcAddr() processorPatchIndices_[patchi] = nNeighbours++; } } - processorPatches_.setSize(nNeighbours); + processorPatches_.resize(nNeighbours); if (Pstream::parRun()) @@ -1728,14 +1729,21 @@ void Foam::globalMeshData::calcGlobalCoPointSlaves() const Foam::globalMeshData::globalMeshData(const polyMesh& mesh) : - processorTopology(mesh.boundaryMesh(), UPstream::worldComm), mesh_(mesh), nTotalPoints_(-1), nTotalFaces_(-1), nTotalCells_(-1), - processorPatches_(0), - processorPatchIndices_(0), - processorPatchNeighbours_(0), + processorTopology_ + ( + processorTopology::New + ( + mesh.boundaryMesh(), + UPstream::worldComm + ) + ), + processorPatches_(), + processorPatchIndices_(), + processorPatchNeighbours_(), nGlobalPoints_(-1), sharedPointLabelsPtr_(nullptr), sharedPointAddrPtr_(nullptr), @@ -1750,10 +1758,9 @@ Foam::globalMeshData::globalMeshData(const polyMesh& mesh) // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // +// A non-default destructor since we had incomplete types in the header Foam::globalMeshData::~globalMeshData() -{ - clearOut(); -} +{} void Foam::globalMeshData::clearOut() @@ -1780,6 +1787,7 @@ void Foam::globalMeshData::clearOut() globalPointSlavesPtr_.clear(); globalPointTransformedSlavesPtr_.clear(); globalPointSlavesMapPtr_.clear(); + // Edge globalEdgeNumberingPtr_.clear(); globalEdgeSlavesPtr_.clear(); @@ -2728,7 +2736,7 @@ void Foam::globalMeshData::updateMesh() if (debug) { - Pout<< "globalMeshData : nTotalFaces_:" << nTotalFaces_ << endl; + Pout<< "globalMeshData : nTotalFaces:" << nTotalFaces_ << endl; } nTotalCells_ = returnReduce @@ -2741,7 +2749,7 @@ void Foam::globalMeshData::updateMesh() if (debug) { - Pout<< "globalMeshData : nTotalCells_:" << nTotalCells_ << endl; + Pout<< "globalMeshData : nTotalCells:" << nTotalCells_ << endl; } nTotalPoints_ = returnReduce @@ -2757,7 +2765,7 @@ void Foam::globalMeshData::updateMesh() if (debug) { - Pout<< "globalMeshData : nTotalPoints_:" << nTotalPoints_ << endl; + Pout<< "globalMeshData : nTotalPoints:" << nTotalPoints_ << endl; } } diff --git a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.H b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.H index 41ed3e36fb..fb75f9677e 100644 --- a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.H +++ b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2018-2021 OpenCFD Ltd. + Copyright (C) 2018-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -81,8 +81,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef globalMeshData_H -#define globalMeshData_H +#ifndef Foam_globalMeshData_H +#define Foam_globalMeshData_H #include "processorTopology.H" #include "labelPair.H" @@ -106,8 +106,6 @@ class bitSet; \*---------------------------------------------------------------------------*/ class globalMeshData -: - public processorTopology { // Private Data @@ -129,6 +127,9 @@ class globalMeshData // Processor patch addressing (be careful if not running in parallel!) + //- The processor/processor topology + processorTopology processorTopology_; + //- List of processor patch labels // (size of list = number of processor patches) labelList processorPatches_; @@ -377,6 +378,19 @@ public: // Processor patch addressing (be careful when not running in parallel) + //- The processor to processor topology. + const processorTopology& topology() const noexcept + { + return processorTopology_; + } + + //- Order in which the patches should be initialised/evaluated + //- corresponding to the schedule + const lduSchedule& patchSchedule() const noexcept + { + return processorTopology_.patchSchedule(); + } + //- Return list of processor patch labels // (size of list = number of processor patches) const labelList& processorPatches() const noexcept @@ -393,7 +407,7 @@ public: } //- Return processorPatchIndices of the neighbours - // processor patches. -1 if not running parallel. + //- processor patches. -1 if not running parallel. const labelList& processorPatchNeighbours() const noexcept { return processorPatchNeighbours_; diff --git a/src/OpenFOAM/meshes/polyMesh/globalMeshData/processorTopology.H b/src/OpenFOAM/meshes/polyMesh/globalMeshData/processorTopology.H deleted file mode 100644 index 950f2d1e4f..0000000000 --- a/src/OpenFOAM/meshes/polyMesh/globalMeshData/processorTopology.H +++ /dev/null @@ -1,51 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2011-2013 OpenFOAM Foundation -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -\*---------------------------------------------------------------------------*/ - -#ifndef processorTopology_H -#define processorTopology_H - -#include "ProcessorTopology.H" -#include "processorPolyPatch.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -typedef ProcessorTopology processorTopology; - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/OpenFOAM/parallel/commSchedule/commSchedule.C b/src/OpenFOAM/parallel/commSchedule/commSchedule.C index 6bb6d5949b..32302b39fb 100644 --- a/src/OpenFOAM/parallel/commSchedule/commSchedule.C +++ b/src/OpenFOAM/parallel/commSchedule/commSchedule.C @@ -90,7 +90,8 @@ Foam::commSchedule::commSchedule if (proc0 < 0 || proc0 >= nProcs || proc1 < 0 || proc1 >= nProcs) { FatalErrorInFunction - << "Illegal processor " << comms[commI] << abort(FatalError); + << "Illegal processor(s): " + << comms[commI] << abort(FatalError); } procToComms[proc0].append(commI); diff --git a/src/OpenFOAM/parallel/commSchedule/commSchedule.H b/src/OpenFOAM/parallel/commSchedule/commSchedule.H index 765f4165ff..821dfa9afc 100644 --- a/src/OpenFOAM/parallel/commSchedule/commSchedule.H +++ b/src/OpenFOAM/parallel/commSchedule/commSchedule.H @@ -42,8 +42,8 @@ Description - procSchedule()[proci] gives per proci Does not care whether 'talking' is first send, second receive or maybe - full swap. This is all responsibility of caller. See ProcessorTopology - class for use in scheduling processor boundary swaps. + full swap. This is all responsibility of caller. + See Foam::rocessorTopology for use in scheduling processor boundary swaps. SourceFiles commSchedule.C @@ -78,13 +78,17 @@ class commSchedule public: + //- Runtime type information ClassName("commSchedule"); + // Constructors //- Construct from wanted communication. Wanted communication is between - // two processors. Can be a one-way communication or - // two-way communication, that is up to the caller. This class just + //- two processors. Can be a one-way communication or + //- two-way communication, that is up to the caller. + // + // This class just // determines an order for it such that any processor is only talking // to one other at a time. After construction: // - schedule is the order in which comms is done. diff --git a/src/OpenFOAM/parallel/processorTopology/processorTopology.H b/src/OpenFOAM/parallel/processorTopology/processorTopology.H new file mode 100644 index 0000000000..3cce0ec109 --- /dev/null +++ b/src/OpenFOAM/parallel/processorTopology/processorTopology.H @@ -0,0 +1,176 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2022 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::processorTopology + +Description + Determines/represents processor-processor connection. + After instantiation contains the processor-processor connection table + (globally synchronized on all processors). + +Note + A processorTopology is usually generated by using the \c New + factory method, which has been wrapped into a separate header to + minimize dependencies. + +Warning + Does not currently correctly support multiple processor + patches connecting two processors. + +SourceFiles + processorTopologyNew.H + +\*---------------------------------------------------------------------------*/ + +#ifndef Foam_processorTopology_H +#define Foam_processorTopology_H + +#include "labelList.H" +#include "lduSchedule.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class processorTopology Declaration +\*---------------------------------------------------------------------------*/ + +class processorTopology +{ + // Private Data + + //- The processor to processor connection (adjacency) table + labelListList procNeighbours_; + + //- Order in which the patches should be initialised/evaluated + //- corresponding to the schedule + lduSchedule patchSchedule_; + + //- Local map from neighbour proc to patchi. Different per processor! + // -1 or patchi for connection to procID + labelList procPatchMap_; + + + // Private Member Functions + + //- From neighbour processor to index in our local boundary. + // Local information (so not same over all processors) + ///const labelList& procPatchMap() const noexcept + ///{ + /// return procPatchMap_; + ///} + + //- Which \em local boundary is attached to specified processor + // Local information (so not same over all processors) + // \return -1 if not currently connected to specified processor. + label procToLocalPatch(const label proci) const + { + return + ( + proci >= 0 && proci < procPatchMap_.size() + ? procPatchMap_[proci] + : static_cast