/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Copyright (C) 2015-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- 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::distributionMapBase Description Class containing processor-to-processor mapping information. We store mapping from the bits-to-send to the complete starting list (subXXXMap) and from the received bits to their location in the new list (constructXXXMap). Schedule is a list of processor pairs (one send, one receive. One of them will be myself) which forms a scheduled (i.e. non-buffered) exchange. See distribute on how to use it. Note2: number of items sent on one processor have to equal the number of items received on the other processor. To aid constructing these maps there are the constructors from global numbering, either with or without transforms. Constructors using compact numbering: layout is - all my own elements first (whether used or not) - followed by used-only remote elements sorted by remote processor. So e.g 4 procs and on proc 1 the compact table will first have all globalIndex.localSize() elements from proc1 followed by used-only elements of proc0, proc2, proc3. The constructed distributionMapBase sends the local elements from and receives the remote elements into their compact position. compactMap[proci] is the position of elements from proci in the compact map. compactMap[myProcNo()] is empty since trivial addressing. It rewrites the input global indices into indices into the constructed data. When constructing from components optionally a 'flip' on the maps can be specified. This will interpret the map values as index+flip, similar to e.g. faceProcAddressing. The flip will only be applied to fieldTypes (scalar, vector, .. triad) SourceFiles distributionMapBase.C distributionMapBaseTemplates.C \*---------------------------------------------------------------------------*/ #ifndef distributionMapBase_H #define distributionMapBase_H #include "labelList.H" #include "labelPair.H" #include "Pstream.H" #include "boolList.H" #include "Map.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { class globalIndex; class PstreamBuffers; // Forward declaration of friend functions and operators class distributionMapBase; Istream& operator>>(Istream&, distributionMapBase&); Ostream& operator<<(Ostream&, const distributionMapBase&); /*---------------------------------------------------------------------------*\ Class distributionMapBase Declaration \*---------------------------------------------------------------------------*/ class distributionMapBase { protected: // Protected data //- Size of reconstructed data label constructSize_; //- Maps from subsetted data back to original data labelListList subMap_; //- Maps from subsetted data to new reconstructed data labelListList constructMap_; //- Whether subMap includes flip or not bool subHasFlip_; //- Whether constructMap includes flip or not bool constructHasFlip_; //- Schedule mutable autoPtr> schedulePtr_; // Private Member Functions static void checkReceivedSize ( const label proci, const label expectedSize, const label receivedSize ); //- Construct per processor compact addressing of the global elements // needed. The ones from the local processor are not included since // these are always all needed. void calcCompactAddressing ( const globalIndex& globalNumbering, const labelList& elements, List>& compactMap ) const; void calcCompactAddressing ( const globalIndex& globalNumbering, const labelListList& elements, List>& compactMap ) const; void exchangeAddressing ( const int tag, const globalIndex& globalNumbering, labelList& elements, List>& compactMap, labelList& compactStart ); void exchangeAddressing ( const int tag, const globalIndex& globalNumbering, labelListList& elements, List>& compactMap, labelList& compactStart ); template static void flipAndCombine ( const UList