]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Support PETSc 2.3.0
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 7 Jun 2005 20:09:27 +0000 (20:09 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 7 Jun 2005 20:09:27 +0000 (20:09 +0000)
git-svn-id: https://svn.dealii.org/trunk@10847 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/common/Make.global_options.in
deal.II/lac/source/petsc_matrix_base.cc
deal.II/lac/source/petsc_precondition.cc
deal.II/lac/source/petsc_vector_base.cc

index cf9142a935f91edb3a68166d55a0b7fc1a28f479..92b05fca3158f2aa5761051337dbf05e944d6cea 100644 (file)
@@ -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
index 84c9324fb0c332dae8bd799bef4da37e018d1e3c..30e80aa1d35148f7961e4511f653e1b41fbedb58 100644 (file)
@@ -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;
index 542257393b5c6f1d6893c8a92ec7f7bdeaf2a8a8..6bb1d6f6996af4dc7268ddae3e948cefdd053c7a 100644 (file)
@@ -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));
   }
   
index efc9e3e99d4d70555682b5e26c4c27f0cb3fe49d..2c5aa4cb39e7fca6d232e28121fc87d7bfba16c5 100644 (file)
@@ -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)
   {

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.