1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
28 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
30 //inline const Foam::labelList& Foam::globalIndex::offsets() const
36 inline Foam::label Foam::globalIndex::offset(const label procI) const
38 return (procI == 0 ? 0 : offsets_[procI-1]);
42 inline Foam::label Foam::globalIndex::localSize(const label procI) const
48 : offsets_[procI] - offsets_[procI-1]
53 inline Foam::label Foam::globalIndex::localSize() const
55 return localSize(Pstream::myProcNo());
59 inline Foam::label Foam::globalIndex::size() const
61 return offsets_[Pstream::nProcs()-1];
65 inline Foam::label Foam::globalIndex::toGlobal
71 return(procI == 0 ? i : i + offsets_[procI-1]);
75 inline Foam::label Foam::globalIndex::toGlobal(const label i) const
77 return toGlobal(Pstream::myProcNo(), i);
81 //- Is on local processor
82 inline bool Foam::globalIndex::isLocal(const label procI, const label i) const
86 && (i >= (procI == 0 ? 0 : offsets_[procI-1]));
90 inline bool Foam::globalIndex::isLocal(const label i) const
92 return isLocal(Pstream::myProcNo(), i);
96 inline Foam::label Foam::globalIndex::toLocal(const label procI, const label i)
99 label localI = (procI == 0 ? i : i - offsets_[procI-1]);
101 if (localI < 0 || i >= offsets_[procI])
103 FatalErrorIn("globalIndex::toLocal(const label, const label)")
104 << "Global " << i << " does not belong on processor "
105 << procI << endl << "Offsets:" << offsets_
106 << abort(FatalError);
112 inline Foam::label Foam::globalIndex::toLocal(const label i) const
114 return toLocal(Pstream::myProcNo(), i);
118 inline Foam::label Foam::globalIndex::whichProcID(const label i) const
120 label index = findLower(offsets_, i+1);
122 if (index == Pstream::nProcs()-1)
124 FatalErrorIn("globalIndex::whichProcID(const label)")
125 << "Global " << i << " does not belong on any processor."
126 << " Offsets:" << offsets_
127 << abort(FatalError);
134 // ************************************************************************* //