Loading...
Searching...
No Matches
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 T, class Addr, class AccessOp>
labelList subSizes (const IndirectListBase< T, Addr > &lists, AccessOp aop)
 Return the sizes of the sub-lists.
template<class IntListType>
void inplaceRenumber (const labelUList &oldToNew, IntListType &lists)
 Inplace renumber the values (not the indices) of a list of lists.
template<class T, class AccessOp>
labelList subSizes (const UList< T > &lists, AccessOp aop=accessOp< T >())
 Return the sizes of the sub-lists.
template<class T, class AccessOp>
label sumSizes (const UList< T > &lists, AccessOp aop=accessOp< T >())
 The total size of all sub-lists.
template<class AccessType, class T, class AccessOp>
AccessType combine (const UList< T > &lists, AccessOp aop=accessOp< T >())
 Combines sub-lists into a single list.
template<class AccessType, class T, class AccessOp, class OffsetOp>
AccessType combineOffset (const UList< T > &lists, const labelUList &offsets, AccessOp aop, OffsetOp oop=offsetOp< T >())
 Like combine but also offsets sublists based on passed sizes.

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, minimizing 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()
gatheredData[Pstream::myProcNo()] = myContainer(points, faces);
// Gather data onto master
Pstream::gatherList(gatheredData);
// Combine
pointField combinedPoints
(
(
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
(
(
gatheredData, sizes, myContainerFaces(), offsetOp<face>()
)
);
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition List.H:72
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Negative if the process is not a...
Definition UPstream.H:1706
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run.
Definition UPstream.H:1697
@ gatherList
gatherList [manual algorithm]
Definition UPstream.H:194
const pointField & points
labelList subSizes(const IndirectListBase< T, Addr > &lists, AccessOp aop)
Return the sizes of the sub-lists.
AccessType combineOffset(const UList< T > &lists, const labelUList &offsets, AccessOp aop, OffsetOp oop=offsetOp< T >())
Like combine but also offsets sublists based on passed sizes.
Definition ListListOps.C:92
AccessType combine(const UList< T > &lists, AccessOp aop=accessOp< T >())
Combines sub-lists into a single list.
Definition ListListOps.C:62
List< label > labelList
A List of labels.
Definition List.H:62
List< face > faceList
List of faces.
Definition faceListFwd.H:41
vectorField pointField
pointField is a vectorField.
Offset operator for ListListOps::combineOffset().
Source files

Function Documentation

◆ subSizes() [1/2]

template<class T, class Addr, class AccessOp>
labelList subSizes ( const IndirectListBase< T, Addr > & lists,
AccessOp aop )

Return the sizes of the sub-lists.

Definition at line 66 of file ensightOutput.H.

References UList< T >::begin(), IndirectListBase< T, Addr >::size(), and Foam::T().

Here is the call graph for this function:

◆ inplaceRenumber()

template<class IntListType>
void inplaceRenumber ( const labelUList & oldToNew,
IntListType & lists )

Inplace renumber the values (not the indices) of a list of lists.

Negative IntListType elements are left untouched.

Definition at line 91 of file ensightOutput.H.

Referenced by ensightFaces::write().

Here is the caller graph for this function:

◆ subSizes() [2/2]

template<class T, class AccessOp>
labelList subSizes ( const UList< T > & lists,
AccessOp aop = accessOpT >() )

Return the sizes of the sub-lists.

◆ sumSizes()

template<class T, class AccessOp>
label sumSizes ( const UList< T > & lists,
AccessOp aop = accessOpT >() )

The total size of all sub-lists.

◆ combine()

◆ combineOffset()

template<class AccessType, class T, class AccessOp, class OffsetOp>
AccessType combineOffset ( const UList< T > & lists,
const labelUList & offsets,
AccessOp aop,
OffsetOp oop = offsetOp<T>() )

Like combine but also offsets sublists based on passed sizes.

Definition at line 91 of file ListListOps.C.

References UList< T >::begin(), and Foam::T().

Here is the call graph for this function: