|
|
|
globalIndex.HGo to the documentation of this file.00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 1991-2009 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 the 00013 Free Software Foundation; either version 2 of the License, or (at your 00014 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, write to the Free Software Foundation, 00023 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00024 00025 Class 00026 Foam::globalIndex 00027 00028 Description 00029 Calculates a unique integer (label so might not have enough room - 2G max) 00030 for processor + local index. E.g. 00031 00032 globalIndex globalFaces(mesh.nFaces()); 00033 label globalFaceI = globalFaces.toGlobal(faceI); 00034 00035 00036 SourceFiles 00037 globalIndex.C 00038 00039 \*---------------------------------------------------------------------------*/ 00040 00041 #ifndef globalIndex_H 00042 #define globalIndex_H 00043 00044 #include "Pstream.H" 00045 00046 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00047 00048 namespace Foam 00049 { 00050 00051 // Forward declaration of friend functions and operators 00052 00053 class globalIndex; 00054 00055 Istream& operator>>(Istream& is, globalIndex& gi); 00056 Ostream& operator<<(Ostream& os, const globalIndex& gi); 00057 00058 00059 /*---------------------------------------------------------------------------*\ 00060 Class globalIndex Declaration 00061 \*---------------------------------------------------------------------------*/ 00062 00063 class globalIndex 00064 { 00065 // Private data 00066 00067 //- Start off procI+1. (so like CompactListList) 00068 labelList offsets_; 00069 00070 00071 public: 00072 00073 // Constructors 00074 00075 //- Construct from local max size 00076 globalIndex(const label localSize); 00077 00078 //- Construct from Istream 00079 globalIndex(Istream& is); 00080 00081 00082 // Member Functions 00083 00085 //inline const labelList& offsets() const; 00086 00087 00088 // Queries relating to my processor 00089 00090 //- my local size 00091 inline label localSize() const; 00092 00093 //- From local to global 00094 inline label toGlobal(const label i) const; 00095 00096 //- Is on local processor 00097 inline bool isLocal(const label i) const; 00098 00099 //- From global to local on current processor. 00100 // FatalError if not on local processor. 00101 inline label toLocal(const label i) const; 00102 00103 00104 // Global queries 00105 00106 //- Global sum of localSizes 00107 inline label size() const; 00108 00109 //- Size of procI data 00110 inline label localSize(const label procI) const; 00111 00112 //- From local to global on procI 00113 inline label toGlobal(const label procI, const label i) const; 00114 00115 //- Is on processor procI 00116 inline bool isLocal(const label procI, const label i) const; 00117 00118 //- From global to local on procI 00119 inline label toLocal(const label procI, const label i) const; 00120 00121 //- Which processor does global come from? Binary search. 00122 inline label whichProcID(const label i) const; 00123 00124 //- Start of procI data 00125 inline label offset(const label procI) const; 00126 00127 00128 00129 // IOstream Operators 00130 00131 friend Istream& operator>>(Istream& is, globalIndex& gi); 00132 friend Ostream& operator<<(Ostream& os, const globalIndex& gi); 00133 }; 00134 00135 00136 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00137 00138 } // End namespace Foam 00139 00140 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00141 00142 #include "globalIndexI.H" 00143 00144 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00145 00146 #endif 00147 00148 // ************************************************************************* // |