mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
- provide a globalIndex::calcOffsets() taking an indirect list, which
enables convenient offsets calculation from a variety of inputs.
- new CompactListList unpack variant: copy_unpack()
The copy_unpack() works somewhat like std::copy() in that it writes
the generated sublists to iterator positions, which makes this
type of code possible:
CompactListList<label> compact = ...;
DynamicList<face> extracted;
compact.copy_unpack<face>
(
std::back_inserter(extracted),
labelRange(4, 10)
);
-and-
const label nOldFaces = allFaces.size();
allFaces.resize(allFaces + nNewFaces);
auto iter = allFaces.begin(nOldFaces);
iter = compact.copy_unpack<face>(iter, /* selection 1 */);
...
iter = compact.copy_unpack<face>(iter, /* selection 2 */);
ENH: globalIndex resize()
- can be used to shrink or grow the offsets table.
Any extension of the offsets table corresponds to 'slots'
with 0 local size.
96 lines
2.8 KiB
C++
96 lines
2.8 KiB
C++
/*---------------------------------------------------------------------------*\
|
|
========= |
|
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
\\ / O peration |
|
|
\\ / A nd | www.openfoam.com
|
|
\\/ M anipulation |
|
|
-------------------------------------------------------------------------------
|
|
Copyright (C) 2023 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 <http://www.gnu.org/licenses/>.
|
|
|
|
Application
|
|
Test-globalIndex2
|
|
|
|
Description
|
|
More functional tests for the globalIndex class.
|
|
|
|
\*---------------------------------------------------------------------------*/
|
|
|
|
#include "globalIndex.H"
|
|
#include "argList.H"
|
|
#include "Time.H"
|
|
#include "IOstreams.H"
|
|
#include "Random.H"
|
|
#include "IndirectList.H"
|
|
#include "SliceList.H"
|
|
|
|
using namespace Foam;
|
|
|
|
|
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
// Main program:
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
Random rnd(123456);
|
|
|
|
// #include "setRootCase.H"
|
|
// #include "createTime.H"
|
|
|
|
Info<< nl
|
|
<< "simple globalIndex tests" << nl << nl;
|
|
|
|
Info<< "Construct from indirect list(s)" << nl;
|
|
{
|
|
// Some sizes
|
|
labelList rawSizes(25);
|
|
forAll(rawSizes, i)
|
|
{
|
|
rawSizes[i] = rnd.position<label>(0, 100);
|
|
}
|
|
|
|
Info<< nl
|
|
<< "plain sizes: "
|
|
<< flatOutput(rawSizes) << nl
|
|
<< " offsets: "
|
|
<< flatOutput(globalIndex::calcOffsets(rawSizes))
|
|
<< nl;
|
|
|
|
|
|
sliceRange slice(0, 5, 5);
|
|
Info<< nl
|
|
<< "range min/max " << slice.min() << '/' << slice.max() << nl;
|
|
|
|
SliceList<label> sliceSizes(rawSizes, slice);
|
|
|
|
Info<< nl
|
|
<< "indirect addr: " << sliceSizes.addressing() << nl
|
|
<< "indirect sizes: "
|
|
<< flatOutput(sliceSizes) << nl
|
|
<< " offsets: "
|
|
<< flatOutput(globalIndex::calcOffsets(sliceSizes))
|
|
<< nl;
|
|
}
|
|
|
|
Info<< "\nEnd\n" << endl;
|
|
return 0;
|
|
}
|
|
|
|
|
|
// ************************************************************************* //
|