From: wolf Date: Tue, 7 Jun 2005 20:09:27 +0000 (+0000) Subject: Support PETSc 2.3.0 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=24948034877f01612f4e3aaada89ac52c44ad5db;p=dealii-svn.git Support PETSc 2.3.0 git-svn-id: https://svn.dealii.org/trunk@10847 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/common/Make.global_options.in b/deal.II/common/Make.global_options.in index cf9142a935..92b05fca31 100644 --- a/deal.II/common/Make.global_options.in +++ b/deal.II/common/Make.global_options.in @@ -110,8 +110,15 @@ lib-deal2-3d.g = $(LIBDIR)/libdeal_II_3d.g$(lib-suffix) # -Wl,-rpath in our linker flags, we create one convenience library # for all PETSc libraries in our own lib directory, and have this one # twiddle with whatever is necessary to link in PETSc. -lib-contrib-petsc-path.g = $(DEAL_II_PETSC_DIR)/lib/libg_c++/$(DEAL_II_PETSC_ARCH) -lib-contrib-petsc-path.o = $(DEAL_II_PETSC_DIR)/lib/libO_c++/$(DEAL_II_PETSC_ARCH) +# +# to make things more fun, the whole scheme was changed in petsc 2.3.0 +ifeq ($(DEAL_II_PETSC_VERSION_MINOR),2) + lib-contrib-petsc-path.g = $(DEAL_II_PETSC_DIR)/lib/libg_c++/$(DEAL_II_PETSC_ARCH) + lib-contrib-petsc-path.o = $(DEAL_II_PETSC_DIR)/lib/libO_c++/$(DEAL_II_PETSC_ARCH) +else + lib-contrib-petsc-path.g = $(DEAL_II_PETSC_DIR)/lib/$(DEAL_II_PETSC_ARCH) + lib-contrib-petsc-path.o = $(DEAL_II_PETSC_DIR)/lib/$(DEAL_II_PETSC_ARCH) +endif lib-contrib-petsc.g = $(LIBDIR)/libpetsc.g$(lib-suffix) lib-contrib-petsc.o = $(LIBDIR)/libpetsc$(lib-suffix) @@ -153,8 +160,12 @@ INCLUDE = -I$D/base/include -I$D/lac/include -I$D/deal.II/include \ # be replaced by something where we do not blindly include PETSc make files # (and thus import all of its variables), but rather set up a scheme to # extract these values upon configuration +# +# note also that this only works for PETSc before 2.3 :-] ifeq ($(USE_CONTRIB_PETSC),yes) - include $(DEAL_II_PETSC_DIR)/bmake/$(DEAL_II_PETSC_ARCH)/packages + ifeq ($(DEAL_II_PETSC_VERSION_MINOR),2) + include $(DEAL_II_PETSC_DIR)/bmake/$(DEAL_II_PETSC_ARCH)/packages + endif INCLUDE += -I$(include-path-petsc) -I$(include-path-petsc-bmake)\ $(MPI_INCLUDE) endif @@ -175,7 +186,11 @@ CFLAGS = @CFLAGS@ # PETSc wants to see a whole lot of other flags being passed. ... ifeq ($(USE_CONTRIB_PETSC),yes) - include $(DEAL_II_PETSC_DIR)/bmake/$(DEAL_II_PETSC_ARCH)/variables + ifeq ($(DEAL_II_PETSC_VERSION_MINOR),2) + include $(DEAL_II_PETSC_DIR)/bmake/$(DEAL_II_PETSC_ARCH)/variables + else + include $(DEAL_II_PETSC_DIR)/bmake/common/variables + endif CXXFLAGS.g += $(GCXX_PETSCFLAGS) CXXFLAGS.o += $(OCXX_PETSCFLAGS) endif diff --git a/deal.II/lac/source/petsc_matrix_base.cc b/deal.II/lac/source/petsc_matrix_base.cc index 84c9324fb0..30e80aa1d3 100644 --- a/deal.II/lac/source/petsc_matrix_base.cc +++ b/deal.II/lac/source/petsc_matrix_base.cc @@ -393,8 +393,11 @@ namespace PETScWrappers MatrixBase & MatrixBase::operator *= (const PetscScalar a) { - const int ierr - = MatScale (&a, matrix); +#if (PETSC_VERSION_MAJOR <= 2) && (PETSC_VERSION_MINOR < 3) + const int ierr = MatScale (&a, matrix); +#else + const int ierr = MatScale (matrix, a); +#endif AssertThrow (ierr == 0, ExcPETScError(ierr)); return *this; @@ -407,8 +410,12 @@ namespace PETScWrappers { const PetscScalar factor = 1./a; - const int ierr - = MatScale (&factor, matrix); +#if (PETSC_VERSION_MAJOR <= 2) && (PETSC_VERSION_MINOR < 3) + const int ierr = MatScale (&factor, matrix); +#else + const int ierr = MatScale (matrix, factor); +#endif + AssertThrow (ierr == 0, ExcPETScError(ierr)); return *this; diff --git a/deal.II/lac/source/petsc_precondition.cc b/deal.II/lac/source/petsc_precondition.cc index 542257393b..6bb1d6f699 100644 --- a/deal.II/lac/source/petsc_precondition.cc +++ b/deal.II/lac/source/petsc_precondition.cc @@ -291,10 +291,19 @@ namespace PETScWrappers ierr = PCLUSetPivoting (pc, additional_data.pivoting); AssertThrow (ierr == 0, ExcPETScError(ierr)); +#if (PETSC_VERSION_MAJOR <= 2) && (PETSC_VERSION_MINOR < 3) ierr = PCLUSetZeroPivot (pc, additional_data.zero_pivot); +#else + ierr = PCFactorSetZeroPivot (pc, additional_data.zero_pivot); +#endif + AssertThrow (ierr == 0, ExcPETScError(ierr)); +#if (PETSC_VERSION_MAJOR <= 2) && (PETSC_VERSION_MINOR < 3) ierr = PCLUSetDamping (pc, additional_data.damping); +#else + ierr = PCFactorSetShiftNonzero (pc, additional_data.damping); +#endif AssertThrow (ierr == 0, ExcPETScError(ierr)); } diff --git a/deal.II/lac/source/petsc_vector_base.cc b/deal.II/lac/source/petsc_vector_base.cc index efc9e3e99d..2c5aa4cb39 100644 --- a/deal.II/lac/source/petsc_vector_base.cc +++ b/deal.II/lac/source/petsc_vector_base.cc @@ -127,7 +127,12 @@ namespace PETScWrappers // (see test bits/petsc_65) compress (); +#if (PETSC_VERSION_MAJOR <= 2) && (PETSC_VERSION_MINOR < 3) const int ierr = VecSet (&s, vector); +#else + const int ierr = VecSet (vector, s); +#endif + AssertThrow (ierr == 0, ExcPETScError(ierr)); return *this; @@ -438,8 +443,12 @@ namespace PETScWrappers VectorBase & VectorBase::operator *= (const PetscScalar a) { - const int ierr - = VecScale (&a, vector); +#if (PETSC_VERSION_MAJOR <= 2) && (PETSC_VERSION_MINOR < 3) + const int ierr = VecScale (&a, vector); +#else + const int ierr = VecScale (vector, a); +#endif + AssertThrow (ierr == 0, ExcPETScError(ierr)); return *this; @@ -452,8 +461,12 @@ namespace PETScWrappers { const PetscScalar factor = 1./a; - const int ierr - = VecScale (&factor, vector); +#if (PETSC_VERSION_MAJOR <= 2) && (PETSC_VERSION_MINOR < 3) + const int ierr = VecScale (&factor, vector); +#else + const int ierr = VecScale (vector, factor); +#endif + AssertThrow (ierr == 0, ExcPETScError(ierr)); return *this; @@ -464,10 +477,13 @@ namespace PETScWrappers VectorBase & VectorBase::operator += (const VectorBase &v) { - const PetscScalar one = 1.0; +#if (PETSC_VERSION_MAJOR <= 2) && (PETSC_VERSION_MINOR < 3) + const PetscScalar one = 1.0; + const int ierr = VecAXPY (&one, v, vector); +#else + const int ierr = VecAXPY (vector, 1, v); +#endif - const int ierr - = VecAXPY (&one, v, vector); AssertThrow (ierr == 0, ExcPETScError(ierr)); return *this; @@ -478,10 +494,13 @@ namespace PETScWrappers VectorBase & VectorBase::operator -= (const VectorBase &v) { - const PetscScalar minus_one = -1.0; +#if (PETSC_VERSION_MAJOR <= 2) && (PETSC_VERSION_MINOR < 3) + const PetscScalar minus_one = -1.0; + const int ierr = VecAXPY (&minus_one, v, vector); +#else + const int ierr = VecAXPY (vector, -1, v); +#endif - const int ierr - = VecAXPY (&minus_one, v, vector); AssertThrow (ierr == 0, ExcPETScError(ierr)); return *this; @@ -492,8 +511,12 @@ namespace PETScWrappers void VectorBase::add (const PetscScalar s) { - const int ierr - = VecShift (&s, vector); + #if (PETSC_VERSION_MAJOR <= 2) && (PETSC_VERSION_MINOR < 3) + const int ierr = VecShift (&s, vector); +#else + const int ierr = VecShift (vector, s); +#endif + AssertThrow (ierr == 0, ExcPETScError(ierr)); } @@ -511,8 +534,12 @@ namespace PETScWrappers VectorBase::add (const PetscScalar a, const VectorBase &v) { - const int ierr - = VecAXPY (&a, v, vector); +#if (PETSC_VERSION_MAJOR <= 2) && (PETSC_VERSION_MINOR < 3) + const int ierr = VecAXPY (&a, v, vector); +#else + const int ierr = VecAXPY (vector, a, v); +#endif + AssertThrow (ierr == 0, ExcPETScError(ierr)); } @@ -520,15 +547,19 @@ namespace PETScWrappers void VectorBase::add (const PetscScalar a, - const VectorBase &v, + const VectorBase &v, const PetscScalar b, - const VectorBase &w) + const VectorBase &w) { const PetscScalar weights[2] = {a,b}; Vec addends[2] = {v.vector, w.vector}; - const int ierr - = VecMAXPY (2, weights, vector, addends); +#if (PETSC_VERSION_MAJOR <= 2) && (PETSC_VERSION_MINOR < 3) + const int ierr = VecMAXPY (2, weights, vector, addends); +#else + const int ierr = VecMAXPY (vector, 2, weights, addends); +#endif + AssertThrow (ierr == 0, ExcPETScError(ierr)); } @@ -536,10 +567,14 @@ namespace PETScWrappers void VectorBase::sadd (const PetscScalar s, - const VectorBase &v) + const VectorBase &v) { - const int ierr - = VecAYPX (&s, v, vector); +#if (PETSC_VERSION_MAJOR <= 2) && (PETSC_VERSION_MINOR < 3) + const int ierr = VecAYPX (&s, v, vector); +#else + const int ierr = VecAYPX (vector, s, v); +#endif + AssertThrow (ierr == 0, ExcPETScError(ierr)); } @@ -573,8 +608,12 @@ namespace PETScWrappers const PetscScalar weights[2] = {a,b}; Vec addends[2] = {v.vector,w.vector}; - const int ierr - = VecMAXPY (2, weights, vector, addends); +#if (PETSC_VERSION_MAJOR <= 2) && (PETSC_VERSION_MINOR < 3) + const int ierr = VecMAXPY (2, weights, vector, addends); +#else + const int ierr = VecMAXPY (vector, 2, weights, addends); +#endif + AssertThrow (ierr == 0, ExcPETScError(ierr)); } @@ -596,8 +635,12 @@ namespace PETScWrappers const PetscScalar weights[3] = {a,b,c}; Vec addends[3] = {v.vector, w.vector, x.vector}; - const int ierr - = VecMAXPY (3, weights, vector, addends); +#if (PETSC_VERSION_MAJOR <= 2) && (PETSC_VERSION_MINOR < 3) + const int ierr = VecMAXPY (3, weights, vector, addends); +#else + const int ierr = VecMAXPY (vector, 3, weights, addends); +#endif + AssertThrow (ierr == 0, ExcPETScError(ierr)); } @@ -615,7 +658,7 @@ namespace PETScWrappers void VectorBase::equ (const PetscScalar a, - const VectorBase &v) + const VectorBase &v) { Assert (size() == v.size(), ExcDimensionMismatch (size(), v.size())); @@ -633,9 +676,9 @@ namespace PETScWrappers void VectorBase::equ (const PetscScalar a, - const VectorBase &v, + const VectorBase &v, const PetscScalar b, - const VectorBase &w) + const VectorBase &w) { Assert (size() == v.size(), ExcDimensionMismatch (size(), v.size())); @@ -655,8 +698,12 @@ namespace PETScWrappers VectorBase::ratio (const VectorBase &a, const VectorBase &b) { - const int ierr - = VecPointwiseDivide (a, b, vector); +#if (PETSC_VERSION_MAJOR <= 2) && (PETSC_VERSION_MINOR < 3) + const int ierr = VecPointwiseDivide (a, b, vector); +#else + const int ierr = VecPointwiseDivide (vector, a, b); +#endif + AssertThrow (ierr == 0, ExcPETScError(ierr)); } @@ -699,6 +746,7 @@ namespace PETScWrappers } + void VectorBase::swap (VectorBase &v) {