From: wolf Date: Thu, 7 Oct 2004 15:38:24 +0000 (+0000) Subject: Make things compile with PETSc 2.2.1, which has changed interfaces again... X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=249dd2183412bc5470a0b2d422beafb0f15fafe2;p=dealii-svn.git Make things compile with PETSc 2.2.1, which has changed interfaces again... git-svn-id: https://svn.dealii.org/trunk@9694 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/lac/include/lac/petsc_vector.h b/deal.II/lac/include/lac/petsc_vector.h index 8870305da8..39de2f2789 100644 --- a/deal.II/lac/include/lac/petsc_vector.h +++ b/deal.II/lac/include/lac/petsc_vector.h @@ -257,10 +257,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 0397a1e848..e99ebf9ecf 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 949982d06f..1b77edbc13 100644 --- a/deal.II/lac/source/petsc_solver.cc +++ b/deal.II/lac/source/petsc_solver.cc @@ -168,7 +168,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(solver_data->ksp,b); AssertThrow (ierr == 0, ExcPETScError(ierr)); ierr = KSPSetSolution(solver_data->ksp, x); @@ -178,6 +181,13 @@ namespace PETScWrappers ierr = KSPSolve (solver_data->ksp); AssertThrow (ierr == 0, ExcPETScError(ierr)); +# else + ierr = KSPSetUp (solver_data->ksp); + AssertThrow (ierr == 0, ExcPETScError(ierr)); + + ierr = KSPSolve (solver_data->ksp, b, x); + AssertThrow (ierr == 0, ExcPETScError(ierr)); +# endif #endif // destroy solver object