16 #include <deal.II/base/mpi.h> 18 #include <deal.II/lac/petsc_vector.h> 20 #ifdef DEAL_II_WITH_PETSC 25 DEAL_II_NAMESPACE_OPEN
32 : communicator(MPI_COMM_SELF)
45 : communicator(communicator)
56 , communicator(communicator)
74 const MPI_Comm &communicator)
75 : communicator(communicator)
90 , communicator(v.communicator)
103 : communicator(communicator)
139 ierr = VecGhostUpdateBegin(
vector, INSERT_VALUES, SCATTER_FORWARD);
141 ierr = VecGhostUpdateEnd(
vector, INSERT_VALUES, SCATTER_FORWARD);
164 const bool omit_zeroing_entries)
174 MPI_Allreduce(&k, &k_global, 1, MPI_INT, MPI_LOR,
communicator);
189 const PetscErrorCode ierr = VecDestroy(&
vector);
197 if (omit_zeroing_entries ==
false)
209 if (!omit_zeroing_entries)
211 const PetscErrorCode ierr = VecSet(
vector, 0.0);
224 const MPI_Comm &comm)
226 const PetscErrorCode ierr = VecDestroy(&
vector);
242 const PetscErrorCode ierr = VecDestroy(&
vector);
260 const PetscErrorCode ierr =
279 std::vector<size_type> ghostindices;
282 const PetscInt *ptr =
283 (ghostindices.size() > 0 ?
284 reinterpret_cast<const PetscInt *
>(ghostindices.data()) :
302 ierr = VecGetOwnershipRange(
vector, &begin, &end);
308 ierr = VecGhostGetLocalForm(
vector, &l);
312 ierr = VecGetSize(l, &lsize);
315 ierr = VecGhostRestoreLocalForm(
vector, &l);
330 # if DEAL_II_PETSC_VERSION_LT(3, 6, 0) 343 # ifdef DEAL_II_WITH_MPI 347 return num_nonzero == 0;
349 return has_nonzero == 0;
356 const unsigned int precision,
357 const bool scientific,
358 const bool across)
const 365 PetscInt nlocal, istart, iend;
367 PetscErrorCode ierr = VecGetArray(
vector, &val);
370 ierr = VecGetLocalSize(
vector, &nlocal);
373 ierr = VecGetOwnershipRange(
vector, &istart, &iend);
377 std::ios::fmtflags old_flags = out.flags();
378 unsigned int old_precision = out.precision(precision);
380 out.precision(precision);
382 out.setf(std::ios::scientific, std::ios::floatfield);
384 out.setf(std::ios::fixed, std::ios::floatfield);
391 for (
unsigned int i = 0;
402 out <<
"[Proc" << i <<
" " << istart <<
"-" << iend - 1 <<
"]" 404 for (PetscInt i = 0; i < nlocal; ++i)
405 out << val[i] <<
' ';
409 out <<
"[Proc " << i <<
" " << istart <<
"-" << iend - 1
411 for (PetscInt i = 0; i < nlocal; ++i)
412 out << val[i] << std::endl;
418 out.flags(old_flags);
419 out.precision(old_precision);
423 ierr = VecRestoreArray(
vector, &val);
433 DEAL_II_NAMESPACE_CLOSE
435 #endif // DEAL_II_WITH_PETSC
#define AssertDimension(dim1, dim2)
static ::ExceptionBase & ExcIO()
#define AssertThrow(cond, exc)
virtual void clear() override
static ::ExceptionBase & ExcIndexRange(int arg1, int arg2, int arg3)
bool is_ascending_and_one_to_one(const MPI_Comm &communicator) const
static ::ExceptionBase & ExcMessage(std::string arg1)
size_type local_size() const
T sum(const T &t, const MPI_Comm &mpi_communicator)
void subtract_set(const IndexSet &other)
VectorOperation::values last_action
#define Assert(cond, exc)
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
types::global_dof_index size_type
unsigned int n_mpi_processes(const MPI_Comm &mpi_communicator)
void fill_index_vector(std::vector< size_type > &indices) const
Vector & operator=(const Vector &v)
#define AssertThrowMPI(error_code)
bool has_ghost_elements() const
void reinit(const MPI_Comm &communicator, const size_type N, const size_type local_size, const bool omit_zeroing_entries=false)
IndexSet locally_owned_elements() const
virtual void create_vector(const size_type n, const size_type local_size)
unsigned int this_mpi_process(const MPI_Comm &mpi_communicator)
static ::ExceptionBase & ExcNotImplemented()
void print(std::ostream &out, const unsigned int precision=3, const bool scientific=true, const bool across=true) const
size_type n_elements() const