19#ifdef DEAL_II_WITH_PETSC
34# ifdef DEAL_II_HAVE_CXX20
134 ierr = VecGhostUpdateBegin(
vector, INSERT_VALUES, SCATTER_FORWARD);
136 ierr = VecGhostUpdateEnd(
vector, INSERT_VALUES, SCATTER_FORWARD);
158 const bool omit_zeroing_entries)
166 MPI_Allreduce(&k, &k_global, 1, MPI_INT, MPI_LOR, communicator);
181 const PetscErrorCode ierr = VecDestroy(&
vector);
189 if (omit_zeroing_entries ==
false)
203 if (!omit_zeroing_entries)
205 const PetscErrorCode ierr = VecSet(
vector, 0.0);
213 omit_zeroing_entries);
223 const PetscErrorCode ierr = VecDestroy(&
vector);
237 const PetscErrorCode ierr = VecDestroy(&
vector);
247 const std::shared_ptr<const Utilities::MPI::Partitioner> &partitioner,
248 const bool make_ghosted)
252 Assert(partitioner->ghost_indices_initialized(),
253 ExcMessage(
"You asked to create a ghosted vector, but the "
254 "partitioner does not provide ghost indices."));
256 this->
reinit(partitioner->locally_owned_range(),
257 partitioner->ghost_indices(),
258 partitioner->get_mpi_communicator());
262 this->
reinit(partitioner->locally_owned_range(),
263 partitioner->get_mpi_communicator());
277 const PetscErrorCode ierr = VecCreateMPI(communicator,
301 const PetscInt *ptr =
302 (ghostindices.size() > 0 ?
303 reinterpret_cast<const PetscInt *
>(ghostindices.data()) :
306 PetscErrorCode ierr = VecCreateGhost(communicator,
321 ierr = VecGetOwnershipRange(
vector, &begin, &end);
328 ierr = VecGhostGetLocalForm(
vector, &l);
332 ierr = VecGetSize(l, &lsize);
335 ierr = VecGhostRestoreLocalForm(
vector, &l);
353 unsigned int num_nonzero =
355 return num_nonzero == 0;
361 const unsigned int precision,
362 const bool scientific,
363 const bool across)
const
369 const PetscScalar *val;
370 PetscInt nlocal, istart, iend;
372 PetscErrorCode ierr = VecGetArrayRead(
vector, &val);
375 ierr = VecGetLocalSize(
vector, &nlocal);
378 ierr = VecGetOwnershipRange(
vector, &istart, &iend);
382 std::ios::fmtflags old_flags = out.flags();
383 unsigned int old_precision = out.precision(precision);
385 out.precision(precision);
387 out.setf(std::ios::scientific, std::ios::floatfield);
389 out.setf(std::ios::fixed, std::ios::floatfield);
397 for (
unsigned int i = 0;
401 const int mpi_ierr = MPI_Barrier(communicator);
408 out <<
"[Proc" << i <<
" " << istart <<
"-" << iend - 1 <<
"]"
410 for (PetscInt i = 0; i < nlocal; ++i)
411 out << val[i] <<
' ';
415 out <<
"[Proc " << i <<
" " << istart <<
"-" << iend - 1
417 for (PetscInt i = 0; i < nlocal; ++i)
418 out << val[i] << std::endl;
424 out.flags(old_flags);
425 out.precision(old_precision);
429 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
size_type size() const override
#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)
*braid_SplitCommworld & comm