20#ifdef DEAL_II_WITH_PETSC
32 : communicator(MPI_COMM_SELF)
45 : communicator(communicator)
56 , communicator(communicator)
75 : communicator(communicator)
90 , communicator(v.communicator)
105 : communicator(communicator)
141 ierr = VecGhostUpdateBegin(
vector, INSERT_VALUES, SCATTER_FORWARD);
143 ierr = VecGhostUpdateEnd(
vector, INSERT_VALUES, SCATTER_FORWARD);
166 const bool omit_zeroing_entries)
176 MPI_Allreduce(&k, &k_global, 1, MPI_INT, MPI_LOR,
communicator);
191 const PetscErrorCode ierr = VecDestroy(&
vector);
199 if (omit_zeroing_entries ==
false)
211 if (!omit_zeroing_entries)
213 const PetscErrorCode ierr = VecSet(
vector, 0.0);
221 omit_zeroing_entries);
231 const PetscErrorCode ierr = VecDestroy(&
vector);
247 const PetscErrorCode ierr = VecDestroy(&
vector);
259 const std::shared_ptr<const Utilities::MPI::Partitioner> &partitioner)
261 this->
reinit(partitioner->locally_owned_range(),
262 partitioner->ghost_indices(),
263 partitioner->get_mpi_communicator());
295 std::vector<size_type> ghostindices;
298 const PetscInt *ptr =
299 (ghostindices.size() > 0 ?
300 reinterpret_cast<const PetscInt *
>(ghostindices.data()) :
318 ierr = VecGetOwnershipRange(
vector, &begin, &end);
325 ierr = VecGhostGetLocalForm(
vector, &l);
329 ierr = VecGetSize(l, &lsize);
332 ierr = VecGhostRestoreLocalForm(
vector, &l);
347# if DEAL_II_PETSC_VERSION_LT(3, 6, 0)
360# ifdef DEAL_II_WITH_MPI
364 return num_nonzero == 0;
366 return has_nonzero == 0;
373 const unsigned int precision,
374 const bool scientific,
375 const bool across)
const
382 PetscInt nlocal, istart, iend;
384 PetscErrorCode ierr = VecGetArray(
vector, &val);
387 ierr = VecGetLocalSize(
vector, &nlocal);
390 ierr = VecGetOwnershipRange(
vector, &istart, &iend);
394 std::ios::fmtflags old_flags = out.flags();
395 unsigned int old_precision = out.precision(precision);
397 out.precision(precision);
399 out.setf(std::ios::scientific, std::ios::floatfield);
401 out.setf(std::ios::fixed, std::ios::floatfield);
408 for (
unsigned int i = 0;
419 out <<
"[Proc" << i <<
" " << istart <<
"-" << iend - 1 <<
"]"
421 for (PetscInt i = 0; i < nlocal; ++i)
422 out << val[i] <<
' ';
426 out <<
"[Proc " << i <<
" " << istart <<
"-" << iend - 1
428 for (PetscInt i = 0; i < nlocal; ++i)
429 out << val[i] << std::endl;
435 out.flags(old_flags);
436 out.precision(old_precision);
440 ierr = VecRestoreArray(
vector, &val);
void fill_index_vector(std::vector< size_type > &indices) const
size_type n_elements() const
void subtract_set(const IndexSet &other)
bool is_ascending_and_one_to_one(const MPI_Comm &communicator) const
virtual void create_vector(const size_type n, const size_type locally_owned_size)
void print(std::ostream &out, const unsigned int precision=3, const bool scientific=true, const bool across=true) const
virtual void clear() override
void reinit(const MPI_Comm &communicator, const size_type N, const size_type locally_owned_size, const bool omit_zeroing_entries=false)
Vector & operator=(const Vector &v)
VectorOperation::values last_action
IndexSet locally_owned_elements() 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)
unsigned int this_mpi_process(const MPI_Comm &mpi_communicator)
T sum(const T &t, const MPI_Comm &mpi_communicator)
unsigned int n_mpi_processes(const MPI_Comm &mpi_communicator)