// get a representation of the present
// row
-#if DEAL_II_PETSC_VERSION_LT(2,2,1)
- int ncols;
- int *colnums;
- PetscScalar *values;
-#else
PetscInt ncols;
const PetscInt *colnums;
const PetscScalar *values;
-#endif
int ierr;
ierr = MatGetRow(*matrix, this->a_row, &ncols, &colnums, &values);
// now set all the entries of this row to
// zero
-#if DEAL_II_PETSC_VERSION_LT(2,2,1)
- const int petsc_row = row;
-#else
const PetscInt petsc_row = row;
-#endif
IS index_set;
#if DEAL_II_PETSC_VERSION_LT(3,2,0)
ISCreateGeneral (get_mpi_communicator(), 1, &petsc_row, PETSC_COPY_VALUES, &index_set);
#endif
-
-#if DEAL_II_PETSC_VERSION_LT(2,3,0)
- const int ierr
- = MatZeroRows(matrix, index_set, &new_diag_value);
-#else
#if DEAL_II_PETSC_VERSION_LT(3,2,0)
const int ierr
= MatZeroRowsIS(matrix, index_set, new_diag_value);
const int ierr
= MatZeroRowsIS(matrix, index_set, new_diag_value, PETSC_NULL, PETSC_NULL);
#endif
-#endif
-
AssertThrow (ierr == 0, ExcPETScError(ierr));
#if DEAL_II_PETSC_VERSION_LT(3,2,0)
// now set all the entries of these rows
// to zero
-#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());
-#endif
// call the functions. note that we have
// to call them even if #rows is empty,
&petsc_rows[0], PETSC_COPY_VALUES, &index_set);
#endif
-#if DEAL_II_PETSC_VERSION_LT(2,3,0)
- const int ierr
- = MatZeroRows(matrix, index_set, &new_diag_value);
-#else
#if DEAL_II_PETSC_VERSION_LT(3,2,0)
const int ierr
= MatZeroRowsIS(matrix, index_set, new_diag_value);
const int ierr
= MatZeroRowsIS(matrix, index_set, new_diag_value, PETSC_NULL, PETSC_NULL);
#endif
-#endif
-
AssertThrow (ierr == 0, ExcPETScError(ierr));
#if DEAL_II_PETSC_VERSION_LT(3,2,0)
// get a representation of the present
// row
-#if DEAL_II_PETSC_VERSION_LT(2,2,1)
- int ncols;
- int *colnums;
- PetscScalar *values;
-#else
PetscInt ncols;
const PetscInt *colnums;
const PetscScalar *values;
-#endif
//TODO: this is probably horribly inefficient; we should lobby for a way to
//query this information from PETSc
MatrixBase &
MatrixBase::operator *= (const PetscScalar a)
{
-#if DEAL_II_PETSC_VERSION_LT(2,3,0)
- const int ierr = MatScale (&a, matrix);
-#else
const int ierr = MatScale (matrix, a);
-#endif
AssertThrow (ierr == 0, ExcPETScError(ierr));
return *this;
MatrixBase::operator /= (const PetscScalar a)
{
const PetscScalar factor = 1./a;
-
-#if DEAL_II_PETSC_VERSION_LT(2,3,0)
- const int ierr = MatScale (&factor, matrix);
-#else
const int ierr = MatScale (matrix, factor);
-#endif
AssertThrow (ierr == 0, ExcPETScError(ierr));
void
MatrixBase::transpose ()
{
- int ierr;
-
-#if DEAL_II_PETSC_VERSION_LT(3,0,0)
- ierr = MatTranspose(matrix, PETSC_NULL);
-#else
- ierr = MatTranspose(matrix, MAT_REUSE_MATRIX, &matrix);
-#endif
-
+ int ierr = MatTranspose(matrix, MAT_REUSE_MATRIX, &matrix);
AssertThrow (ierr == 0, ExcPETScError(ierr));
}
// First flush PETSc caches
compress ();
-
-#if DEAL_II_PETSC_VERSION_LT(3,0,0)
- // avoid warning about unused variables
- (void) tolerance;
-
- MatIsHermitian (matrix, &truth);
-#else
MatIsHermitian (matrix, tolerance, &truth);
-#endif
+
return truth;
}
compress ();
// Set options
-#if DEAL_II_PETSC_VERSION_LT(3,0,0)
- PetscViewerSetFormat (PETSC_VIEWER_STDOUT_WORLD,
- PETSC_VIEWER_ASCII_DEFAULT);
-#else
PetscViewerSetFormat (PETSC_VIEWER_STDOUT_WORLD,
PETSC_VIEWER_DEFAULT);
-#endif
+
// Write to screen
MatView (matrix,PETSC_VIEWER_STDOUT_WORLD);
}
// checks with the solver_control
// object we have in this object for
// convergence
-#if DEAL_II_PETSC_VERSION_LT(3,0,0)
- KSPSetConvergenceTest (solver_data->ksp, &convergence_test,
- reinterpret_cast<void *>(&solver_control));
-#else
KSPSetConvergenceTest (solver_data->ksp, &convergence_test,
reinterpret_cast<void *>(&solver_control),
PETSC_NULL);
-#endif
-
}
// set the command line option prefix name
// problem in PETSc 2.1.6, where it asks
// for a char*, even though KSPXXXX is of
// type const char*
- int ierr;
-
-#if DEAL_II_PETSC_VERSION_LT(3,3,0)
- ierr = KSPSetType (ksp, const_cast<char *>(KSPCHEBYCHEV));
-#else
- ierr = KSPSetType (ksp, const_cast<char *>(KSPCHEBYSHEV));
-#endif
+ int ierr = KSPSetType (ksp, const_cast<char *>(KSPCHEBYSHEV));
AssertThrow (ierr == 0, ExcPETScError(ierr));
// in the deal.II solvers, we always
* that checks with the solver_control
* object for convergence
*/
-#if DEAL_II_PETSC_VERSION_LT(3,0,0)
- KSPSetConvergenceTest (solver_data->ksp, &convergence_test,
- reinterpret_cast<void *>(&solver_control));
-#else
KSPSetConvergenceTest (solver_data->ksp, &convergence_test,
reinterpret_cast<void *>(&solver_control),
PETSC_NULL);
-#endif
/**
* set the software that is to be