60 PETScVector(
const PetscInt vec_size,
const bool is_global_size =
true);
70 PETScVector(
const PetscInt vec_size,
const std::vector<PetscInt>& ghost_ids,
71 const bool is_global_size =
true);
80 const bool deep_copy =
true);
104 void set(
const PetscInt i,
const PetscScalar value)
106 VecSetValue(
v_, i, value, INSERT_VALUES);
114 void add(
const PetscInt i,
const PetscScalar value)
116 VecSetValue(
v_, i, value, ADD_VALUES);
126 template <
class T_SUBVEC>
127 void add(
const std::vector<PetscInt>& e_idxs,
const T_SUBVEC& sub_vec)
129 VecSetValues(
v_, e_idxs.size(), &e_idxs[0], &sub_vec[0], ADD_VALUES);
139 template <
class T_SUBVEC>
140 void set(
const std::vector<PetscInt>& e_idxs,
const T_SUBVEC& sub_vec)
142 VecSetValues(
v_, e_idxs.size(), &e_idxs[0], &sub_vec[0], INSERT_VALUES);
158 std::vector<PetscScalar>
get(std::vector<IndexType>
const& indices)
const;
175 PetscScalar
get(
const PetscInt idx)
const;
191 void copyValues(std::vector<PetscScalar>&
u)
const;
223 const std::string& file_name,
224 const PetscViewerFormat vw_format = PETSC_VIEWER_ASCII_MATLAB)
const;
Wrapper class for PETSc vector.
PetscInt start_rank_
Starting index in a rank.
void finalizeAssembly()
Perform MPI collection of assembled entries in buffer.
std::vector< PetscScalar > entry_array_
Array containing the entries of the vector. If the vector is created without given ghost IDs,...
PetscScalar operator[](PetscInt idx) const
void set(const std::vector< PetscInt > &e_idxs, const T_SUBVEC &sub_vec)
PETSc_Vec const & getRawVector() const
void config()
A function called by constructors to configure members.
void setLocalAccessibleVector() const
PetscInt getRangeBegin() const
Get the start index of the local vector.
void restoreArray(PetscScalar *array) const
PetscInt getLocalSize() const
Get the number of entries in the same rank.
PetscInt size_loc_
Size of local entries.
bool created_with_ghost_id_
Flag to indicate whether the vector is created with ghost entry indices.
PetscScalar * getLocalVector() const
void getGlobalVector(std::vector< PetscScalar > &u) const
std::vector< PetscScalar > get(std::vector< IndexType > const &indices) const
void add(const std::vector< PetscInt > &e_idxs, const T_SUBVEC &sub_vec)
PetscInt size_ghosts_
Size of local ghost entries.
void copyValues(std::vector< PetscScalar > &u) const
PetscInt getRangeEnd() const
Get the end index of the local vector.
PetscInt size_
Size of the vector.
PETScVector & operator=(PETScVector &&)=delete
friend void finalizeVectorAssembly(PETScVector &vec)
Function to finalize the vector assembly.
PetscInt size() const
Get the global size of the vector.
void shallowCopy(const PETScVector &v)
void add(const PetscInt i, const PetscScalar value)
void set(const PetscInt i, const PetscScalar value)
PETSc_Vec & getRawVector()
Exposes the underlying PETSc vector.
PetscInt getGhostSize() const
Get the number of ghost entries in the same rank.
std::map< PetscInt, PetscInt > global_ids2local_ids_ghost_
Map global indices of ghost entries to local indices.
PetscInt getLocalIndex(const PetscInt global_index) const
Get local index by a global index.
PetscInt end_rank_
Ending index in a rank.
void viewer(const std::string &file_name, const PetscViewerFormat vw_format=PETSC_VIEWER_ASCII_MATLAB) const
void finalizeVectorAssembly(VEC_T &)
General function to finalize the vector assembly.