distributionMap Class Reference

Class containing processor-to-processor mapping information. More...

Inheritance diagram for distributionMap:
Collaboration diagram for distributionMap:

Classes

class  transform
 Default transformation behaviour. More...
 
class  transformPosition
 Default transformation behaviour for position. More...
 

Public Member Functions

 ClassName ("distributionMap")
 
 distributionMap ()
 Construct null. More...
 
 distributionMap (const label constructSize, labelListList &&subMap, labelListList &&constructMap, const bool subHasFlip=false, const bool constructHasFlip=false)
 Construct from components. More...
 
 distributionMap (const label constructSize, labelListList &&subMap, labelListList &&constructMap, labelListList &&transformElements, labelList &&transformStart, const bool subHasFlip=false, const bool constructHasFlip=false)
 Construct from components. More...
 
 distributionMap (const labelList &sendProcs, const labelList &recvProcs)
 Construct from reverse addressing: per data item the send. More...
 
 distributionMap (const globalIndex &, labelList &elements, List< Map< label >> &compactMap, const int tag=Pstream::msgType())
 Construct from list of (possibly) remote elements in globalIndex. More...
 
 distributionMap (const globalIndex &, labelListList &cellCells, List< Map< label >> &compactMap, const int tag=Pstream::msgType())
 Special variant that works with the info sorted into bins. More...
 
 distributionMap (const globalIndex &, labelList &untransformedElements, const globalIndexAndTransform &, const labelPairList &transformedElements, labelList &transformedIndices, List< Map< label >> &compactMap, const int tag=Pstream::msgType())
 Construct from list of (possibly remote) untransformed elements. More...
 
 distributionMap (const globalIndex &, labelListList &cellCells, const globalIndexAndTransform &, const List< labelPairList > &transformedElements, labelListList &transformedIndices, List< Map< label >> &compactMap, const int tag=Pstream::msgType())
 As above but with ListLists. More...
 
 distributionMap (const distributionMap &)
 Copy constructor. More...
 
 distributionMap (distributionMap &&)
 Move constructor. More...
 
 distributionMap (Istream &)
 Construct from Istream. More...
 
autoPtr< distributionMapclone () const
 Clone. More...
 
virtual ~distributionMap ()
 Destructor. More...
 
const labelListListtransformElements () const
 For every globalIndexAndTransform::transformPermutations. More...
 
const labelListtransformStart () const
 Destination in constructMap for transformed elements. More...
 
label whichTransform (const label index) const
 Find transform from transformElements. More...
 
void transfer (distributionMap &)
 Transfer the contents of the argument and annul the argument. More...
 
template<class T >
void distribute (List< T > &fld, const bool dummyTransform=true, const int tag=UPstream::msgType()) const
 Distribute data using default commsType. More...
 
template<class T , class negateOp >
void distribute (List< T > &fld, const negateOp &negOp, const bool dummyTransform=true, const int tag=UPstream::msgType()) const
 Distribute data using default commsType. More...
 
template<class T >
void distribute (DynamicList< T > &fld, const bool dummyTransform=true, const int tag=UPstream::msgType()) const
 Distribute data using default commsType. More...
 
template<class T >
void reverseDistribute (const label constructSize, List< T > &, const bool dummyTransform=true, const int tag=UPstream::msgType()) const
 Reverse distribute data using default commsType. More...
 
template<class T >
void reverseDistribute (const label constructSize, const T &nullValue, List< T > &fld, const bool dummyTransform=true, const int tag=UPstream::msgType()) const
 Reverse distribute data using default commsType. More...
 
template<class T , class TransformOp >
void distribute (const globalIndexAndTransform &, List< T > &fld, const TransformOp &top, const int tag=UPstream::msgType()) const
 Distribute with transforms. More...
 
template<class T , class TransformOp >
void reverseDistribute (const globalIndexAndTransform &, const label constructSize, List< T > &fld, const TransformOp &top, const int tag=UPstream::msgType()) const
 Reverse distribute with transforms. More...
 
template<class T , class TransformOp >
void reverseDistribute (const globalIndexAndTransform &, const label constructSize, const T &nullValue, List< T > &fld, const TransformOp &top, const int tag=UPstream::msgType()) const
 Reverse distribute with transforms. More...
 
void printLayout (Ostream &os) const
 Debug: print layout. Can only be used on maps with sorted. More...
 
void operator= (const distributionMap &)
 
- Public Member Functions inherited from distributionMapBase
 ClassName ("distributionMapBase")
 
 distributionMapBase ()
 Construct null. More...
 
 distributionMapBase (const label constructSize, const labelListList &&subMap, const labelListList &&constructMap, const bool subHasFlip=false, const bool constructHasFlip=false)
 Move construct from components. More...
 
 distributionMapBase (const labelList &sendProcs, const labelList &recvProcs)
 Construct from reverse addressing: per data item the send. More...
 
 distributionMapBase (const globalIndex &, labelList &elements, List< Map< label >> &compactMap, const int tag=Pstream::msgType())
 Construct from list of (possibly) remote elements in globalIndex. More...
 
 distributionMapBase (const globalIndex &, labelListList &cellCells, List< Map< label >> &compactMap, const int tag=Pstream::msgType())
 Special variant that works with the info sorted into bins. More...
 
 distributionMapBase (const distributionMapBase &)
 Construct copy. More...
 
 distributionMapBase (distributionMapBase &&)
 Move constructor. More...
 
 distributionMapBase (Istream &)
 Construct from Istream. More...
 
label constructSize () const
 Constructed data size. More...
 
labelconstructSize ()
 Constructed data size. More...
 
const labelListListsubMap () const
 From subsetted data back to original data. More...
 
labelListListsubMap ()
 From subsetted data back to original data. More...
 
const labelListListconstructMap () const
 From subsetted data to new reconstructed data. More...
 
labelListListconstructMap ()
 From subsetted data to new reconstructed data. More...
 
bool subHasFlip () const
 Does subMap include a sign. More...
 
bool & subHasFlip ()
 Does subMap include a sign. More...
 
bool constructHasFlip () const
 Does constructMap include a sign. More...
 
bool & constructHasFlip ()
 Does constructMap include a sign. More...
 
const List< labelPair > & schedule () const
 Return a schedule. Demand driven. See above. More...
 
void transfer (distributionMapBase &)
 Transfer the contents of the argument and annul the argument. More...
 
void compact (const boolList &elemIsUsed, const int tag=UPstream::msgType())
 Compact maps. Gets per field a bool whether it is used (locally) More...
 
void compact (const boolList &elemIsUsed, const label localSize, labelList &oldToNewSub, labelList &oldToNewConstruct, const int tag=UPstream::msgType())
 Compact all maps and layout. Returns compaction maps for. More...
 
template<class T >
void distribute (List< T > &fld, const int tag=UPstream::msgType()) const
 Distribute data using default commsType. More...
 
template<class T , class negateOp >
void distribute (List< T > &fld, const negateOp &negOp, const int tag=UPstream::msgType()) const
 Distribute data using default commsType. More...
 
template<class T >
void distribute (DynamicList< T > &fld, const int tag=UPstream::msgType()) const
 Distribute data using default commsType. More...
 
template<class T >
void reverseDistribute (const label constructSize, List< T > &, const int tag=UPstream::msgType()) const
 Reverse distribute data using default commsType. More...
 
template<class T >
void reverseDistribute (const label constructSize, const T &nullValue, List< T > &fld, const int tag=UPstream::msgType()) const
 Reverse distribute data using default commsType. More...
 
template<class T >
void send (PstreamBuffers &, const List< T > &) const
 Do all sends using PstreamBuffers. More...
 
template<class T >
void receive (PstreamBuffers &, List< T > &) const
 Do all receives using PstreamBuffers. More...
 
void printLayout (Ostream &os) const
 Debug: print layout. Can only be used on maps with sorted. More...
 
void operator= (const distributionMapBase &)
 
void operator= (distributionMapBase &&)
 

Friends

Istreamoperator>> (Istream &, distributionMap &)
 Read dictionary from Istream. More...
 
Ostreamoperator<< (Ostream &, const distributionMap &)
 Write dictionary to Ostream. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from distributionMapBase
static List< labelPairschedule (const labelListList &subMap, const labelListList &constructMap, const int tag)
 Calculate a schedule. See above. More...
 
static label renumber (const globalIndex &, const List< Map< label >> &compactMap, const label globalElement)
 Helper for construct from globalIndex. Renumbers element. More...
 
template<class T , class negateOp >
static void distribute (const Pstream::commsTypes commsType, const List< labelPair > &schedule, const label constructSize, const labelListList &subMap, const bool subHasFlip, const labelListList &constructMap, const bool constructHasFlip, List< T > &, const negateOp &negOp, const int tag=UPstream::msgType())
 Distribute data. Note:schedule only used for. More...
 
template<class T , class CombineOp , class negateOp >
static void distribute (const Pstream::commsTypes commsType, const List< labelPair > &schedule, const label constructSize, const labelListList &subMap, const bool subHasFlip, const labelListList &constructMap, const bool constructHasFlip, List< T > &, const CombineOp &cop, const negateOp &negOp, const T &nullValue, const int tag=UPstream::msgType())
 Distribute data. If multiple processors writing to same. More...
 
- Protected Member Functions inherited from distributionMapBase
void calcCompactAddressing (const globalIndex &globalNumbering, const labelList &elements, List< Map< label >> &compactMap) const
 Construct per processor compact addressing of the global elements. More...
 
void calcCompactAddressing (const globalIndex &globalNumbering, const labelListList &elements, List< Map< label >> &compactMap) const
 
void exchangeAddressing (const int tag, const globalIndex &globalNumbering, labelList &elements, List< Map< label >> &compactMap, labelList &compactStart)
 
void exchangeAddressing (const int tag, const globalIndex &globalNumbering, labelListList &elements, List< Map< label >> &compactMap, labelList &compactStart)
 
- Static Protected Member Functions inherited from distributionMapBase
static void checkReceivedSize (const label proci, const label expectedSize, const label receivedSize)
 
template<class T , class CombineOp , class negateOp >
static void flipAndCombine (const UList< label > &map, const bool hasFlip, const UList< T > &rhs, const CombineOp &cop, const negateOp &negOp, List< T > &lhs)
 
template<class T , class negateOp >
static T accessAndFlip (const UList< T > &fld, const label index, const bool hasFlip, const negateOp &negOp)
 
- Protected Attributes inherited from distributionMapBase
label constructSize_
 Size of reconstructed data. More...
 
labelListList subMap_
 Maps from subsetted data back to original data. More...
 
labelListList constructMap_
 Maps from subsetted data to new reconstructed data. More...
 
bool subHasFlip_
 Whether subMap includes flip or not. More...
 
bool constructHasFlip_
 Whether constructMap includes flip or not. More...
 
autoPtr< List< labelPair > > schedulePtr_
 Schedule. More...
 

Detailed Description

Class containing processor-to-processor mapping information.

We store mapping from the bits-to-send to the complete starting list (subXXXMap) and from the received bits to their location in the new list (constructXXXMap).

Schedule is a list of processor pairs (one send, one receive. One of them will be myself) which forms a scheduled (i.e. non-buffered) exchange. See distribute on how to use it. Note2: number of items sent on one processor have to equal the number of items received on the other processor.

To aid constructing these maps there are the constructors from global numbering, either with or without transforms.

  • without transforms: Constructors using compact numbering: layout is
  • all my own elements first (whether used or not)
  • followed by used-only remote elements sorted by remote processor. So e.g 4 procs and on proc 1 the compact table will first have all globalIndex.localSize() elements from proc1 followed by used-only elements of proc0, proc2, proc3. The constructed distributionMap sends the local elements from and receives the remote elements into their compact position. compactMap[proci] is the position of elements from proci in the compact map. compactMap[myProcNo()] is empty since trivial addressing.

It rewrites the input global indices into indices into the constructed data.

  • with transforms: This requires the precalculated set of possible transforms (globalIndexAndTransform). These are given as permutations (+, -, or none) of up to 3 independent transforms. The layout of the data is
  • all my own elements first (whether used or not)
  • followed by used-only remote elements sorted by remote processor.
  • followed by - for each transformation index - the set of local or remote elements with that transformation. The inputs for the constructor are
  • the set of untransformed local or remote indices in globalIndex numbering. These get rewritten to be indices into the layout of the data.
  • the set of transformed local or remote indices in globalIndexAndTransform encoding. These are labelPairs.

Any distribute with transforms is now done as: 1. exchange data with other processors and receive these into the slots for that processor 2. for all transformations transform a subset of the data according to transformElements_[transformI] and store this starting from transformStart_[transformI]

In the same way a reverse distribute will 1. apply the inverse transform to the data starting at transformStart_[transformI] and copy the result back into the transformElements_[transformI]. These might be local or remote slots. 2. the data in the remote slots will now be sent back to the correct location in the originating processor.

E.g. a map to handle

  • mesh points on a mesh with
  • 1 cyclic so 3 permutations (+,-,none) will have layout
  • on e.g. processor 1 out of 2:

    +——+ <- transformStart[2] | | | | <- transform2 applied to data in local or remote slots | | +——+ <- transformStart[1] | | | | <- transform1 applied to data in local or remote slots | | +——+ <- transformStart[1] | | | | <- transform0 applied to data in local or remote slots | | +——+ <- transformStart[0] | | | | <- data from proc2 | | +——+ | | | | <- data from proc0 | | +——+ <- mesh.nPoints() | | | | | | +——+ 0

When constructing from components optionally a 'flip' on the maps can be specified. This will interpret the map values as index+flip, similar to e.g. faceProcAddressing. The flip will only be applied to fieldTypes (scalar, vector, .. triad)

Source files

Definition at line 157 of file distributionMap.H.

Constructor & Destructor Documentation

◆ distributionMap() [1/11]

Construct null.

Definition at line 150 of file distributionMap.C.

◆ distributionMap() [2/11]

distributionMap ( const label  constructSize,
labelListList &&  subMap,
labelListList &&  constructMap,
const bool  subHasFlip = false,
const bool  constructHasFlip = false 
)

Construct from components.

Definition at line 156 of file distributionMap.C.

◆ distributionMap() [3/11]

distributionMap ( const label  constructSize,
labelListList &&  subMap,
labelListList &&  constructMap,
labelListList &&  transformElements,
labelList &&  transformStart,
const bool  subHasFlip = false,
const bool  constructHasFlip = false 
)

Construct from components.

Definition at line 176 of file distributionMap.C.

◆ distributionMap() [4/11]

distributionMap ( const labelList sendProcs,
const labelList recvProcs 
)

Construct from reverse addressing: per data item the send.

processor and the receive processor. (note: data is not stored sorted per processor so cannot use printLayout).

Definition at line 200 of file distributionMap.C.

◆ distributionMap() [5/11]

distributionMap ( const globalIndex globalNumbering,
labelList elements,
List< Map< label >> &  compactMap,
const int  tag = Pstream::msgType() 
)

Construct from list of (possibly) remote elements in globalIndex.

numbering (or -1). Determines compact numbering (see above) and distribute map to get data into this ordering and renumbers the elements to be in compact numbering.

Definition at line 210 of file distributionMap.C.

◆ distributionMap() [6/11]

distributionMap ( const globalIndex globalNumbering,
labelListList cellCells,
List< Map< label >> &  compactMap,
const int  tag = Pstream::msgType() 
)

Special variant that works with the info sorted into bins.

according to local indices. E.g. think cellCells where cellCells[localCelli] is a list of global cells

Definition at line 228 of file distributionMap.C.

◆ distributionMap() [7/11]

distributionMap ( const globalIndex globalNumbering,
labelList untransformedElements,
const globalIndexAndTransform globalTransforms,
const labelPairList transformedElements,
labelList transformedIndices,
List< Map< label >> &  compactMap,
const int  tag = Pstream::msgType() 
)

Construct from list of (possibly remote) untransformed elements.

in globalIndex numbering (or -1) and (possibly remote) transformded elements in globalIndexAndTransform numbering. Determines compact numbering (see above) and distribute map to get data into this ordering and renumbers the elements to be in compact numbering.

Definition at line 246 of file distributionMap.C.

References distributionMapBase::calcCompactAddressing(), distributionMapBase::constructSize_, distributionMapBase::exchangeAddressing(), forAll, globalIndexAndTransform::index(), UPstream::myProcNo(), n, Foam::Pout, distributionMap::printLayout(), globalIndexAndTransform::processor(), List< T >::setSize(), List< T >::size(), globalIndexAndTransform::transformIndex(), and globalIndexAndTransform::transformPermutations().

Here is the call graph for this function:

◆ distributionMap() [8/11]

◆ distributionMap() [9/11]

distributionMap ( const distributionMap map)

Copy constructor.

Definition at line 469 of file distributionMap.C.

◆ distributionMap() [10/11]

Move constructor.

Definition at line 477 of file distributionMap.C.

◆ distributionMap() [11/11]

Construct from Istream.

Definition at line 485 of file distributionMap.C.

◆ ~distributionMap()

virtual ~distributionMap ( )
inlinevirtual

Destructor.

Definition at line 432 of file distributionMap.H.

Member Function Documentation

◆ ClassName()

ClassName ( "distributionMap"  )

◆ clone()

Clone.

Definition at line 491 of file distributionMap.C.

◆ transformElements()

const labelListList& transformElements ( ) const
inline

For every globalIndexAndTransform::transformPermutations.

gives the elements that need to be transformed

Definition at line 442 of file distributionMap.H.

◆ transformStart()

const labelList& transformStart ( ) const
inline

Destination in constructMap for transformed elements.

Definition at line 448 of file distributionMap.H.

◆ whichTransform()

Foam::label whichTransform ( const label  index) const

Find transform from transformElements.

Definition at line 499 of file distributionMap.C.

References Foam::findLower().

Here is the call graph for this function:

◆ transfer()

void transfer ( distributionMap rhs)

Transfer the contents of the argument and annul the argument.

Definition at line 506 of file distributionMap.C.

References distributionMapBase::transfer().

Here is the call graph for this function:

◆ distribute() [1/4]

◆ distribute() [2/4]

void distribute ( List< T > &  fld,
const negateOp &  negOp,
const bool  dummyTransform = true,
const int  tag = UPstream::msgType() 
) const

Distribute data using default commsType.

Fill in transformed slots with copies

Definition at line 129 of file distributionMapTemplates.C.

References distributionMapBase::distribute(), and fld().

Here is the call graph for this function:

◆ distribute() [3/4]

void distribute ( DynamicList< T > &  fld,
const bool  dummyTransform = true,
const int  tag = UPstream::msgType() 
) const

Distribute data using default commsType.

Definition at line 160 of file distributionMapTemplates.C.

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

Here is the call graph for this function:

◆ reverseDistribute() [1/4]

void reverseDistribute ( const label  constructSize,
List< T > &  fld,
const bool  dummyTransform = true,
const int  tag = UPstream::msgType() 
) const

◆ reverseDistribute() [2/4]

void reverseDistribute ( const label  constructSize,
const T nullValue,
List< T > &  fld,
const bool  dummyTransform = true,
const int  tag = UPstream::msgType() 
) const

Reverse distribute data using default commsType.

Since constructSize might be larger than supplied size supply a nullValue

Definition at line 196 of file distributionMapTemplates.C.

References fld(), and distributionMapBase::reverseDistribute().

Here is the call graph for this function:

◆ distribute() [4/4]

void distribute ( const globalIndexAndTransform git,
List< T > &  fld,
const TransformOp &  top,
const int  tag = UPstream::msgType() 
) const

Distribute with transforms.

Definition at line 215 of file distributionMapTemplates.C.

References fld().

Here is the call graph for this function:

◆ reverseDistribute() [3/4]

void reverseDistribute ( const globalIndexAndTransform git,
const label  constructSize,
List< T > &  fld,
const TransformOp &  top,
const int  tag = UPstream::msgType() 
) const

Reverse distribute with transforms.

Definition at line 231 of file distributionMapTemplates.C.

References fld().

Here is the call graph for this function:

◆ reverseDistribute() [4/4]

void reverseDistribute ( const globalIndexAndTransform git,
const label  constructSize,
const T nullValue,
List< T > &  fld,
const TransformOp &  top,
const int  tag = UPstream::msgType() 
) const

Reverse distribute with transforms.

Definition at line 251 of file distributionMapTemplates.C.

References fld().

Here is the call graph for this function:

◆ printLayout()

void printLayout ( Ostream os) const

Debug: print layout. Can only be used on maps with sorted.

storage (local data first, then non-local data)

Definition at line 132 of file distributionMap.C.

References Foam::endl(), forAll, distributionMapBase::printLayout(), and List< T >::size().

Referenced by distributionMap::distributionMap().

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

◆ operator=()

void operator= ( const distributionMap rhs)

Definition at line 516 of file distributionMap.C.

References Foam::abort(), Foam::FatalError, FatalErrorInFunction, and distributionMapBase::operator=().

Referenced by IOdistributionMap::IOdistributionMap().

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

Friends And Related Function Documentation

◆ operator>>

Istream& operator>> ( Istream ,
distributionMap  
)
friend

Read dictionary from Istream.

◆ operator<<

Ostream& operator<< ( Ostream ,
const distributionMap  
)
friend

Write dictionary to Ostream.


The documentation for this class was generated from the following files: