00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. 00006 \\/ M anipulation | 00007 ------------------------------------------------------------------------------- 00008 License 00009 This file is part of OpenFOAM. 00010 00011 OpenFOAM is free software: you can redistribute it and/or modify it 00012 under the terms of the GNU General Public License as published by 00013 the Free Software Foundation, either version 3 of the License, or 00014 (at your option) any later version. 00015 00016 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00018 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00019 for more details. 00020 00021 You should have received a copy of the GNU General Public License 00022 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. 00023 00024 Class 00025 Foam::globalIndex 00026 00027 Description 00028 Calculates a unique integer (label so might not have enough room - 2G max) 00029 for processor + local index. E.g. 00030 00031 globalIndex globalFaces(mesh.nFaces()); 00032 label globalFaceI = globalFaces.toGlobal(faceI); 00033 00034 00035 SourceFiles 00036 globalIndex.C 00037 00038 \*---------------------------------------------------------------------------*/ 00039 00040 #ifndef globalIndex_H 00041 #define globalIndex_H 00042 00043 #include <OpenFOAM/Pstream.H> 00044 00045 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00046 00047 namespace Foam 00048 { 00049 00050 // Forward declaration of friend functions and operators 00051 00052 class globalIndex; 00053 00054 Istream& operator>>(Istream& is, globalIndex& gi); 00055 Ostream& operator<<(Ostream& os, const globalIndex& gi); 00056 00057 00058 /*---------------------------------------------------------------------------*\ 00059 Class globalIndex Declaration 00060 \*---------------------------------------------------------------------------*/ 00061 00062 class globalIndex 00063 { 00064 // Private data 00065 00066 //- Start off procI+1. (so like CompactListList) 00067 labelList offsets_; 00068 00069 00070 public: 00071 00072 // Constructors 00073 00074 //- Construct from local max size 00075 globalIndex(const label localSize); 00076 00077 //- Construct from Istream 00078 globalIndex(Istream& is); 00079 00080 00081 // Member Functions 00082 00084 //inline const labelList& offsets() const; 00085 00086 00087 // Queries relating to my processor 00088 00089 //- my local size 00090 inline label localSize() const; 00091 00092 //- From local to global 00093 inline label toGlobal(const label i) const; 00094 00095 //- Is on local processor 00096 inline bool isLocal(const label i) const; 00097 00098 //- From global to local on current processor. 00099 // FatalError if not on local processor. 00100 inline label toLocal(const label i) const; 00101 00102 00103 // Global queries 00104 00105 //- Global sum of localSizes 00106 inline label size() const; 00107 00108 //- Size of procI data 00109 inline label localSize(const label procI) const; 00110 00111 //- From local to global on procI 00112 inline label toGlobal(const label procI, const label i) const; 00113 00114 //- Is on processor procI 00115 inline bool isLocal(const label procI, const label i) const; 00116 00117 //- From global to local on procI 00118 inline label toLocal(const label procI, const label i) const; 00119 00120 //- Which processor does global come from? Binary search. 00121 inline label whichProcID(const label i) const; 00122 00123 //- Start of procI data 00124 inline label offset(const label procI) const; 00125 00126 00127 00128 // IOstream Operators 00129 00130 friend Istream& operator>>(Istream& is, globalIndex& gi); 00131 friend Ostream& operator<<(Ostream& os, const globalIndex& gi); 00132 }; 00133 00134 00135 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00136 00137 } // End namespace Foam 00138 00139 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00140 00141 #include <OpenFOAM/globalIndexI.H> 00142 00143 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00144 00145 #endif 00146 00147 // ************************ vim: set sw=4 sts=4 et: ************************ //