ENH: added IndirectSubList

- provides an indirect access to a sub-section of a list that is
  somewhat less efficient than a Foam::SubList, but supports the
  following:
    * adjustment of its addressing range after construction
    * recovery of the original, underlying list at any time

  This can be more convenient for some coding cases.
  For example,

      template<class Addr>
      void renumberFaces(IndirectListBase<face, Addr>& faces, ...);

  which can be called for

      * Specific faces:
        UIndirectList<face>(mesh.faces(), facesToChange)

      * A sub-range of faces:
        IndirectSubList<face>(mesh.faces(), pp.range())

      * All faces:
        IndirectSubList<face>(mesh.faces())

CONFIG: added IndirectListsFwd.H with some common forwarding
This commit is contained in:
Mark Olesen
2020-01-31 17:01:22 +01:00
parent 9c85d40cc6
commit 822d052e32
12 changed files with 267 additions and 43 deletions

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -31,8 +31,9 @@ Description
#include "labelList.H"
#include "FixedList.H"
#include "sliceRange.H"
#include "SliceList.H"
#include "IndirectList.H"
#include "IndirectSubList.H"
#include "SliceList.H"
#include "Random.H"
using namespace Foam;
@ -146,6 +147,23 @@ int main(int argc, char *argv[])
Info<< nl << "Random list: " << flatOutput(list1) << nl;
{
IndirectSubList<scalar> sublist1(list1, labelRange(0, 10));
Info<< nl << "SubList: " << sublist1.addressing() << " = "
<< flatOutput(sublist1) << nl;
// Adjust addressing
sublist1.addressing().reset(5, 8);
// This should resolve as a no-op
sublist1 = sublist1;
Info<< "SubList: " << sublist1.addressing() << " = "
<< flatOutput(sublist1) << nl;
}
SliceList<scalar> slice1(list1, sliceRange(0, 15, 3));
Info<< nl << "slicing with: " << slice1.addressing() << nl;