Flow123d  master-f44eb46
Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
VectorMPI Class Reference

#include <vector_mpi.hh>

Public Types

typedef std::vector< double > VectorData
 
typedef std::shared_ptr< VectorDataVectorDataPtr
 

Public Member Functions

 VectorMPI (MPI_Comm comm=PETSC_COMM_SELF)
 
 VectorMPI (unsigned int local_size, MPI_Comm comm=PETSC_COMM_WORLD)
 Create shared pointer and PETSC vector with given size. COLLECTIVE. More...
 
 VectorMPI (unsigned int local_size, std::vector< LongIdx > &ghost_idx)
 Create PETSc vector with ghost values whose indices are specified in ghost_idx. More...
 
void resize (unsigned int local_size)
 
void resize (unsigned int local_size, std::vector< LongIdx > &ghost_idx)
 
Vec & petsc_vec ()
 Getter for PETSC vector of output data (e.g. can be used by scatters). More...
 
void zero_entries ()
 
unsigned int size () const
 Return size of output data. More...
 
double get (unsigned int pos) const
 Return value on given position. More...
 
void set (unsigned int pos, double val)
 Set value on given position. More...
 
void normalize (unsigned int pos, double divisor)
 Normalize value on given position. More...
 
void add (unsigned int pos, double val)
 Add value to item on given position. More...
 
void add_global (unsigned int pos, double val)
 Add value to item on given global position. More...
 
void duplicate_from (VectorMPI other)
 For the current vector, it creates the same parallel structure as the other vector has. More...
 
void swap (VectorMPI &other)
 Swaps the current vector data with the other vector data. More...
 
void copy_from (const VectorMPI &other)
 
void local_to_ghost_begin ()
 local_to_ghost_{begin,end} updates the ghost values on neighbouring processors from local values More...
 
void local_to_ghost_end ()
 local_to_ghost_{begin,end} updates the ghost values on neighbouring processors from local values More...
 
void ghost_to_local_begin ()
 ghost_to_local_{begin,end} updates the local values by adding ghost values from neighbouring processors More...
 
void ghost_to_local_end ()
 ghost_to_local_{begin,end} updates the local values by adding ghost values from neighbouring processors More...
 
 ~VectorMPI ()
 Destructor. More...
 
arma::vec get_subvec (const LocDofVec &loc_indices)
 
arma::vec get_subvec (const LocDofVec &loc_indices) const
 
void set_subvec (const LocDofVec &loc_indices, const arma::vec &values)
 

Static Public Member Functions

static VectorMPI sequential (unsigned int size)
 

Private Attributes

VectorDataPtr data_ptr_
 shared pointer to vector of data More...
 
Vec data_petsc_
 stored vector of data in PETSC format More...
 
MPI_Comm communicator_
 communicator More...
 

Detailed Description

Auxiliary class for output elementwise concentration vectors in convection transport, sorptions, dual porosity etc.

Stores data in two formats:

Allows the following functionalities:

Definition at line 43 of file vector_mpi.hh.

Member Typedef Documentation

◆ VectorData

Definition at line 45 of file vector_mpi.hh.

◆ VectorDataPtr

typedef std::shared_ptr< VectorData > VectorMPI::VectorDataPtr

Definition at line 46 of file vector_mpi.hh.

Constructor & Destructor Documentation

◆ VectorMPI() [1/3]

VectorMPI::VectorMPI ( MPI_Comm  comm = PETSC_COMM_SELF)

Definition at line 29 of file vector_mpi.cc.

Here is the caller graph for this function:

◆ VectorMPI() [2/3]

VectorMPI::VectorMPI ( unsigned int  local_size,
MPI_Comm  comm = PETSC_COMM_WORLD 
)

Create shared pointer and PETSC vector with given size. COLLECTIVE.

Definition at line 34 of file vector_mpi.cc.

◆ VectorMPI() [3/3]

VectorMPI::VectorMPI ( unsigned int  local_size,
std::vector< LongIdx > &  ghost_idx 
)

Create PETSc vector with ghost values whose indices are specified in ghost_idx.

Definition at line 39 of file vector_mpi.cc.

◆ ~VectorMPI()

VectorMPI::~VectorMPI ( )

Destructor.

Definition at line 151 of file vector_mpi.cc.

Member Function Documentation

◆ add()

void VectorMPI::add ( unsigned int  pos,
double  val 
)
inline

Add value to item on given position.

Definition at line 125 of file vector_mpi.hh.

Here is the caller graph for this function:

◆ add_global()

void VectorMPI::add_global ( unsigned int  pos,
double  val 
)
inline

Add value to item on given global position.

Definition at line 132 of file vector_mpi.hh.

Here is the caller graph for this function:

◆ copy_from()

void VectorMPI::copy_from ( const VectorMPI other)

Copies data from the other vector. Both vector must have the same communicator and distribution.

Definition at line 103 of file vector_mpi.cc.

Here is the caller graph for this function:

◆ duplicate_from()

void VectorMPI::duplicate_from ( VectorMPI  other)

For the current vector, it creates the same parallel structure as the other vector has.

FIXME: it does not take care of ghost values, so it cannot be used in that situation.

Definition at line 80 of file vector_mpi.cc.

◆ get()

double VectorMPI::get ( unsigned int  pos) const
inline

Return value on given position.

Definition at line 105 of file vector_mpi.hh.

Here is the caller graph for this function:

◆ get_subvec() [1/2]

arma::vec VectorMPI::get_subvec ( const LocDofVec loc_indices)

Access to the vector element on local index idx. Access to the vector element on local index idx (const version). Access to the vector elements on local indices idx.

Definition at line 110 of file vector_mpi.cc.

Here is the caller graph for this function:

◆ get_subvec() [2/2]

arma::vec VectorMPI::get_subvec ( const LocDofVec loc_indices) const

Access to the vector elements on local indices idx (const version).

Definition at line 124 of file vector_mpi.cc.

◆ ghost_to_local_begin()

void VectorMPI::ghost_to_local_begin ( )
inline

ghost_to_local_{begin,end} updates the local values by adding ghost values from neighbouring processors

Definition at line 164 of file vector_mpi.hh.

Here is the caller graph for this function:

◆ ghost_to_local_end()

void VectorMPI::ghost_to_local_end ( )
inline

ghost_to_local_{begin,end} updates the local values by adding ghost values from neighbouring processors

Definition at line 168 of file vector_mpi.hh.

Here is the caller graph for this function:

◆ local_to_ghost_begin()

void VectorMPI::local_to_ghost_begin ( )
inline

local_to_ghost_{begin,end} updates the ghost values on neighbouring processors from local values

Definition at line 156 of file vector_mpi.hh.

Here is the caller graph for this function:

◆ local_to_ghost_end()

void VectorMPI::local_to_ghost_end ( )
inline

local_to_ghost_{begin,end} updates the ghost values on neighbouring processors from local values

Definition at line 160 of file vector_mpi.hh.

Here is the caller graph for this function:

◆ normalize()

void VectorMPI::normalize ( unsigned int  pos,
double  divisor 
)
inline

Normalize value on given position.

Definition at line 118 of file vector_mpi.hh.

Here is the caller graph for this function:

◆ petsc_vec()

Vec& VectorMPI::petsc_vec ( )
inline

Getter for PETSC vector of output data (e.g. can be used by scatters).

Getter for shared pointer of output data. VectorDataPtr data_ptr()

Definition at line 79 of file vector_mpi.hh.

Here is the caller graph for this function:

◆ resize() [1/2]

void VectorMPI::resize ( unsigned int  local_size)

Resize the vector to given local size. Operation is allowed only if this object is a unique vector object pointing to the actual data.

Definition at line 50 of file vector_mpi.cc.

Here is the caller graph for this function:

◆ resize() [2/2]

void VectorMPI::resize ( unsigned int  local_size,
std::vector< LongIdx > &  ghost_idx 
)

Resize the vector to given local size with ghost values. Indices of ghost values are in ghost_idx.

Definition at line 66 of file vector_mpi.cc.

◆ sequential()

VectorMPI VectorMPI::sequential ( unsigned int  size)
static

Helper method creating VectorMPI of given size with serial Petsc communicator.

Method is used for better readability of code.

Definition at line 44 of file vector_mpi.cc.

Here is the caller graph for this function:

◆ set()

void VectorMPI::set ( unsigned int  pos,
double  val 
)
inline

Set value on given position.

Definition at line 111 of file vector_mpi.hh.

Here is the caller graph for this function:

◆ set_subvec()

void VectorMPI::set_subvec ( const LocDofVec loc_indices,
const arma::vec &  values 
)

Set some vector elements on local indices idx.

Definition at line 138 of file vector_mpi.cc.

Here is the caller graph for this function:

◆ size()

unsigned int VectorMPI::size ( ) const
inline

Return size of output data.

Definition at line 98 of file vector_mpi.hh.

Here is the caller graph for this function:

◆ swap()

void VectorMPI::swap ( VectorMPI other)

Swaps the current vector data with the other vector data.

FIXME: it does not take care of ghost values, so it cannot be used

Definition at line 86 of file vector_mpi.cc.

◆ zero_entries()

void VectorMPI::zero_entries ( )
inline

Definition at line 82 of file vector_mpi.hh.

Here is the caller graph for this function:

Member Data Documentation

◆ communicator_

MPI_Comm VectorMPI::communicator_
private

communicator

Definition at line 215 of file vector_mpi.hh.

◆ data_petsc_

Vec VectorMPI::data_petsc_
private

stored vector of data in PETSC format

Definition at line 213 of file vector_mpi.hh.

◆ data_ptr_

VectorDataPtr VectorMPI::data_ptr_
private

shared pointer to vector of data

Definition at line 211 of file vector_mpi.hh.


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