Foam::ListListOps Namespace Reference

Various utility functions to work on Lists of Lists (usually resulting from 'gather'ing and combining information from individual processors) More...

Functions

template<class AccessType , class T , class AccessOp >
AccessType combine (const List< T > &, AccessOp aop=accessOp< T >())
 Combines sublists into one big list. More...
 
template<class T , class AccessOp >
labelList subSizes (const List< T > &, AccessOp aop=accessOp< T >())
 Gets sizes of sublists. More...
 
template<class AccessType , class T , class AccessOp , class OffsetOp >
AccessType combineOffset (const List< T > &, const labelList &sizes, AccessOp aop, OffsetOp oop=offsetOp< T >())
 Like combine but also offsets sublists based on passed sizes. More...
 

Detailed Description

Various utility functions to work on Lists of Lists (usually resulting from 'gather'ing and combining information from individual processors)

  • combine :
    takes (elements of) sublists and appends them into one big list.
  • combineOffset :
    similar and also adds offset.

The access of data is through an AccessOp so that data can be 'gather'ed in one go, minimising communication, and then picked apart and recombined.

Example:

// Assuming myContainer defined which holds all the data I want to
// transfer (say a pointField and a faceList). myContainer also defines
// access operators to
// access the individual elements, say myContainerPoints::operator(),
// and myContainerFaces::operator()
List<myContainer> gatheredData(Pstream::nProcs());
gatheredData[Pstream::myProcNo()] = myContainer(points, faces);
// Gather data onto master
Pstream::gatherList(gatheredData);
// Combine
pointField combinedPoints
(
ListListOps::combine<pointField>
(
gatheredData,
myContainerPoints()
)
);
// Combine and renumber (so combinedFaces indexes combinedPoints)
// Extract sizes of individual lists
labelList sizes
(
ListListOps::subSizes(gatheredData, myContainerPoints())
);
// Renumber using user-defined operator offsetOp<face>()
faceList combinedFaces
(
ListListOps::combineOffset<faceList>
(
gatheredData, sizes, myContainerFaces(), offsetOp<face>()
)
);
static void gatherList(const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
Gather data but keep individual values separate.
static label nProcs(const label communicator=0)
Number of processes in parallel run.
Definition: UPstream.H:411
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
Definition: UPstream.H:429
const pointField & points
labelList subSizes(const List< T > &, AccessOp aop=accessOp< T >())
Gets sizes of sublists.
Definition: ListListOps.C:61
List< label > labelList
A List of labels.
Definition: labelList.H:56
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:42
List< face > faceList
Definition: faceListFwd.H:43
Source files

Function Documentation

◆ combine()

AccessType combine ( const List< T > &  lst,
AccessOp  aop = accessOp<T>() 
)

Combines sublists into one big list.

Definition at line 34 of file ListListOps.C.

References forAll, Foam::sum(), and Foam::T().

Referenced by coordSet::gather(), and sampledSurfaces::sampleType().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ subSizes()

labelList subSizes ( const List< T > &  lst,
AccessOp  aop = accessOp<T>() 
)

Gets sizes of sublists.

Definition at line 61 of file ListListOps.C.

References forAll, and List< T >::size().

Referenced by cutPolyIsoSurface::cutPolyIsoSurface(), and PatchTools::gatherAndMerge().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ combineOffset()

AccessType combineOffset ( const List< T > &  lst,
const labelList sizes,
AccessOp  aop,
OffsetOp  oop = offsetOp<T>() 
)

Like combine but also offsets sublists based on passed sizes.

Definition at line 74 of file ListListOps.C.

References forAll, Foam::offset(), Foam::sum(), and Foam::T().

Here is the call graph for this function: