From 6c4f6a78f668f0a5d7de37e54c33bbbab0d3305b Mon Sep 17 00:00:00 2001 From: wolf Date: Thu, 7 Oct 2004 15:37:03 +0000 Subject: [PATCH] Make things compile with PETSc 2.2.1, which has changed interfaces again... git-svn-id: https://svn.dealii.org/branches/Branch-5-0@9693 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/lac/include/lac/petsc_vector.h | 30 ++++++++++++++++++++++++- deal.II/lac/source/petsc_matrix_base.cc | 6 ++--- deal.II/lac/source/petsc_solver.cc | 12 +++++++++- 3 files changed, 43 insertions(+), 5 deletions(-) diff --git a/deal.II/lac/include/lac/petsc_vector.h b/deal.II/lac/include/lac/petsc_vector.h index 6b6168b9c3..f59c955c6b 100644 --- a/deal.II/lac/include/lac/petsc_vector.h +++ b/deal.II/lac/include/lac/petsc_vector.h @@ -232,10 +232,38 @@ namespace PETScWrappers int ierr = VecDestroy (vector); AssertThrow (ierr == 0, ExcPETScError(ierr)); - // then do the gather operation + // then do the gather + // operation. petsc has changed its + // interface again, and replaced a single + // function call by several calls that + // are hard to understand. gets me all + // annoyed at their development + // model +#if (PETSC_VERSION_MAJOR <= 2) && \ + ((PETSC_VERSION_MINOR < 2) || \ + ((PETSC_VERSION_MINOR == 2) && (PETSC_VERSION_SUBMINOR == 0))) ierr = VecConvertMPIToSeqAll (static_cast(v), &vector); AssertThrow (ierr == 0, ExcPETScError(ierr)); + +#else + + VecScatter ctx; + + ierr = VecScatterCreateToAll (static_cast(v), &ctx, &vector); + AssertThrow (ierr == 0, ExcPETScError(ierr)); + + ierr = VecScatterBegin (static_cast(v), vector, + INSERT_VALUES, SCATTER_FORWARD, ctx); + AssertThrow (ierr == 0, ExcPETScError(ierr)); + + ierr = VecScatterEnd (static_cast(v), vector, + INSERT_VALUES, SCATTER_FORWARD, ctx); + AssertThrow (ierr == 0, ExcPETScError(ierr)); + + ierr = VecScatterDestroy (ctx); + AssertThrow (ierr == 0, ExcPETScError(ierr)); +#endif return *this; } diff --git a/deal.II/lac/source/petsc_matrix_base.cc b/deal.II/lac/source/petsc_matrix_base.cc index 6f6ae79eb4..de15e68d7c 100644 --- a/deal.II/lac/source/petsc_matrix_base.cc +++ b/deal.II/lac/source/petsc_matrix_base.cc @@ -46,9 +46,9 @@ namespace PETScWrappers // get a representation of the present // row - int ncols; - int *colnums; - PetscScalar *values; + int ncols; + const int *colnums; + const PetscScalar *values; int ierr; ierr = MatGetRow(*matrix, this->a_row, &ncols, &colnums, &values); diff --git a/deal.II/lac/source/petsc_solver.cc b/deal.II/lac/source/petsc_solver.cc index 03ed750a30..3f55c541ca 100644 --- a/deal.II/lac/source/petsc_solver.cc +++ b/deal.II/lac/source/petsc_solver.cc @@ -159,7 +159,10 @@ namespace PETScWrappers // then do the real work: set up solver // internal data and solve the - // system. + // system. unfortunately, the call + // sequence is different between PETSc + // versions 2.2.0 and 2.2.1 +# if (PETSC_VERSION_MINOR == 2) && (PETSC_VERSION_SUBMINOR == 0) ierr = KSPSetRhs(ksp,b); AssertThrow (ierr == 0, ExcPETScError(ierr)); ierr = KSPSetSolution(ksp,x); @@ -173,6 +176,13 @@ namespace PETScWrappers // and destroy the solver object ierr = KSPDestroy (ksp); AssertThrow (ierr == 0, ExcPETScError(ierr)); +# else + ierr = KSPSetUp (ksp); + AssertThrow (ierr == 0, ExcPETScError(ierr)); + + ierr = KSPSolve (ksp, b, x); + AssertThrow (ierr == 0, ExcPETScError(ierr)); +# endif #endif // in case of failure: throw -- 2.39.5