Flow123d  build_with_4.0.3-86a16ad
Public Types | Public Member Functions | Private Attributes | List of all members
Distribution Class Reference

#include <distribution.hh>

Public Types

enum  SpecialDistribution { Block =-1 , Localized =-2 }
 

Public Member Functions

 Distribution (const unsigned int size, MPI_Comm comm)
 
 Distribution (const unsigned int *const sizes, MPI_Comm comm)
 
 Distribution (const Vec &petsc_vector)
 
 Distribution (const DistributionType &type, unsigned int global_size, MPI_Comm comm)
 
 Distribution (const Distribution &distr)
 
unsigned int np () const
 get num of processors More...
 
unsigned int myp () const
 get my processor More...
 
unsigned int begin (int proc) const
 get starting local index More...
 
unsigned int begin () const
 
unsigned int end (int proc) const
 get last local index +1 More...
 
unsigned int end () const
 
unsigned int lsize (int proc) const
 get local size More...
 
unsigned int lsize () const
 
unsigned int size () const
 get global size More...
 
bool is_local (unsigned int idx) const
 identify local index More...
 
bool is_on_proc (unsigned int idx, unsigned int proc) const
 
unsigned int get_proc (unsigned int idx) const
 get processor of the given index More...
 
const unsigned int * get_lsizes_array ()
 get local sizes array More...
 
const unsigned int * get_starts_array () const
 get local starts array More...
 
MPI_Comm get_comm () const
 Returns communicator. More...
 
void view (std::ostream &stream) const
 distribution view More...
 
 ~Distribution ()
 

Private Attributes

const MPI_Comm communicator
 communicator More...
 
int num_of_procs
 number of procs More...
 
int my_proc
 my proc number More...
 
unsigned int * starts
 starts[i] index of the first index on the proc i; starts[n_procs]=size of whole array More...
 
unsigned int * lsizes
 local sizes More...
 

Detailed Description

Continuous distribution of an 1D array of indexes. TODO: after inclusion of LibMesh sources:

Definition at line 50 of file distribution.hh.

Member Enumeration Documentation

◆ SpecialDistribution

Type of distribution automatically created only from global number of indices.

Enumerator
Block 

Distribute indices evenly.

Localized 

Put all on the first processor.

Definition at line 55 of file distribution.hh.

Constructor & Destructor Documentation

◆ Distribution() [1/5]

Distribution::Distribution ( const unsigned int  size,
MPI_Comm  comm 
)

Constructor. It makes distribution from given local number of indices on every processor.

COLLECTIVE

Parameters
sizeLocal size on calling processor.

create a Distribution from local sizes (dim = np ) (collective context)

Definition at line 27 of file distribution.cc.

◆ Distribution() [2/5]

Distribution::Distribution ( const unsigned int *const  sizes,
MPI_Comm  comm 
)

Constructor. It makes distribution from given array of sizes of processors.

NOT COLLECTIVE, but still use MPI to provide information about processors.

Parameters
sizesInt array with sizes.

create a Distribution from local sizes (dim = np ) (local context)

Definition at line 48 of file distribution.cc.

◆ Distribution() [3/5]

Distribution::Distribution ( const Vec &  petsc_vector)

Constructor. It makes distribution from distribution of a PETSC vector.

NOT COLLECTIVE, but still use MPI to provide information about processors.

Parameters
petsc_vectorconstructor from existing PETSC vector (collective context)

Definition at line 64 of file distribution.cc.

◆ Distribution() [4/5]

Distribution::Distribution ( const DistributionType type,
unsigned int  global_size,
MPI_Comm  comm 
)

Constructor. It makes distribution from global number of indices according to given scheme.

NOT COLLECTIVE, but still use MPI to provide information about processors.

Parameters
typeEither Block or Localized distribution of indices.
global_sizeTotal number of indices to distribute.

construct from given global size (collective context)

Definition at line 82 of file distribution.cc.

◆ Distribution() [5/5]

Distribution::Distribution ( const Distribution distr)

Copy Constructor.

copy constructor

Definition at line 114 of file distribution.cc.

◆ ~Distribution()

Distribution::~Distribution ( )

Destructor.

Definition at line 170 of file distribution.cc.

Member Function Documentation

◆ begin() [1/2]

unsigned int Distribution::begin ( ) const
inline

Definition at line 110 of file distribution.hh.

Here is the caller graph for this function:

◆ begin() [2/2]

unsigned int Distribution::begin ( int  proc) const
inline

get starting local index

Definition at line 109 of file distribution.hh.

Here is the caller graph for this function:

◆ end() [1/2]

unsigned int Distribution::end ( ) const
inline

Definition at line 113 of file distribution.hh.

Here is the caller graph for this function:

◆ end() [2/2]

unsigned int Distribution::end ( int  proc) const
inline

get last local index +1

Definition at line 112 of file distribution.hh.

Here is the caller graph for this function:

◆ get_comm()

MPI_Comm Distribution::get_comm ( ) const
inline

Returns communicator.

Definition at line 129 of file distribution.hh.

Here is the caller graph for this function:

◆ get_lsizes_array()

const unsigned int * Distribution::get_lsizes_array ( )

get local sizes array

Definition at line 142 of file distribution.cc.

Here is the caller graph for this function:

◆ get_proc()

unsigned int Distribution::get_proc ( unsigned int  idx) const

get processor of the given index

find the proc to which belongs index "idx" in the distribution use simple linear search, better binary search could be implemented (local context)

Definition at line 130 of file distribution.cc.

Here is the caller graph for this function:

◆ get_starts_array()

const unsigned int * Distribution::get_starts_array ( ) const

get local starts array

Definition at line 154 of file distribution.cc.

◆ is_local()

bool Distribution::is_local ( unsigned int  idx) const
inline

identify local index

Definition at line 120 of file distribution.hh.

Here is the caller graph for this function:

◆ is_on_proc()

bool Distribution::is_on_proc ( unsigned int  idx,
unsigned int  proc 
) const
inline

Definition at line 121 of file distribution.hh.

Here is the caller graph for this function:

◆ lsize() [1/2]

unsigned int Distribution::lsize ( ) const
inline

Definition at line 116 of file distribution.hh.

Here is the caller graph for this function:

◆ lsize() [2/2]

unsigned int Distribution::lsize ( int  proc) const
inline

get local size

Definition at line 115 of file distribution.hh.

◆ myp()

unsigned int Distribution::myp ( ) const
inline

get my processor

Definition at line 107 of file distribution.hh.

◆ np()

unsigned int Distribution::np ( ) const
inline

get num of processors

Definition at line 105 of file distribution.hh.

Here is the caller graph for this function:

◆ size()

unsigned int Distribution::size ( ) const
inline

get global size

Definition at line 118 of file distribution.hh.

Here is the caller graph for this function:

◆ view()

void Distribution::view ( std::ostream &  stream) const

distribution view

Definition at line 160 of file distribution.cc.

Here is the caller graph for this function:

Member Data Documentation

◆ communicator

const MPI_Comm Distribution::communicator
private

communicator

Definition at line 135 of file distribution.hh.

◆ lsizes

unsigned int* Distribution::lsizes
private

local sizes

Definition at line 143 of file distribution.hh.

◆ my_proc

int Distribution::my_proc
private

my proc number

Definition at line 139 of file distribution.hh.

◆ num_of_procs

int Distribution::num_of_procs
private

number of procs

Definition at line 137 of file distribution.hh.

◆ starts

unsigned int* Distribution::starts
private

starts[i] index of the first index on the proc i; starts[n_procs]=size of whole array

Definition at line 141 of file distribution.hh.


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