Flow123d
JS_before_hm-989-g79825ac
|
#include <vector_mpi.hh>
Public Types | |
typedef std::vector< double > | VectorData |
typedef std::shared_ptr< VectorData > | VectorDataPtr |
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) |
VectorDataPtr | data_ptr () |
Getter for shared pointer of output data. More... | |
Vec & | petsc_vec () |
Getter for PETSC vector of output data (e.g. can be used by scatters). More... | |
void | zero_entries () |
VectorData & | data () |
const VectorData & | data () const |
unsigned int | size () const |
Return size of output data. 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 (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... | |
double & | operator[] (unsigned int idx) |
double & | operator[] (unsigned int idx) const |
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... | |
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.
typedef std::vector<double> VectorMPI::VectorData |
Definition at line 45 of file vector_mpi.hh.
typedef std::shared_ptr< VectorData > VectorMPI::VectorDataPtr |
Definition at line 46 of file vector_mpi.hh.
VectorMPI::VectorMPI | ( | MPI_Comm | comm = PETSC_COMM_SELF | ) |
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::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 | ( | ) |
Destructor.
Definition at line 151 of file vector_mpi.cc.
void VectorMPI::copy_from | ( | 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.
|
inline |
|
inline |
Definition at line 91 of file vector_mpi.hh.
|
inline |
Getter for shared pointer of output data.
Definition at line 75 of file vector_mpi.hh.
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.
arma::vec VectorMPI::get_subvec | ( | const LocDofVec & | loc_indices | ) |
Access to the vector elements on local indices idx
.
Definition at line 110 of file vector_mpi.cc.
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.
|
inline |
ghost_to_local_{begin,end} updates the local values by adding ghost values from neighbouring processors
Definition at line 131 of file vector_mpi.hh.
|
inline |
ghost_to_local_{begin,end} updates the local values by adding ghost values from neighbouring processors
Definition at line 135 of file vector_mpi.hh.
|
inline |
local_to_ghost_{begin,end} updates the ghost values on neighbouring processors from local values
Definition at line 123 of file vector_mpi.hh.
|
inline |
local_to_ghost_{begin,end} updates the ghost values on neighbouring processors from local values
Definition at line 127 of file vector_mpi.hh.
|
inline |
Access to the vector element on local index idx
.
Definition at line 144 of file vector_mpi.hh.
|
inline |
Access to the vector element on local index idx
(const version).
Definition at line 154 of file vector_mpi.hh.
|
inline |
Getter for PETSC vector of output data (e.g. can be used by scatters).
Definition at line 79 of file vector_mpi.hh.
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.
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.
|
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.
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.
|
inline |
Return size of output data.
Definition at line 98 of file vector_mpi.hh.
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.
|
inline |
|
private |
communicator
Definition at line 182 of file vector_mpi.hh.
|
private |
stored vector of data in PETSC format
Definition at line 180 of file vector_mpi.hh.
|
private |
shared pointer to vector of data
Definition at line 178 of file vector_mpi.hh.