diff --git a/applications/test/PackedList3/Make/files b/applications/test/PackedList3/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..0e119bc4f3607667e19f34ff2eac8556ae18c7ee --- /dev/null +++ b/applications/test/PackedList3/Make/files @@ -0,0 +1,3 @@ +PackedListTest3.C + +EXE = $(FOAM_USER_APPBIN)/PackedListTest3 diff --git a/applications/test/PackedList3/Make/options b/applications/test/PackedList3/Make/options new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/applications/test/PackedList3/PackedListTest3.C b/applications/test/PackedList3/PackedListTest3.C new file mode 100644 index 0000000000000000000000000000000000000000..9b5b60a118517cdaaa689b02c0298d37ba005088 --- /dev/null +++ b/applications/test/PackedList3/PackedListTest3.C @@ -0,0 +1,75 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Application + +Description + +\*---------------------------------------------------------------------------*/ + +#include "argList.H" +#include "boolList.H" +#include "HashSet.H" +#include "StaticHashTable.H" +#include "cpuTime.H" +#include <vector> +#include "PackedList.H" +#include "PackedBoolList.H" + +using namespace Foam; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + +// Main program: + +int main(int argc, char *argv[]) +{ + const label n = 100000000; + const label nReport = 1000000; + + cpuTime timer; + + // test inserts + // PackedBoolList + PackedBoolList packed; + for (label i = 0; i < n; i++) + { + if ((i % nReport) == 0 && i) + { + Info<< "i:" << i << " in " << timer.cpuTimeIncrement() << " s" + <<endl; + } + packed[i] = 1; + } + Info<< "insert test: " << n << " elements in " + << timer.cpuTimeIncrement() << " s\n\n"; + + Info << "\nEnd\n" << endl; + + return 0; +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/containers/Lists/PackedList/PackedListI.H b/src/OpenFOAM/containers/Lists/PackedList/PackedListI.H index 92d6c02d72dc71aa6e7bea80fcefe156cf441f73..ee993e28dfa787f2a4b216d962552b77415aaa5f 100644 --- a/src/OpenFOAM/containers/Lists/PackedList/PackedListI.H +++ b/src/OpenFOAM/containers/Lists/PackedList/PackedListI.H @@ -670,7 +670,16 @@ inline void Foam::PackedList<nBits>::reserve // need more capacity? if (len > StorageList::size()) { - StorageList::setSize(len, 0u); + // Like DynamicList with SizeInc=0, SizeMult=2, SizeDiv=1 + StorageList::setSize + ( + max + ( + len, + StorageList::size()*2 + ), + 0u + ); } }