diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index 0faefed09c..b0e2f003e5 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -47,6 +47,7 @@ $(ints)/int64/int64IO.C $(ints)/int/intIO.C $(ints)/label/label.C $(ints)/uLabel/uLabel.C +$(ints)/lists/labelList.C $(ints)/lists/labelIOList.C $(ints)/lists/labelListIOList.C diff --git a/src/OpenFOAM/containers/Lists/List/List.H b/src/OpenFOAM/containers/Lists/List/List.H index 6ab194b368..332b3fbc4e 100644 --- a/src/OpenFOAM/containers/Lists/List/List.H +++ b/src/OpenFOAM/containers/Lists/List/List.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2017-2019 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -346,6 +346,11 @@ public: // * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * * // +//- Create identity map of the given length with (map[i] == i) +// Optionally with an alternative start index, so that (map[i] == i+start) +labelList identity(const label len, label start=0); + + //- Hashing for List data, which uses Hasher for contiguous data and //- element-wise incrementally hashing otherwise. template diff --git a/src/OpenFOAM/containers/Lists/ListOps/ListOps.C b/src/OpenFOAM/containers/Lists/ListOps/ListOps.C index 4bca347959..49c7de5a30 100644 --- a/src/OpenFOAM/containers/Lists/ListOps/ListOps.C +++ b/src/OpenFOAM/containers/Lists/ListOps/ListOps.C @@ -24,12 +24,6 @@ License \*---------------------------------------------------------------------------*/ #include "ListOps.H" -#include - -// * * * * * * * * * * * * * * Global Data Members * * * * * * * * * * * * * // - -const Foam::labelList Foam::emptyLabelList; - // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // @@ -47,6 +41,16 @@ Foam::labelList Foam::invert if (newIdx >= 0) { + #ifdef FULLDEBUG + if (newIdx >= len) + { + FatalErrorInFunction + << "Inverse location " << newIdx + << " is out of range. List has size " << len + << abort(FatalError); + } + #endif + if (inverse[newIdx] >= 0) { FatalErrorInFunction @@ -76,7 +80,7 @@ Foam::labelListList Foam::invertOneToMany { if (newIdx >= 0) { - sizes[newIdx]++; + ++sizes[newIdx]; } } @@ -102,15 +106,6 @@ Foam::labelListList Foam::invertOneToMany } -Foam::labelList Foam::identity(const label len, label start) -{ - labelList map(len); - std::iota(map.begin(), map.end(), start); - - return map; -} - - Foam::bitSet Foam::reorder ( const labelUList& oldToNew, diff --git a/src/OpenFOAM/containers/Lists/ListOps/ListOps.H b/src/OpenFOAM/containers/Lists/ListOps/ListOps.H index 12ae68cc8f..a7b5bd7fb6 100644 --- a/src/OpenFOAM/containers/Lists/ListOps/ListOps.H +++ b/src/OpenFOAM/containers/Lists/ListOps/ListOps.H @@ -55,17 +55,6 @@ SourceFiles namespace Foam { -//- Deprecated(2018-07) reference to zero-sized list. -// Compare to List::null() which returns null pointer cast as list reference. -// -// \deprecated(2018-07) This cast is disallowed with many modern compilers -template -static const List& emptyList() -{ - return *reinterpret_cast*>(&emptyLabelList); -} - - //- Renumber the values (not the indices) of a list. // Negative IntListType elements are left untouched. template @@ -372,9 +361,6 @@ List invertManyToMany return output; } -//- Create identity map of the given length with (map[i] == i) -// Optionally with an alternative start index, so that (map[i] == i+start) -labelList identity(const label len, label start=0); //- Deprecated(2017-10) search for first occurence of the given element. // \return The index found or return -1 if not found. diff --git a/src/OpenFOAM/primitives/ints/lists/labelList.C b/src/OpenFOAM/primitives/ints/lists/labelList.C new file mode 100644 index 0000000000..175502437b --- /dev/null +++ b/src/OpenFOAM/primitives/ints/lists/labelList.C @@ -0,0 +1,45 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2019 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +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 "List.H" +#include + +// * * * * * * * * * * * * * * Global Data Members * * * * * * * * * * * * * // + +const Foam::labelList Foam::emptyLabelList; + + +// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // + +Foam::labelList Foam::identity(const label len, label start) +{ + labelList map(len); + std::iota(map.begin(), map.end(), start); + + return map; +} + + +// ************************************************************************* //