*/
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
* is zero.
*/
PetscTruth is_hermitian (const double tol = 0.0);
+#endif
/*
* Abstract PETSc object that helps view
#ifndef __deal2__petsc_parallel_sparse_matrix_h
#define __deal2__petsc_parallel_sparse_matrix_h
-
#include <base/config.h>
#ifdef DEAL_II_USE_PETSC
// 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;
// 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;
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
// 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());
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
// 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;
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);
{
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);
{
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);
// 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;
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
// 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
// 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
// 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>
// 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
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);
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);
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);
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);
# 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>
// 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);
// 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
// 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);
// 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
// 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
// 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
// (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);
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);
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);
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
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
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);
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);
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);
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);
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);
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);
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);