18 #ifndef VECTOR_MPI_HH_ 19 #define VECTOR_MPI_HH_ 59 resize(local_size, ghost_idx);
76 void resize(
unsigned int local_size) {
78 data_ptr_ = std::make_shared< std::vector<double> >(local_size);
97 data_ptr_ = std::make_shared< std::vector<double> >(local_size + ghost_idx.size());
101 data_ptr_->resize(local_size + ghost_idx.size());
167 VecGhostUpdateBegin(
data_petsc_, INSERT_VALUES, SCATTER_FORWARD);
172 VecGhostUpdateEnd(
data_petsc_, INSERT_VALUES, SCATTER_FORWARD);
177 VecGhostUpdateBegin(
data_petsc_, ADD_VALUES, SCATTER_REVERSE);
182 VecGhostUpdateEnd(
data_petsc_, ADD_VALUES, SCATTER_REVERSE);
unsigned int size() const
Return size of output data.
MPI_Comm communicator_
communicator
void copy(VectorMPI &other)
VectorMPI(unsigned int local_size, MPI_Comm comm=PETSC_COMM_WORLD)
Create shared pointer and PETSC vector with given size. COLLECTIVE.
void ghost_to_local_end()
ghost_to_local_{begin,end} updates the local values by adding ghost values from neighbouring processo...
void local_to_ghost_begin()
local_to_ghost_{begin,end} updates the ghost values on neighbouring processors from local values ...
void duplicate(VectorMPI other)
Return new vector with same parallel structure.
std::vector< double > VectorData
void chkerr(unsigned int ierr)
Replacement of new/delete operator in the spirit of xmalloc.
VectorDataPtr data_ptr()
Getter for shared pointer of output data.
double & operator[](unsigned int idx)
const VectorData & data() const
VectorMPI(MPI_Comm comm=PETSC_COMM_SELF)
Global macros to enhance readability and debugging, general constants.
VectorDataPtr data_ptr_
shared pointer to vector of data
Vec data_petsc_
stored vector of data in PETSC format
void resize(unsigned int local_size)
Vec & petsc_vec()
Getter for PETSC vector of output data (e.g. can be used by scatters).
void swap(nlohmann::json &j1, nlohmann::json &j2) noexcept(is_nothrow_move_constructible< nlohmann::json >::value andis_nothrow_move_assignable< nlohmann::json >::value)
exchanges the values of two JSON objects
void local_to_ghost_end()
local_to_ghost_{begin,end} updates the ghost values on neighbouring processors from local values ...
void resize(unsigned int local_size, std::vector< LongIdx > &ghost_idx)
#define ASSERT_PTR(ptr)
Definition of assert macro checking non-null pointer (PTR)
static VectorMPI sequential(unsigned int size)
void swap(VectorMPI &other)
VectorMPI(unsigned int local_size, std::vector< LongIdx > &ghost_idx)
Create PETSc vector with ghost values whose indices are specified in ghost_idx.
void ghost_to_local_begin()
ghost_to_local_{begin,end} updates the local values by adding ghost values from neighbouring processo...
std::shared_ptr< VectorData > VectorDataPtr
#define ASSERT_EQ(a, b)
Definition of comparative assert macro (EQual)