/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2018-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. OpenFOAM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . \*---------------------------------------------------------------------------*/ #include "ListOps.H" #include "labelRange.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // inline Foam::globalIndex::globalIndex ( const labelUList& listOffsets ) { if (listOffsets.size() > 1) { offsets_ = listOffsets; } } inline Foam::globalIndex::globalIndex ( labelList&& listOffsets ) { if (listOffsets.size() > 1) { offsets_.transfer(listOffsets); } else { listOffsets.clear(); } } inline Foam::globalIndex::globalIndex ( const labelUList& offsetsOrSizes, enum globalIndex::accessType accType ) { if (accType == accessType::SIZES) { reset(offsetsOrSizes); } else if (offsetsOrSizes.size() > 1) { // accessType::OFFSETS offsets_ = offsetsOrSizes; } } inline Foam::globalIndex::globalIndex(const label localSize) { reset(localSize); } inline Foam::globalIndex::globalIndex ( const label localSize, const globalIndex::gatherOnly, const label comm ) { // Gather sizes (one-sided) reset(UPstream::listGatherValues(localSize, comm)); } inline Foam::globalIndex::globalIndex ( const label localSize, const globalIndex::gatherNone, const label /* comm (ignored) */ ) : offsets_(2) { offsets_[0] = 0; offsets_[1] = localSize; } inline Foam::globalIndex::globalIndex ( const label localSize, const int tag, const label comm, const bool parallel ) { reset(localSize, tag, comm, parallel); } // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // inline bool Foam::globalIndex::empty() const { return offsets_.empty() || offsets_.last() == 0; } inline Foam::label Foam::globalIndex::totalSize() const { const label len = (offsets_.size() - 1); return (len < 1) ? static_cast