48 const std::vector<PetscInt>& ghost_ids,
49 const bool is_global_size)
50 : size_ghosts_{static_cast<PetscInt>(ghost_ids.size())}, has_ghost_id_{true}
86 : v_{std::move(other.v_)},
87 v_loc_{std::move(other.v_loc_)},
88 start_rank_{other.start_rank_},
89 end_rank_{other.end_rank_},
91 size_loc_{other.size_loc_},
92 size_ghosts_{other.size_ghosts_},
93 has_ghost_id_{other.has_ghost_id_},
94 global_ids2local_ids_ghost_{other.global_ids2local_ids_ghost_}
116 PetscScalar global_array[])
const
155 OGS_FATAL(
"PETSc vector is already locked for {:s} access.",
156 state > 0 ?
"read" :
"write");
174 "### Memory usage by Updating. Before :%f After:%f Increase:%d\n",
mem1,
206 std::vector<IndexType>
const& indices)
const
208 std::vector<PetscScalar>
local_x(indices.size());
215 for (std::size_t
i = 0;
i < indices.size();
i++)
222 for (std::size_t
i = 0;
i < indices.size();
i++)
226 (indices[
i] == -
size_) ? 0 : std::abs(indices[
i]);
254 if (global_index >= 0)
280 const PetscViewerFormat vw_format)
const
Declaration of class PETScVector, which provides an interface to PETSc vector routines.
Wrapper class for PETSc vector.
PetscInt start_rank_
Starting index in a rank.
void finalizeAssembly()
Perform MPI collection of assembled entries in buffer.
void gatherLocalVectors(PetscScalar local_array[], PetscScalar global_array[]) const
Collect local vectors.
std::vector< PetscScalar > entry_array_
Array containing the entries of the vector. If the vector is created without given ghost IDs,...
void config()
A function called by constructors to configure members.
void setLocalAccessibleVector() const
void restoreArray(PetscScalar *array) const
PetscInt getLocalSize() const
Get the number of entries in the same rank.
bool has_ghost_id_
Flag to indicate whether the vector is created with ghost entry indices.
PetscInt size_loc_
Size of local entries.
PetscScalar * getLocalVector() const
void getGlobalVector(std::vector< PetscScalar > &u) const
std::vector< PetscScalar > get(std::vector< IndexType > const &indices) const
PetscInt size_ghosts_
Size of local ghost entries.
void copyValues(std::vector< PetscScalar > &u) const
PetscInt size_
Size of the vector.
void shallowCopy(const PETScVector &v)
void set(const PetscInt i, const PetscScalar value)
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.