/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2022 M. Janssens ------------------------------------------------------------------------------- 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 "processorColour.H" #include "processorLduInterface.H" #include "processorTopologyNew.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { defineTypeNameAndDebug(processorColour, 0); } // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // Foam::label Foam::processorColour::colour ( const lduMesh& mesh, labelList& procColour ) { procColour.resize_nocopy(Pstream::nProcs(mesh.comm())); procColour = -1; // Re-use processor-topology analysis labelListList procNeighbours(Pstream::nProcs(mesh.comm())); // Fill my entry { const lduInterfacePtrsList patches = mesh.interfaces(); auto& procToProcs = procNeighbours[Pstream::myProcNo(mesh.comm())]; label n = 0; forAll(patches, patchi) { if (patches.set(patchi)) { if (isA(patches[patchi])) { n++; } } } procToProcs.resize_nocopy(n); n = 0; forAll(patches, patchi) { if (patches.set(patchi)) { const auto* ppPtr = isA(patches[patchi]); if (ppPtr) { procToProcs[n++] = ppPtr->neighbProcNo(); } } } } // Send to master Pstream::gatherList(procNeighbours, UPstream::msgType(), mesh.comm()); // Use greedy algorithm for now // (see e.g. https://iq.opengenus.org/graph-colouring-greedy-algorithm/) if (Pstream::master(mesh.comm())) { DynamicList