]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Implementation of simplified PETSc version control in PETScWrappers.
authoryoung <young@0785d39b-7218-0410-832d-ea1e28bc413d>
Sun, 7 Mar 2010 12:50:06 +0000 (12:50 +0000)
committeryoung <young@0785d39b-7218-0410-832d-ea1e28bc413d>
Sun, 7 Mar 2010 12:50:06 +0000 (12:50 +0000)
git-svn-id: https://svn.dealii.org/trunk@20745 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/petsc_matrix_base.h
deal.II/lac/include/lac/petsc_parallel_sparse_matrix.h
deal.II/lac/source/petsc_matrix_base.cc
deal.II/lac/source/petsc_parallel_sparse_matrix.cc
deal.II/lac/source/petsc_precondition.cc
deal.II/lac/source/petsc_solver.cc
deal.II/lac/source/petsc_sparse_matrix.cc
deal.II/lac/source/petsc_vector_base.cc

index 2d9e06699f6f13ab5587222ad07a93f7dd73d4c9..b4f4d804267ce8d803ef2ef1e67e909132ba7d8e 100644 (file)
@@ -1096,6 +1096,7 @@ namespace PETScWrappers
                                         */
       PetscTruth is_symmetric (const double tol = 0.0);
 
+#if DEAL_II_PETSC_VERSION_GTE(2,3,0)
                                         /**
                                         * Test whether a matrix is Hermitian,
                                         * i.e. it is the complex conjugate
@@ -1103,6 +1104,7 @@ namespace PETScWrappers
                                         * is zero.
                                         */
       PetscTruth is_hermitian (const double tol = 0.0);
+#endif
 
                                         /*
                                         * Abstract PETSc object that helps view
index 38ead029a85130c57c5bf6305fa62cb9902f29d7..188cbdc02e1fe4c87aae1d2184cc325b1661431c 100644 (file)
@@ -13,7 +13,6 @@
 #ifndef __deal2__petsc_parallel_sparse_matrix_h
 #define __deal2__petsc_parallel_sparse_matrix_h
 
-
 #include <base/config.h>
 
 #ifdef DEAL_II_USE_PETSC
index f19b3944e800b289104180c7a0b9a24aa894c78b..9f1fc2fa50373dab55cb847d928a8f7eb6f784e6 100644 (file)
@@ -48,9 +48,7 @@ namespace PETScWrappers
 
                                        // get a representation of the present
                                        // row
-#if (PETSC_VERSION_MAJOR <= 2) && \
-    ((PETSC_VERSION_MINOR < 2) ||  \
-     ((PETSC_VERSION_MINOR == 2) && (PETSC_VERSION_SUBMINOR == 0)))
+#if DEAL_II_PETSC_VERSION_LT(2,2,1)
       int          ncols;
       int         *colnums;
       PetscScalar *values;
@@ -141,9 +139,7 @@ namespace PETScWrappers
 
                                      // now set all the entries of this row to
                                      // zero
-#if (PETSC_VERSION_MAJOR <= 2) && \
-    ((PETSC_VERSION_MINOR < 2) ||  \
-     ((PETSC_VERSION_MINOR == 2) && (PETSC_VERSION_SUBMINOR == 0)))
+#if DEAL_II_PETSC_VERSION_LT(2,2,1)
     const int petsc_row      = row;
 #else
     const PetscInt petsc_row = row;
@@ -152,7 +148,7 @@ namespace PETScWrappers
     IS index_set;
     ISCreateGeneral (get_mpi_communicator(), 1, &petsc_row, &index_set);
 
-#if (PETSC_VERSION_MAJOR <= 2) && (PETSC_VERSION_MINOR <= 2)
+#if DEAL_II_PETSC_VERSION_LT(2,3,0)
     const int ierr
       = MatZeroRows(matrix, index_set, &new_diag_value);
 #else
@@ -177,9 +173,7 @@ namespace PETScWrappers
 
                                      // now set all the entries of these rows
                                      // to zero
-#if (PETSC_VERSION_MAJOR <= 2) && \
-    ((PETSC_VERSION_MINOR < 2) ||  \
-     ((PETSC_VERSION_MINOR == 2) && (PETSC_VERSION_SUBMINOR == 0)))
+#if DEAL_II_PETSC_VERSION_LT(2,2,1)
     const std::vector<int>      petsc_rows (rows.begin(), rows.end());
 #else
     const std::vector<PetscInt> petsc_rows (rows.begin(), rows.end());
@@ -192,7 +186,7 @@ namespace PETScWrappers
     ISCreateGeneral (get_mpi_communicator(), rows.size(),
                      &petsc_rows[0], &index_set);
 
-#if (PETSC_VERSION_MAJOR <= 2) && (PETSC_VERSION_MINOR <= 2)
+#if DEAL_II_PETSC_VERSION_LT(2,3,0)
     const int ierr
       = MatZeroRows(matrix, index_set, &new_diag_value);
 #else
@@ -353,9 +347,7 @@ namespace PETScWrappers
 
                                      // get a representation of the present
                                      // row
- #if (PETSC_VERSION_MAJOR <= 2) && \
-    ((PETSC_VERSION_MINOR < 2) ||  \
-     ((PETSC_VERSION_MINOR == 2) && (PETSC_VERSION_SUBMINOR == 0)))
+#if DEAL_II_PETSC_VERSION_LT(2,2,1)
     int ncols;
     int         *colnums;
     PetscScalar *values;
@@ -426,7 +418,7 @@ namespace PETScWrappers
   MatrixBase &
   MatrixBase::operator *= (const PetscScalar a)
   {
-#if (PETSC_VERSION_MAJOR <= 2) && (PETSC_VERSION_MINOR < 3)
+#if DEAL_II_PETSC_VERSION_LT(2,3,0)
     const int ierr = MatScale (&a, matrix);
 #else
     const int ierr = MatScale (matrix, a);
@@ -443,7 +435,7 @@ namespace PETScWrappers
   {
     const PetscScalar factor = 1./a;
 
-#if (PETSC_VERSION_MAJOR <= 2) && (PETSC_VERSION_MINOR < 3)
+#if DEAL_II_PETSC_VERSION_LT(2,3,0)
     const int ierr = MatScale (&factor, matrix);
 #else
     const int ierr = MatScale (matrix, factor);
@@ -551,7 +543,7 @@ namespace PETScWrappers
   {
     int ierr;
 
-#if (PETSC_VERSION_MAJOR <= 2)
+#if DEAL_II_PETSC_VERSION_LT(3,0,0)
     ierr = MatTranspose(matrix, PETSC_NULL);
 #else
     ierr = MatTranspose(matrix, MAT_REUSE_MATRIX, &matrix);
@@ -577,7 +569,7 @@ namespace PETScWrappers
                                     // First flush PETSc caches
     compress ();
 
-#if (PETSC_VERSION_MAJOR <= 2)
+#if DEAL_II_PETSC_VERSION_LT(3,0,0)
                                     // avoid warning about unused variables
     (void) tolerance;
 
@@ -595,7 +587,7 @@ namespace PETScWrappers
     compress ();
 
                                        // Set options
-#if (PETSC_VERSION_MAJOR <= 2)
+#if DEAL_II_PETSC_VERSION_LT(3,0,0)
     PetscViewerSetFormat (PETSC_VIEWER_STDOUT_WORLD,
                          PETSC_VIEWER_ASCII_DEFAULT);
 #else
index 1d998b3e999e01bea4e68e423f57c1aa90bc2959..02328ba8536dcfd074dcfcd9f3672e322e0a2087 100644 (file)
@@ -192,7 +192,7 @@ namespace PETScWrappers
                                        // set symmetric flag, if so requested
       if (is_symmetric == true)
         {
-#if (PETSC_VERSION_MAJOR <= 2)
+#if DEAL_II_PETSC_VERSION_LT(3,0,0)
           const int ierr
             = MatSetOption (matrix, MAT_SYMMETRIC);
 #else
@@ -258,7 +258,7 @@ namespace PETScWrappers
                                        // set symmetric flag, if so requested
       if (is_symmetric == true)
         {
-#if (PETSC_VERSION_MAJOR <= 2)
+#if DEAL_II_PETSC_VERSION_LT(3,0,0)
           const int ierr
             = MatSetOption (matrix, MAT_SYMMETRIC);
 #else
@@ -368,9 +368,7 @@ namespace PETScWrappers
                                        // available. if we don't have this, we
                                        // have to somehow clumsily work around
                                        // the whole thing:
-#if (PETSC_VERSION_MAJOR <= 2) && \
-    ((PETSC_VERSION_MINOR < 2) ||  \
-     ((PETSC_VERSION_MINOR == 2) && (PETSC_VERSION_SUBMINOR == 0)))
+#if DEAL_II_PETSC_VERSION_LT(2,2,1)
 
 #ifdef PETSC_USE_64BIT_INDICES
           std::vector<PetscInt>
@@ -489,7 +487,7 @@ namespace PETScWrappers
                                           // further entries, so PETSc can
                                           // internally optimize some data
                                           // structures.
-#if (PETSC_VERSION_MAJOR <= 2)
+#if DEAL_II_PETSC_VERSION_LT(3,0,0)
           const int ierr =
            MatSetOption (matrix, MAT_NO_NEW_NONZERO_LOCATIONS);
 #else
index b2bc95b8f241e967bbd745a1a431d8a3af3021b1..7ceeae2f68b0c0983dc20c23c1066bedf6c4be2a 100644 (file)
@@ -234,10 +234,7 @@ namespace PETScWrappers
     AssertThrow (ierr == 0, ExcPETScError(ierr));
 
                                      // then set flags
-#if ((PETSC_VERSION_MAJOR == 2) && \
-     ((PETSC_VERSION_MINOR < 3) || \
-      ((PETSC_VERSION_MINOR == 3) && \
-       (PETSC_VERSION_SUBMINOR < 1))))
+#if DEAL_II_PETSC_VERSION_LT(2,3,1)
     PCICCSetLevels (pc, additional_data.levels);
 #else
     PCFactorSetLevels (pc, additional_data.levels);
@@ -277,10 +274,7 @@ namespace PETScWrappers
     AssertThrow (ierr == 0, ExcPETScError(ierr));
 
                                      // then set flags
-#if ((PETSC_VERSION_MAJOR == 2) && \
-     ((PETSC_VERSION_MINOR < 3) || \
-      ((PETSC_VERSION_MINOR == 3) && \
-       (PETSC_VERSION_SUBMINOR < 1))))
+#if DEAL_II_PETSC_VERSION_LT(2,3,1)
     PCILUSetLevels (pc, additional_data.levels);  
 #else
     PCFactorSetLevels (pc, additional_data.levels);
@@ -324,17 +318,14 @@ namespace PETScWrappers
     AssertThrow (ierr == 0, ExcPETScError(ierr));
 
                                      // set flags as given
-#if ((PETSC_VERSION_MAJOR == 2) && \
-     ((PETSC_VERSION_MINOR < 3) || \
-      ((PETSC_VERSION_MINOR == 3) && \
-       (PETSC_VERSION_SUBMINOR < 1))))
+#if DEAL_II_PETSC_VERSION_LT(2,3,1)
     ierr = PCLUSetPivoting (pc, additional_data.pivoting);
 #else
     ierr = PCFactorSetPivoting (pc, additional_data.pivoting);
 #endif
     AssertThrow (ierr == 0, ExcPETScError(ierr));
 
-#if (PETSC_VERSION_MAJOR == 2) && (PETSC_VERSION_MINOR < 3)
+#if DEAL_II_PETSC_VERSION_LT(2,3,0)
     ierr = PCLUSetZeroPivot (pc, additional_data.zero_pivot);
 #else
     ierr = PCFactorSetZeroPivot (pc, additional_data.zero_pivot);
@@ -342,7 +333,7 @@ namespace PETScWrappers
     
     AssertThrow (ierr == 0, ExcPETScError(ierr));
 
-#if (PETSC_VERSION_MAJOR == 2) && (PETSC_VERSION_MINOR < 3)
+#if DEAL_II_PETSC_VERSION_LT(2,3,0)
     ierr = PCLUSetDamping (pc, additional_data.damping);
 #else
     ierr = PCFactorSetShiftNonzero (pc, additional_data.damping);
index b8e2b7ceb89228de6268ddd638f5a9e85928e35f..cb4aa99173abdda987d66f2380e31462505190f0 100644 (file)
@@ -21,8 +21,8 @@
 #  include <lac/petsc_precondition.h>
 #  include <cmath>
 
-#if (PETSC_VERSION_MAJOR == 2) && (PETSC_VERSION_MINOR < 2)
-#  include <petscsles.h>
+#if DEAL_II_PETSC_VERSION_LT(2,2,0)
+#include <petscsles.h>
 #endif
 #include <petscversion.h>
 
@@ -75,7 +75,8 @@ namespace PETScWrappers
                                      // us to work around this by offering two
                                      // completely different
                                      // implementations. sigh...
-#if (PETSC_VERSION_MAJOR == 2) && (PETSC_VERSION_MINOR < 2)
+#if DEAL_II_PETSC_VERSION_LT(2,2,0)
+
                                      // first create a solver object
     SLES sles;
     ierr = SLESCreate (mpi_communicator, &sles);
@@ -163,7 +164,7 @@ namespace PETScWrappers
                                          // checks with the solver_control
                                          // object we have in this object for
                                          // convergence
-#if (PETSC_VERSION_MAJOR <= 2)
+#if DEAL_II_PETSC_VERSION_LT(3,0,0)
         KSPSetConvergenceTest (solver_data->ksp, &convergence_test,
                                reinterpret_cast<void *>(&solver_control));
 #else
@@ -179,7 +180,7 @@ namespace PETScWrappers
                                      // 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)
+#if DEAL_II_PETSC_VERSION_LT(2,2,1)
     ierr = KSPSetRhs(solver_data->ksp,b);
     AssertThrow (ierr == 0, ExcPETScError(ierr));
     ierr = KSPSetSolution(solver_data->ksp, x);
index cd6c2e3796ca55510cf1181080ae5197f973a632..afe6050a561ff1fcd0336ce3ef537e0213723459 100644 (file)
@@ -149,7 +149,7 @@ namespace PETScWrappers
                                      // set symmetric flag, if so requested
     if (is_symmetric == true)
       {
-#if (PETSC_VERSION_MAJOR <= 2)
+#if DEAL_II_PETSC_VERSION_LT(3,0,0)
         const int ierr
           = MatSetOption (matrix, MAT_SYMMETRIC);
 #else
@@ -194,7 +194,7 @@ namespace PETScWrappers
                                      // set symmetric flag, if so requested
     if (is_symmetric == true)
       {
-#if (PETSC_VERSION_MAJOR <= 2)
+#if DEAL_II_PETSC_VERSION_LT(3,0,0)
         const int ierr
           = MatSetOption (matrix, MAT_SYMMETRIC);
 #else
@@ -264,7 +264,7 @@ namespace PETScWrappers
                                        // In the end, tell the matrix that
                                        // it should not expect any new
                                        // entries.
-#if (PETSC_VERSION_MAJOR <= 2)
+#if DEAL_II_PETSC_VERSION_LT(3,0,0)
        const int ierr =
          MatSetOption (matrix, MAT_NO_NEW_NONZERO_LOCATIONS);
 #else
index 259e8a15669d164254aeb47658eed1b296800505..9f6550833d56f57692a1b4f7682252b87ffa9e17 100644 (file)
@@ -138,7 +138,7 @@ namespace PETScWrappers
                                      // (see test bits/petsc_65)
     compress ();
 
-#if (PETSC_VERSION_MAJOR <= 2) && (PETSC_VERSION_MINOR < 3)
+#if DEAL_II_PETSC_VERSION_LT(2,3,0)
     const int ierr = VecSet (&s, vector);
 #else
     const int ierr = VecSet (vector, s);
@@ -597,7 +597,7 @@ namespace PETScWrappers
     Assert (numbers::is_finite(a),
            ExcMessage("The given value is not finite but either infinite or Not A Number (NaN)"));
 
-#if (PETSC_VERSION_MAJOR <= 2) && (PETSC_VERSION_MINOR < 3)
+#if DEAL_II_PETSC_VERSION_LT(2,3,0)
     const int ierr = VecScale (&a, vector);
 #else
     const int ierr = VecScale (vector, a);
@@ -622,7 +622,7 @@ namespace PETScWrappers
     Assert (numbers::is_finite(factor),
            ExcMessage("The given value is not finite but either infinite or Not A Number (NaN)"));
 
-#if (PETSC_VERSION_MAJOR <= 2) && (PETSC_VERSION_MINOR < 3)
+#if DEAL_II_PETSC_VERSION_LT(2,3,0)
     const int ierr = VecScale (&factor, vector);
 #else
     const int ierr = VecScale (vector, factor);
@@ -638,7 +638,7 @@ namespace PETScWrappers
   VectorBase &
   VectorBase::operator += (const VectorBase &v)
   {
-#if (PETSC_VERSION_MAJOR <= 2) && (PETSC_VERSION_MINOR < 3)
+#if DEAL_II_PETSC_VERSION_LT(2,3,0)
     const PetscScalar one = 1.0;
     const int ierr = VecAXPY (&one, v, vector);
 #else
@@ -655,7 +655,7 @@ namespace PETScWrappers
   VectorBase &
   VectorBase::operator -= (const VectorBase &v)
   {
-#if (PETSC_VERSION_MAJOR <= 2) && (PETSC_VERSION_MINOR < 3)
+#if DEAL_II_PETSC_VERSION_LT(2,3,0)
     const PetscScalar minus_one = -1.0;
     const int ierr = VecAXPY (&minus_one, v, vector);
 #else
@@ -676,7 +676,7 @@ namespace PETScWrappers
     Assert (numbers::is_finite(s),
            ExcMessage("The given value is not finite but either infinite or Not A Number (NaN)"));
 
-#if (PETSC_VERSION_MAJOR <= 2) && (PETSC_VERSION_MINOR < 3)
+#if DEAL_II_PETSC_VERSION_LT(2,3,0)
     const int ierr = VecShift (&s, vector);
 #else
     const int ierr = VecShift (vector, s);
@@ -703,7 +703,7 @@ namespace PETScWrappers
     Assert (numbers::is_finite(a),
            ExcMessage("The given value is not finite but either infinite or Not A Number (NaN)"));
 
-#if (PETSC_VERSION_MAJOR <= 2) && (PETSC_VERSION_MINOR < 3)
+#if DEAL_II_PETSC_VERSION_LT(2,3,0)
     const int ierr = VecAXPY (&a, v, vector);
 #else
     const int ierr = VecAXPY (vector, a, v);
@@ -729,7 +729,7 @@ namespace PETScWrappers
     const PetscScalar weights[2] = {a,b};
     Vec               addends[2] = {v.vector, w.vector};
 
-#if (PETSC_VERSION_MAJOR <= 2) && (PETSC_VERSION_MINOR < 3)
+#if DEAL_II_PETSC_VERSION_LT(2,3,0)
     const int ierr = VecMAXPY (2, weights, vector, addends);
 #else
     const int ierr = VecMAXPY (vector, 2, weights, addends);
@@ -748,7 +748,7 @@ namespace PETScWrappers
     Assert (numbers::is_finite(s),
            ExcMessage("The given value is not finite but either infinite or Not A Number (NaN)"));
 
-#if (PETSC_VERSION_MAJOR <= 2) && (PETSC_VERSION_MINOR < 3)
+#if DEAL_II_PETSC_VERSION_LT(2,3,0)
     const int ierr = VecAYPX (&s, v, vector);
 #else
     const int ierr = VecAYPX (vector, s, v);
@@ -801,7 +801,7 @@ namespace PETScWrappers
     const PetscScalar weights[2] = {a,b};
     Vec               addends[2] = {v.vector,w.vector};
 
-#if (PETSC_VERSION_MAJOR <= 2) && (PETSC_VERSION_MINOR < 3)
+#if DEAL_II_PETSC_VERSION_LT(2,3,0)
     const int ierr = VecMAXPY (2, weights, vector, addends);
 #else
     const int ierr = VecMAXPY (vector, 2, weights, addends);
@@ -838,7 +838,7 @@ namespace PETScWrappers
     const PetscScalar weights[3] = {a,b,c};
     Vec               addends[3] = {v.vector, w.vector, x.vector};
 
-#if (PETSC_VERSION_MAJOR <= 2) && (PETSC_VERSION_MINOR < 3)
+#if DEAL_II_PETSC_VERSION_LT(2,3,0)
     const int ierr = VecMAXPY (3, weights, vector, addends);
 #else
     const int ierr = VecMAXPY (vector, 3, weights, addends);
@@ -911,7 +911,7 @@ namespace PETScWrappers
   VectorBase::ratio (const VectorBase &a,
                      const VectorBase &b)
   {
-#if (PETSC_VERSION_MAJOR <= 2) && (PETSC_VERSION_MINOR < 3)
+#if DEAL_II_PETSC_VERSION_LT(2,3,0)
     const int ierr = VecPointwiseDivide (a, b, vector);
 #else
     const int ierr = VecPointwiseDivide (vector, a, b);

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.