35 : communicator_(comm) {
40 : communicator_(PETSC_COMM_WORLD) {
41 resize(local_size, ghost_idx);
52 data_ptr_ = std::make_shared< std::vector<double> >(local_size);
54 ASSERT(
data_ptr_.use_count() == 1 ) (
data_ptr_.use_count() ).error(
"Object referenced by other pointer. Can not resize.");
67 ASSERT(
communicator_ == PETSC_COMM_WORLD).error(
"Cannot allocate ghost values in sequential vector.");
69 data_ptr_ = std::make_shared< std::vector<double> >(local_size + ghost_idx.size());
71 ASSERT(
data_ptr_.use_count() == 1 ) (
data_ptr_.use_count() ).error(
"Object referenced by other pointer. Can not resize.");
73 data_ptr_->resize(local_size + ghost_idx.size());
115 for(
unsigned int i=0; i<loc_indices.n_elem; i++){
116 unsigned int idx = loc_indices(i);
118 vec(i) = (*data_ptr_)[idx];
129 for(
unsigned int i=0; i<loc_indices.n_elem; i++){
130 unsigned int idx = loc_indices(i);
132 vec(i) = (*data_ptr_)[idx];
141 ASSERT_EQ(loc_indices.n_elem, values.n_elem);
143 for(
unsigned int i=0; i<loc_indices.n_elem; i++){
144 unsigned int idx = loc_indices(i);
146 (*data_ptr_)[idx] = values(i);
#define ASSERT_PERMANENT_EQ(a, b)
Definition of comparative assert macro (EQual)
#define ASSERT_EQ(a, b)
Definition of comparative assert macro (EQual) only for debug mode.
void copy_from(const VectorMPI &other)
void duplicate_from(VectorMPI other)
For the current vector, it creates the same parallel structure as the other vector has.
arma::vec get_subvec(const LocDofVec &loc_indices)
void resize(unsigned int local_size)
void set_subvec(const LocDofVec &loc_indices, const arma::vec &values)
static VectorMPI sequential(unsigned int size)
VectorDataPtr data_ptr_
shared pointer to vector of data
Vec data_petsc_
stored vector of data in PETSC format
void swap(VectorMPI &other)
Swaps the current vector data with the other vector data.
MPI_Comm communicator_
communicator
unsigned int size() const
Return size of output data.
VectorMPI(MPI_Comm comm=PETSC_COMM_SELF)
Global macros to enhance readability and debugging, general constants.
arma::Col< IntIdx > LocDofVec
void swap(nlohmann::json &j1, nlohmann::json &j2) noexcept(is_nothrow_move_constructible< nlohmann::json >::value and is_nothrow_move_assignable< nlohmann::json >::value)
exchanges the values of two JSON objects
void chkerr(unsigned int ierr)
Replacement of new/delete operator in the spirit of xmalloc.