20 #ifdef DEAL_II_WITH_PETSC
52 const MPI_Comm &communicator)
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);
214 const MPI_Comm &
comm)
216 const PetscErrorCode ierr = VecDestroy(&
vector);
230 const PetscErrorCode ierr = VecDestroy(&
vector);
240 const std::shared_ptr<const Utilities::MPI::Partitioner> &partitioner)
242 this->
reinit(partitioner->locally_owned_range(),
243 partitioner->ghost_indices(),
244 partitioner->get_mpi_communicator());
257 const PetscErrorCode ierr = VecCreateMPI(communicator,
281 const PetscInt *ptr =
282 (ghostindices.size() > 0 ?
283 reinterpret_cast<const PetscInt *
>(ghostindices.data()) :
286 PetscErrorCode ierr = VecCreateGhost(communicator,
308 ierr = VecGhostGetLocalForm(
vector, &
l);
312 ierr = VecGetSize(
l, &lsize);
315 ierr = VecGhostRestoreLocalForm(
vector, &
l);
331 # ifdef DEAL_II_WITH_MPI
334 unsigned int num_nonzero =
336 return num_nonzero == 0;
338 return has_nonzero == 0;
345 const unsigned int precision,
346 const bool scientific,
347 const bool across)
const
353 const PetscScalar *val;
354 PetscInt nlocal, istart, iend;
356 PetscErrorCode ierr = VecGetArrayRead(
vector, &val);
359 ierr = VecGetLocalSize(
vector, &nlocal);
362 ierr = VecGetOwnershipRange(
vector, &istart, &iend);
366 std::ios::fmtflags old_flags = out.flags();
367 unsigned int old_precision = out.precision(precision);
369 out.precision(precision);
371 out.setf(std::ios::scientific, std::ios::floatfield);
373 out.setf(std::ios::fixed, std::ios::floatfield);
381 for (
unsigned int i = 0;
385 const int mpi_ierr = MPI_Barrier(communicator);
392 out <<
"[Proc" << i <<
" " << istart <<
"-" << iend - 1 <<
"]"
394 for (PetscInt i = 0; i < nlocal; ++i)
395 out << val[i] <<
' ';
399 out <<
"[Proc " << i <<
" " << istart <<
"-" << iend - 1
401 for (PetscInt i = 0; i < nlocal; ++i)
402 out << val[i] << std::endl;
408 out.flags(old_flags);
409 out.precision(old_precision);
413 ierr = VecRestoreArrayRead(
vector, &val);
size_type n_elements() const
void subtract_set(const IndexSet &other)
bool is_ascending_and_one_to_one(const MPI_Comm &communicator) const
std::vector< size_type > get_index_vector() const
types::global_dof_index size_type
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)
VectorOperation::values last_action
IndexSet locally_owned_elements() const
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 & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
#define Assert(cond, exc)
static ::ExceptionBase & ExcNotImplemented()
#define AssertDimension(dim1, dim2)
#define AssertThrowMPI(error_code)
#define AssertIndexRange(index, range)
static ::ExceptionBase & ExcIO()
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
Tensor< 2, dim, Number > l(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
VectorType::value_type * begin(VectorType &V)
VectorType::value_type * end(VectorType &V)
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)