initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / meshes / polyMesh / globalMeshData / globalIndex.H
blobe394f679d042dd0c425f6fa7a869ebafeb5f2a4a
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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
25 Class
26     Foam::globalIndex
28 Description
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);
36 SourceFiles
37     globalIndex.C
39 \*---------------------------------------------------------------------------*/
41 #ifndef globalIndex_H
42 #define globalIndex_H
44 #include "Pstream.H"
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 namespace Foam
51 // Forward declaration of friend functions and operators
53 class globalIndex;
55 Istream& operator>>(Istream& is, globalIndex& gi);
56 Ostream& operator<<(Ostream& os, const globalIndex& gi);
59 /*---------------------------------------------------------------------------*\
60                            Class globalIndex Declaration
61 \*---------------------------------------------------------------------------*/
63 class globalIndex
65     // Private data
67         //- Start off procI+1. (so like CompactListList)
68         labelList offsets_;
71 public:
73     // Constructors
75         //- Construct from local max size
76         globalIndex(const label localSize);
78         //- Construct from Istream
79         globalIndex(Istream& is);
82     // Member Functions
84         ////- Start of procI+1 data
85         //inline const labelList& offsets() const;
88         // Queries relating to my processor
90             //- my local size
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;
104         // Global queries
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
146 #endif
148 // ************************************************************************* //