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)
75 : communicator(communicator)
89 : communicator(communicator)
125 ierr = VecGhostUpdateBegin(
vector, INSERT_VALUES, SCATTER_FORWARD);
127 ierr = VecGhostUpdateEnd(
vector, INSERT_VALUES, SCATTER_FORWARD);
150 const bool omit_zeroing_entries)
160 MPI_Allreduce(&k, &k_global, 1, MPI_INT, MPI_LOR,
communicator);
175 const PetscErrorCode ierr = VecDestroy(&
vector);
183 if (omit_zeroing_entries ==
false)
195 if (!omit_zeroing_entries)
197 const PetscErrorCode ierr = VecSet(
vector, 0.0);
210 const MPI_Comm &comm)
212 const PetscErrorCode ierr = VecDestroy(&
vector);
228 const PetscErrorCode ierr = VecDestroy(&
vector);
246 const PetscErrorCode ierr =
265 std::vector<size_type> ghostindices;
268 const PetscInt *ptr =
269 (ghostindices.size() > 0 ? (
const PetscInt *)(&(ghostindices[0])) :
287 ierr = VecGetOwnershipRange(
vector, &begin, &end);
293 ierr = VecGhostGetLocalForm(
vector, &l);
297 ierr = VecGetSize(l, &lsize);
300 ierr = VecGhostRestoreLocalForm(
vector, &l);
314 # if DEAL_II_PETSC_VERSION_LT(3, 6, 0) 327 # ifdef DEAL_II_WITH_MPI 331 return num_nonzero == 0;
333 return has_nonzero == 0;
340 const unsigned int precision,
341 const bool scientific,
342 const bool across)
const 349 PetscInt nlocal, istart, iend;
351 PetscErrorCode ierr = VecGetArray(
vector, &val);
354 ierr = VecGetLocalSize(
vector, &nlocal);
357 ierr = VecGetOwnershipRange(
vector, &istart, &iend);
361 std::ios::fmtflags old_flags = out.flags();
362 unsigned int old_precision = out.precision(precision);
364 out.precision(precision);
366 out.setf(std::ios::scientific, std::ios::floatfield);
368 out.setf(std::ios::fixed, std::ios::floatfield);
375 for (
unsigned int i = 0;
386 out <<
"[Proc" << i <<
" " << istart <<
"-" << iend - 1 <<
"]" 388 for (PetscInt i = 0; i < nlocal; ++i)
389 out << val[i] <<
' ';
393 out <<
"[Proc " << i <<
" " << istart <<
"-" << iend - 1
395 for (PetscInt i = 0; i < nlocal; ++i)
396 out << val[i] << std::endl;
402 out.flags(old_flags);
403 out.precision(old_precision);
407 ierr = VecRestoreArray(
vector, &val);
417 DEAL_II_NAMESPACE_CLOSE
419 #endif // DEAL_II_WITH_PETSC
static::ExceptionBase & ExcIO()
bool is_ascending_and_one_to_one(const MPI_Comm &communicator) const
size_type n_elements() const
bool has_ghost_elements() const
#define AssertThrow(cond, exc)
virtual void clear() override
static::ExceptionBase & ExcIndexRange(int arg1, int arg2, int arg3)
static::ExceptionBase & ExcMessage(std::string arg1)
T sum(const T &t, const MPI_Comm &mpi_communicator)
void subtract_set(const IndexSet &other)
void fill_index_vector(std::vector< size_type > &indices) const
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
void print(std::ostream &out, const unsigned int precision=3, const bool scientific=true, const bool across=true) const
unsigned int n_mpi_processes(const MPI_Comm &mpi_communicator)
Vector & operator=(const Vector &v)
size_type local_size() const
#define AssertThrowMPI(error_code)
void reinit(const MPI_Comm &communicator, const size_type N, const size_type local_size, const bool omit_zeroing_entries=false)
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()
IndexSet locally_owned_elements() const
static::ExceptionBase & ExcInternalError()