1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 Calculates a unique integer (label so might not have enough room - 2G max)
30 for processor + local index. E.g.
32 globalIndex globalFaces(mesh.nFaces());
33 label globalFaceI = globalFaces.toGlobal(faceI);
39 \*---------------------------------------------------------------------------*/
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 // Forward declaration of friend functions and operators
55 Istream& operator>>(Istream& is, globalIndex& gi);
56 Ostream& operator<<(Ostream& os, const globalIndex& gi);
59 /*---------------------------------------------------------------------------*\
60 Class globalIndex Declaration
61 \*---------------------------------------------------------------------------*/
67 //- Start off procI+1. (so like CompactListList)
75 //- Construct from local max size
76 globalIndex(const label localSize);
78 //- Construct from Istream
79 globalIndex(Istream& is);
84 ////- Start of procI+1 data
85 //inline const labelList& offsets() const;
88 // Queries relating to my processor
91 inline label localSize() const;
93 //- From local to global
94 inline label toGlobal(const label i) const;
96 //- Is on local processor
97 inline bool isLocal(const label i) const;
99 //- From global to local on current processor.
100 // FatalError if not on local processor.
101 inline label toLocal(const label i) const;
106 //- Global sum of localSizes
107 inline label size() const;
109 //- Size of procI data
110 inline label localSize(const label procI) const;
112 //- From local to global on procI
113 inline label toGlobal(const label procI, const label i) const;
115 //- Is on processor procI
116 inline bool isLocal(const label procI, const label i) const;
118 //- From global to local on procI
119 inline label toLocal(const label procI, const label i) const;
121 //- Which processor does global come from? Binary search.
122 inline label whichProcID(const label i) const;
124 //- Start of procI data
125 inline label offset(const label procI) const;
129 // IOstream Operators
131 friend Istream& operator>>(Istream& is, globalIndex& gi);
132 friend Ostream& operator<<(Ostream& os, const globalIndex& gi);
136 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
138 } // End namespace Foam
140 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
142 #include "globalIndexI.H"
144 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
148 // ************************************************************************* //