ENH: return UList range slice as a SubList

- previously returned the range slice as a UList,
  but this prevents convenient assignment.
  Apply similar handling for Field/SubField

  Allows the following

     labelRange range(...);
     fullList.slice(range) = identity(range.size());

  and

     fullList.slice(range) = UIndirectList<T>(other, addr);

ENH: create SubList from full FixedList (simplifies interface)

- allow default constructed SubList. Use shallowCopy to 'reset' later
This commit is contained in:
Mark Olesen
2021-10-21 17:35:03 +02:00
parent 3781f17eee
commit e2861cc200
14 changed files with 269 additions and 96 deletions

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016 Shell Research Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
Copyright (C) 2019-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -269,7 +269,7 @@ int main(int argc, char* argv[])
{
Info<< " negative blocks: " << origBlocks.size() << nl;
for (const PDRobstacle& obs : obstacles[origBlocks])
for (const PDRobstacle& obs : obstacles.slice(origBlocks))
{
arr.addBlockage(obs, patches, -1);
}
@ -282,7 +282,7 @@ int main(int argc, char* argv[])
{
Info<< " blocks " << interBlocks.size() << nl;
for (const PDRobstacle& obs : obstacles[interBlocks])
for (const PDRobstacle& obs : obstacles.slice(interBlocks))
{
arr.addBlockage(obs, patches, 0);
}
@ -293,7 +293,7 @@ int main(int argc, char* argv[])
{
Info<< " positive blocks: " << origBlocks.size() << nl;
for (const PDRobstacle& obs : obstacles[origBlocks])
for (const PDRobstacle& obs : obstacles.slice(origBlocks))
{
arr.addBlockage(obs, patches, 1);
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016 Shell Research Ltd.
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -405,7 +405,7 @@ scalar block_overlap
// Sort blocks by their x-position (with sortBias)
labelList blkOrder;
sortedOrder(blocks[range], blkOrder);
sortedOrder(blocks.slice(range), blkOrder);
DynamicList<PDRobstacle> newBlocks;
@ -510,7 +510,7 @@ scalar block_cylinder_overlap
// Sort blocks and cylinders by their x-position (with sortBias)
labelList blkOrder;
sortedOrder(blocks[range], blkOrder);
sortedOrder(blocks.slice(range), blkOrder);
labelList cylOrder;
sortedOrder(cylinders, cylOrder);