ENH: add simplified gather methods for globalIndex with default communicator

- when combining lists in processor order this simplifies code and
  reduces memory overhead.

  Write this:
    ----
    labelList collected;

    const globalIndex sizing(input.size());
    sizing.gather(input, collected);
    ----

  OR

    ----
    labelList collected;
    globalIndex::gatherOp(input, collected);
    ----

  Instead of this:

    ----
    labelList collected;

    List<labelList> scratch(Pstream::nProcs());
    scratch[Pstream::myProcNo()] = input;
    Pstream::gatherList(scratch);

    if (Pstream::master())
    {
        collected = ListListOps::combine<labelList>
        (
            scratch,
            accessOp<labelList>()
        );
    }
    scratch.clear();
    ----
This commit is contained in:
Mark Olesen
2019-01-16 21:33:06 +01:00
parent f19150cd32
commit f498d09dbf
9 changed files with 236 additions and 131 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -237,17 +237,7 @@ void Foam::functionObjects::AMIWeights::writeWeightField
// Collect field
scalarField mergedWeights;
globalFaces().gather
(
UPstream::worldComm,
ListOps::create<label>
(
UPstream::procID(UPstream::worldComm),
labelOp<int>() // int -> label
),
weightSum,
mergedWeights
);
globalFaces().gather(weightSum, mergedWeights);
const bool isACMI = isA<cyclicACMIPolyPatch>(cpp);
@ -256,17 +246,7 @@ void Foam::functionObjects::AMIWeights::writeWeightField
{
const cyclicACMIPolyPatch& pp = refCast<const cyclicACMIPolyPatch>(cpp);
globalFaces().gather
(
UPstream::worldComm,
ListOps::create<label>
(
UPstream::procID(UPstream::worldComm),
labelOp<int>() // int -> label
),
pp.mask(),
mergedMask
);
globalFaces().gather(pp.mask(), mergedMask);
}
if (Pstream::master())