20#ifdef DEAL_II_WITH_PETSC
127 ierr = VecGhostUpdateBegin(
vector, INSERT_VALUES, SCATTER_FORWARD);
129 ierr = VecGhostUpdateEnd(
vector, INSERT_VALUES, SCATTER_FORWARD);
151 const bool omit_zeroing_entries)
159 MPI_Allreduce(&k, &k_global, 1, MPI_INT, MPI_LOR, communicator);
174 const PetscErrorCode ierr = VecDestroy(&
vector);
182 if (omit_zeroing_entries ==
false)
196 if (!omit_zeroing_entries)
198 const PetscErrorCode ierr = VecSet(
vector, 0.0);
206 omit_zeroing_entries);
216 const PetscErrorCode ierr = VecDestroy(&
vector);
230 const PetscErrorCode ierr = VecDestroy(&
vector);
240 const std::shared_ptr<const Utilities::MPI::Partitioner> &partitioner,
241 const bool make_ghosted)
245 Assert(partitioner->ghost_indices_initialized(),
246 ExcMessage(
"You asked to create a ghosted vector, but the "
247 "partitioner does not provide ghost indices."));
249 this->
reinit(partitioner->locally_owned_range(),
250 partitioner->ghost_indices(),
251 partitioner->get_mpi_communicator());
255 this->
reinit(partitioner->locally_owned_range(),
256 partitioner->get_mpi_communicator());
270 const PetscErrorCode ierr = VecCreateMPI(communicator,
294 const PetscInt *ptr =
295 (ghostindices.size() > 0 ?
296 reinterpret_cast<const PetscInt *
>(ghostindices.data()) :
299 PetscErrorCode ierr = VecCreateGhost(communicator,
314 ierr = VecGetOwnershipRange(
vector, &begin, &end);
321 ierr = VecGhostGetLocalForm(
vector, &l);
325 ierr = VecGetSize(l, &lsize);
328 ierr = VecGhostRestoreLocalForm(
vector, &l);
344# ifdef DEAL_II_WITH_MPI
347 unsigned int num_nonzero =
349 return num_nonzero == 0;
351 return has_nonzero == 0;
358 const unsigned int precision,
359 const bool scientific,
360 const bool across)
const
366 const PetscScalar *val;
367 PetscInt nlocal, istart, iend;
369 PetscErrorCode ierr = VecGetArrayRead(
vector, &val);
372 ierr = VecGetLocalSize(
vector, &nlocal);
375 ierr = VecGetOwnershipRange(
vector, &istart, &iend);
379 std::ios::fmtflags old_flags = out.flags();
380 unsigned int old_precision = out.precision(precision);
382 out.precision(precision);
384 out.setf(std::ios::scientific, std::ios::floatfield);
386 out.setf(std::ios::fixed, std::ios::floatfield);
394 for (
unsigned int i = 0;
398 const int mpi_ierr = MPI_Barrier(communicator);
405 out <<
"[Proc" << i <<
" " << istart <<
"-" << iend - 1 <<
"]"
407 for (PetscInt i = 0; i < nlocal; ++i)
408 out << val[i] <<
' ';
412 out <<
"[Proc " << i <<
" " << istart <<
"-" << iend - 1
414 for (PetscInt i = 0; i < nlocal; ++i)
415 out << val[i] << std::endl;
421 out.flags(old_flags);
422 out.precision(old_precision);
426 ierr = VecRestoreArrayRead(
vector, &val);
bool is_ascending_and_one_to_one(const MPI_Comm communicator) const
size_type n_elements() const
void subtract_set(const IndexSet &other)
std::vector< size_type > get_index_vector() const
void print(std::ostream &out, const unsigned int precision=3, const bool scientific=true, const bool across=true) const
virtual void clear() override
Vector & operator=(const Vector &v)
virtual void create_vector(const MPI_Comm comm, const size_type n, const size_type locally_owned_size)
void reinit(const MPI_Comm communicator, const size_type N, const size_type locally_owned_size, const bool omit_zeroing_entries=false)
VectorOperation::values last_action
IndexSet locally_owned_elements() const
MPI_Comm get_mpi_communicator() const
bool has_ghost_elements() const
size_type locally_owned_size() const
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcIO()
static ::ExceptionBase & ExcNotImplemented()
#define Assert(cond, exc)
#define AssertDimension(dim1, dim2)
#define AssertThrowMPI(error_code)
#define AssertIndexRange(index, range)
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
T sum(const T &t, const MPI_Comm mpi_communicator)
unsigned int n_mpi_processes(const MPI_Comm mpi_communicator)
unsigned int this_mpi_process(const MPI_Comm mpi_communicator)