From f4903b68830c4d05a630d283c6ac8bceeeb6ebc4 Mon Sep 17 00:00:00 2001 From: heister Date: Fri, 1 Feb 2013 00:23:08 +0000 Subject: [PATCH] integrate r28202,r28203,r28204 from unified linear algebra branch: introduces get_mpi_communicator() for PETScWrappers::Vector git-svn-id: https://svn.dealii.org/trunk@28206 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/include/deal.II/lac/petsc_vector_base.h | 15 +++++++++++++++ deal.II/source/lac/petsc_solver.cc | 5 +++++ 2 files changed, 20 insertions(+) diff --git a/deal.II/include/deal.II/lac/petsc_vector_base.h b/deal.II/include/deal.II/lac/petsc_vector_base.h index 29391b7705..a50120b792 100644 --- a/deal.II/include/deal.II/lac/petsc_vector_base.h +++ b/deal.II/include/deal.II/lac/petsc_vector_base.h @@ -810,6 +810,13 @@ namespace PETScWrappers */ std::size_t memory_consumption () const; + /** + * Return a reference to the MPI + * communicator object in use with this + * object. + */ + virtual const MPI_Comm &get_mpi_communicator () const; + protected: /** * A generic vector object in @@ -1182,6 +1189,14 @@ namespace PETScWrappers return operator()(index); } + inline + const MPI_Comm & + VectorBase::get_mpi_communicator () const + { + static MPI_Comm comm; + PetscObjectGetComm((PetscObject)vector, &comm); + return comm; + } #endif // DOXYGEN } diff --git a/deal.II/source/lac/petsc_solver.cc b/deal.II/source/lac/petsc_solver.cc index caaa9ea4b9..8a8dc50073 100644 --- a/deal.II/source/lac/petsc_solver.cc +++ b/deal.II/source/lac/petsc_solver.cc @@ -63,6 +63,11 @@ namespace PETScWrappers const PreconditionerBase &preconditioner) { int ierr; + + Assert(A.get_mpi_communicator()==mpi_communicator, ExcMessage("PETSc Solver and Matrix need to use the same MPI_Comm.")); + Assert(x.get_mpi_communicator()==mpi_communicator, ExcMessage("PETSc Solver and Vector need to use the same MPI_Comm.")); + Assert(b.get_mpi_communicator()==mpi_communicator, ExcMessage("PETSc Solver and Vector need to use the same MPI_Comm.")); + // first create a solver object if this // is necessary if (solver_data.get() == 0) -- 2.39.5