SET(${var} TRUE)
#
- # We support petsc from version 3.x.x onwards
+ # We support petsc from version 3.3.x onwards
#
- IF(PETSC_VERSION_MAJOR LESS 3)
+ IF(PETSC_VERSION_MAJOR LESS 3 OR
+ ((PETSC_VERSION_MAJOR EQUAL 3) AND (PETSC_VERSION_MINOR LESS 3)))
MESSAGE(STATUS "Could not find a sufficient modern PETSc installation: "
- "Version >=3.0.0 required!"
+ "Version >=3.3.0 required!"
)
SET(PETSC_ADDITIONAL_ERROR_STRING
"Could not find a sufficient modern PETSc installation: "
- "Version >=3.0.0 required!\n"
+ "Version >=3.3.0 required!\n"
)
SET(${var} FALSE)
ENDIF()
MESSAGE(FATAL_ERROR "\n"
"Could not find the petsc library!\n"
${PETSC_ADDITIONAL_ERROR_STRING}
- "\nPlease ensure that the petsc library version 3.0.0 or newer is "
+ "\nPlease ensure that the petsc library version 3.3.0 or newer is "
"installed on your computer and is configured with the same mpi options "
"as deal.II\n"
"If the library is not at a default location, either provide some hints\n"
<p style="color: red"><b>Note:</b> The most recent version of PETSc
that has been reported to be compatible with
- <acronym>deal.II</acronym> is version 3.6.0. If you use a later
- version than this and encounter problems, let us know.
+ <acronym>deal.II</acronym> is version 3.7.6. If you use a later
+ version than this and encounter problems, let us
+ know. <acronym>deal.II</acronym> does not support versions of PETSc prior
+ to 3.3.0.
</p>
<p>
--- /dev/null
+Changed: Versions of PETSc prior to 3.3.0 are no longer supported.
+<br>
+(David Wells, 2017/06/03)
namespace PETScWrappers
{
-#if DEAL_II_PETSC_VERSION_LT(3,2,0)
- typedef PetscTruth PetscBooleanType;
-#else
- typedef PetscBool PetscBooleanType;
-#endif
+ /**
+ * a compatibility typedef for older versions of PETSc.
+ *
+ * @deprecated The name of this type changed in PETSc 3.2: deal.II does not
+ * support versions of PETSc older than this so this typedef will be removed
+ * in a future release.
+ */
+ typedef PetscBool PetscBooleanType DEAL_II_DEPRECATED;
/**
* Set an option in the global PETSc database. This function just wraps
inline PetscErrorCode destroy_matrix (Mat &matrix)
{
// PETSc will check whether or not matrix is nullptr.
-#if DEAL_II_PETSC_VERSION_LT(3, 2, 0)
- return MatDestroy (matrix);
-#else
return MatDestroy (&matrix);
-#endif
}
inline PetscErrorCode destroy_krylov_solver (KSP &krylov_solver)
{
// PETSc will check whether or not matrix is nullptr.
-#if DEAL_II_PETSC_VERSION_LT(3, 2, 0)
- return KSPDestroy (krylov_solver);
-#else
return KSPDestroy (&krylov_solver);
-#endif
}
*/
inline void set_matrix_option (Mat &matrix,
const MatOption option_name,
- const PetscBooleanType option_value = PETSC_FALSE)
+ const PetscBool option_value = PETSC_FALSE)
{
-#if DEAL_II_PETSC_VERSION_LT(3,0,0)
- const PetscErrorCode ierr = MatSetOption (matrix, option_name);
-#else
const PetscErrorCode ierr = MatSetOption (matrix, option_name, option_value);
-#endif
-
AssertThrow (ierr == 0, ExcPETScError(ierr));
}
*/
inline void close_matrix (Mat &matrix)
{
-#if DEAL_II_PETSC_VERSION_LT(3, 0, 0)
-# ifdef DEBUG
- set_matrix_option (matrix, MAT_NEW_NONZERO_LOCATION_ERR);
-# else
- set_matrix_option (matrix, MAT_NO_NEW_NONZERO_LOCATIONS);
-# endif
-#else
# ifdef DEBUG
set_matrix_option (matrix, MAT_NEW_NONZERO_LOCATION_ERR, PETSC_TRUE);
# else
set_matrix_option (matrix, MAT_NEW_NONZERO_LOCATIONS, PETSC_FALSE);
# endif
-#endif
}
*/
inline void set_keep_zero_rows (Mat &matrix)
{
-#if DEAL_II_PETSC_VERSION_LT(3, 1, 0)
- set_matrix_option (matrix, MAT_KEEP_ZEROED_ROWS, PETSC_TRUE);
-#else
set_matrix_option (matrix, MAT_KEEP_NONZERO_PATTERN, PETSC_TRUE);
-#endif
}
}
PetscScalar matrix_scalar_product (const VectorBase &u,
const VectorBase &v) const;
-
-#if DEAL_II_PETSC_VERSION_GTE(3,1,0)
/**
* Return the trace of the matrix, i.e. the sum of all diagonal entries in
* the matrix.
*/
PetscScalar trace () const;
-#endif
/**
* Multiply the entire matrix by a fixed factor.
// One could still build a vector that is rich in the directions of all guesses,
// by taking a linear combination of them. (TODO: make function virtual?)
-#if DEAL_II_PETSC_VERSION_LT(3,1,0)
- const PetscErrorCode ierr = EPSSetInitialVector (eps, &vecs[0]);
-#else
const PetscErrorCode ierr = EPSSetInitialSpace (eps, vecs.size(), &vecs[0]);
-#endif
AssertThrow (ierr == 0, ExcSLEPcError(ierr));
}
ierr = VecRestoreArray (sequential_vector, &start_ptr);
AssertThrow (ierr == 0, ExcPETScError(ierr));
-#if DEAL_II_PETSC_VERSION_LT(3,2,0)
- ierr = VecScatterDestroy(scatter_context);
- AssertNothrow (ierr == 0, ExcPETScError(ierr));
- ierr = VecDestroy (sequential_vector);
- AssertNothrow (ierr == 0, ExcPETScError(ierr));
-#else
ierr = VecScatterDestroy(&scatter_context);
AssertNothrow (ierr == 0, ExcPETScError(ierr));
ierr = VecDestroy (&sequential_vector);
AssertNothrow (ierr == 0, ExcPETScError(ierr));
-#endif
}
}
// since this is a collective operation
IS index_set;
-#if DEAL_II_PETSC_VERSION_LT(3,2,0)
- ISCreateGeneral (get_mpi_communicator(), rows.size(),
- &petsc_rows[0], &index_set);
-#else
ISCreateGeneral (get_mpi_communicator(), rows.size(),
&petsc_rows[0], PETSC_COPY_VALUES, &index_set);
-#endif
-#if DEAL_II_PETSC_VERSION_LT(3,2,0)
- const PetscErrorCode ierr = MatZeroRowsIS(matrix, index_set, new_diag_value);
-#else
const PetscErrorCode ierr = MatZeroRowsIS(matrix, index_set, new_diag_value,
nullptr, nullptr);
-#endif
AssertThrow (ierr == 0, ExcPETScError(ierr));
-
-#if DEAL_II_PETSC_VERSION_LT(3,2,0)
- ISDestroy (index_set);
-#else
ISDestroy (&index_set);
-#endif
}
}
-#if DEAL_II_PETSC_VERSION_GTE(3,1,0)
PetscScalar
MatrixBase::trace () const
{
return result;
}
-#endif
// use the call sequence indicating only
// a maximal number of elements per row
// for all rows globally
-#if DEAL_II_PETSC_VERSION_LT(3,3,0)
- const PetscErrorCode ierr = MatCreateMPIAIJ
- (communicator,
- local_rows, local_columns,
- m, n,
- n_nonzero_per_row, 0,
- n_offdiag_nonzero_per_row, 0,
- &matrix);
-#else
const PetscErrorCode ierr = MatCreateAIJ
(communicator,
local_rows, local_columns,
n_offdiag_nonzero_per_row, nullptr,
&matrix);
set_matrix_option (matrix, MAT_NEW_NONZERO_ALLOCATION_ERR, PETSC_FALSE);
-#endif
AssertThrow (ierr == 0, ExcPETScError(ierr));
// set symmetric flag, if so requested
offdiag_row_lengths.end());
//TODO: There must be a significantly better way to provide information about the off-diagonal blocks of the matrix. this way, petsc keeps allocating tiny chunks of memory, and gets completely hung up over this
-#if DEAL_II_PETSC_VERSION_LT(3,3,0)
- const PetscErrorCode ierr = MatCreateMPIAIJ
- (communicator,
- local_rows, local_columns,
- m, n,
- 0, &int_row_lengths[0],
- 0, offdiag_row_lengths.size() ? &int_offdiag_row_lengths[0] : 0,
- &matrix);
-#else
const PetscErrorCode ierr = MatCreateAIJ
(communicator,
local_rows, local_columns,
//TODO: Sometimes the actual number of nonzero entries allocated is greater than the number of nonzero entries, which petsc will complain about unless explicitly disabled with MatSetOption. There is probably a way to prevent a different number nonzero elements being allocated in the first place. (See also previous TODO).
set_matrix_option (matrix, MAT_NEW_NONZERO_ALLOCATION_ERR, PETSC_FALSE);
-#endif
AssertThrow (ierr == 0, ExcPETScError(ierr));
// set symmetric flag, if so requested
const size_type
local_row_end = local_row_start + local_rows_per_process[this_process];
-#if DEAL_II_PETSC_VERSION_LT(2,3,3)
- //old version to create the matrix, we
- //can skip calculating the row length
- //at least starting from 2.3.3 (tested,
- //see below)
-
- const size_type
- local_col_end = local_col_start + local_columns_per_process[this_process];
-
- // then count the elements in- and
- // out-of-window for the rows we own
- std::vector<PetscInt>
-
- row_lengths_in_window (local_row_end - local_row_start),
- row_lengths_out_of_window (local_row_end - local_row_start);
- for (size_type row = local_row_start; row<local_row_end; ++row)
- for (size_type c=0; c<sparsity_pattern.row_length(row); ++c)
- {
- const size_type column = sparsity_pattern.column_number(row,c);
-
- if ((column >= local_col_start) &&
- (column < local_col_end))
- ++row_lengths_in_window[row-local_row_start];
- else
- ++row_lengths_out_of_window[row-local_row_start];
- }
-
-
- // create the matrix. completely
- // confusingly, PETSc wants us to pass
- // arrays for the local number of
- // elements that starts with zero for
- // the first _local_ row, i.e. it
- // doesn't index into an array for
- // _all_ rows.
- const PetscErrorCode ierr = MatCreateMPIAIJ(communicator,
- local_rows_per_process[this_process],
- local_columns_per_process[this_process],
- sparsity_pattern.n_rows(),
- sparsity_pattern.n_cols(),
- 0, &row_lengths_in_window[0],
- 0, &row_lengths_out_of_window[0],
- &matrix);
- AssertThrow (ierr == 0, ExcPETScError(ierr));
-
-#else //PETSC_VERSION>=2.3.3
// create the matrix. We
// do not set row length but set the
// correct SparsityPattern later.
ierr = MatSetType(matrix,MATMPIAIJ);
AssertThrow (ierr == 0, ExcPETScError(ierr));
-#endif
-
// next preset the exact given matrix
// entries with zeros, if the user
nullptr);
AssertThrow (ierr == 0, ExcPETScError(ierr));
-#if DEAL_II_PETSC_VERSION_LT(2,3,3)
- // this is only needed for old
- // PETSc versions:
-
- // for some reason, it does not
- // seem to be possible to force
- // actual allocation of actual
- // entries by using the last
- // arguments to the call above. if
- // we don't initialize the entries
- // like in the following loop, then
- // the program is unbearably slow
- // because elements are allocated
- // and accessed in random order,
- // which is not what PETSc likes
- //
- // note that we actually have to
- // set the entries to something
- // non-zero! do the allocation one
- // row at a time
- {
- const std::vector<PetscScalar>
- values (sparsity_pattern.max_entries_per_row(),
- 1.);
-
- for (size_type i=local_row_start; i<local_row_end; ++i)
- {
- PetscInt petsc_i = i;
- ierr = MatSetValues (matrix, 1, &petsc_i,
- sparsity_pattern.row_length(i),
- &colnums_in_window[rowstart_in_window[i-local_row_start]],
- &values[0], INSERT_VALUES);
- AssertThrow (ierr == 0, ExcPETScError(ierr));
- }
- }
-
- compress (VectorOperation::insert);
-
- // set the dummy entries set above
- // back to zero
- *this = 0;
-#endif // version <=2.3.3
-
close_matrix (matrix);
set_keep_zero_rows(matrix);
}
IndexSet
SparseMatrix::locally_owned_domain_indices () const
{
-#if DEAL_II_PETSC_VERSION_LT(3,3,0)
- Assert(false,ExcNotImplemented());
- return IndexSet();
-#else
PetscInt n_rows, n_cols, n_loc_rows, n_loc_cols, min, max;
PetscErrorCode ierr;
indices.compress();
return indices;
-#endif
}
IndexSet
SparseMatrix::locally_owned_range_indices () const
{
-#if DEAL_II_PETSC_VERSION_LT(3,3,0)
- Assert(false,ExcNotImplemented());
- return IndexSet();
-#else
PetscInt n_rows, n_cols, n_loc_rows, n_loc_cols, min, max;
PetscErrorCode ierr;
indices.compress();
return indices;
-#endif
}
}
// so let's go the slow way:
-#if DEAL_II_PETSC_VERSION_LT(3,2,0)
- const PetscErrorCode ierr = VecDestroy (vector);
-#else
const PetscErrorCode ierr = VecDestroy (&vector);
-#endif
AssertThrow (ierr == 0, ExcPETScError(ierr));
create_vector (n, local_sz);
const IndexSet &ghost,
const MPI_Comm &comm)
{
-#if DEAL_II_PETSC_VERSION_LT(3,2,0)
- const PetscErrorCode ierr = VecDestroy (vector);
-#else
const PetscErrorCode ierr = VecDestroy (&vector);
-#endif
AssertThrow (ierr == 0, ExcPETScError(ierr));
communicator = comm;
Vector::reinit (const IndexSet &local,
const MPI_Comm &comm)
{
-#if DEAL_II_PETSC_VERSION_LT(3,2,0)
- const PetscErrorCode ierr = VecDestroy (vector);
-#else
const PetscErrorCode ierr = VecDestroy (&vector);
-#endif
AssertThrow (ierr == 0, ExcPETScError(ierr));
communicator = comm;
if (pc!=nullptr)
{
-#if DEAL_II_PETSC_VERSION_LT(3,2,0)
- PetscErrorCode ierr = PCDestroy(pc);
-#else
PetscErrorCode ierr = PCDestroy(&pc);
-#endif
pc = nullptr;
AssertThrow (ierr == 0, ExcPETScError(ierr));
}
AssertThrow (ierr == 0, ExcPETScError(ierr));
// set flags as given
-#if DEAL_II_PETSC_VERSION_LT(3,0,1)
- ierr = PCFactorSetPivoting (pc, additional_data.pivoting);
-#else
ierr = PCFactorSetColumnPivot (pc, additional_data.pivoting);
-#endif
AssertThrow (ierr == 0, ExcPETScError(ierr));
ierr = PCFactorSetZeroPivot (pc, additional_data.zero_pivot);
AssertThrow (ierr == 0, ExcPETScError(ierr));
-#if DEAL_II_PETSC_VERSION_LT(3,0,1)
- ierr = PCFactorSetShiftNonzero (pc, additional_data.damping);
-#else
ierr = PCFactorSetShiftAmount (pc, additional_data.damping);
-#endif
AssertThrow (ierr == 0, ExcPETScError(ierr));
ierr = PCSetFromOptions (pc);
void
SolverChebychev::set_solver_type (KSP &ksp) const
{
- // set the type of solver. note the
- // completely pointless change in
- // spelling Chebyshev between PETSc 3.2
- // and 3.3...
-#if DEAL_II_PETSC_VERSION_LT(3,3,0)
- PetscErrorCode ierr = KSPSetType (ksp, KSPCHEBYCHEV);
-#else
PetscErrorCode ierr = KSPSetType (ksp, KSPCHEBYSHEV);
-#endif
AssertThrow (ierr == 0, ExcPETScError(ierr));
// in the deal.II solvers, we always
// right
if (additional_data.right_preconditioning)
{
-#if DEAL_II_PETSC_VERSION_LT(3,2,0)
- ierr = KSPSetPreconditionerSide(ksp, PC_RIGHT);
-#else
ierr = KSPSetPCSide(ksp, PC_RIGHT);
-#endif
-
AssertThrow (ierr == 0, ExcPETScError(ierr));
}
* factorization here we start to see differences with the base
* class solve function
*/
-#if DEAL_II_PETSC_VERSION_GTE(3,2,0)
ierr = PCFactorSetMatSolverPackage (solver_data->pc, MATSOLVERMUMPS);
-#else
- ierr = PCFactorSetMatSolverPackage (solver_data->pc, MAT_SOLVER_MUMPS);
-#endif
AssertThrow (ierr == 0, ExcPETScError (ierr));
/**
{
if (attained_ownership)
{
-#if DEAL_II_PETSC_VERSION_LT(3,2,0)
- const PetscErrorCode ierr = VecDestroy (vector);
-#else
const PetscErrorCode ierr = VecDestroy (&vector);
-#endif
AssertNothrow (ierr == 0, ExcPETScError(ierr));
(void) ierr;
}
{
if (attained_ownership)
{
-#if DEAL_II_PETSC_VERSION_LT(3,2,0)
- const PetscErrorCode ierr = VecDestroy (vector);
-#else
const PetscErrorCode ierr = VecDestroy (&vector);
-#endif
AssertThrow (ierr == 0, ExcPETScError(ierr));
}
if (eps != nullptr)
{
// Destroy the solver object.
-#if DEAL_II_PETSC_VERSION_LT(3,2,0)
- const PetscErrorCode ierr = EPSDestroy (eps);
-#else
const PetscErrorCode ierr = EPSDestroy (&eps);
-#endif
+
(void)ierr;
AssertNothrow (ierr == 0, ExcSLEPcError(ierr));
}
ExcMessage("Initial vector should be nonzero."));
Vec vec = this_initial_vector;
-#if DEAL_II_PETSC_VERSION_LT(3,1,0)
- const PetscErrorCode ierr = EPSSetInitialVector (eps, &vec);
-#else
const PetscErrorCode ierr = EPSSetInitialSpace (eps, 1, &vec);
-#endif
+
AssertThrow (ierr == 0, ExcSLEPcError(ierr));
}
SolverBase (cn, mpi_communicator),
additional_data (data)
{
-#if DEAL_II_PETSC_VERSION_GTE(3,1,0)
PetscErrorCode ierr = EPSSetType (eps, const_cast<char *>(EPSGD));
AssertThrow (ierr == 0, ExcSLEPcError(ierr));
ierr = EPSGDSetDoubleExpansion (eps, PETSC_TRUE);
AssertThrow (ierr == 0, ExcSLEPcError(ierr));
}
-#else
- // PETSc/SLEPc version must be > 3.1.0.
- Assert ((false),
- ExcMessage ("Your SLEPc installation does not include a copy of the "
- "Generalized Davidson solver. A SLEPc version > 3.1.0 is required."));
-#endif
}
/* ------------------ Jacobi Davidson -------------------- */
SolverBase (cn, mpi_communicator),
additional_data (data)
{
-#if DEAL_II_PETSC_VERSION_GTE(3,1,0)
const PetscErrorCode ierr = EPSSetType (eps, const_cast<char *>(EPSJD));
AssertThrow (ierr == 0, ExcSLEPcError(ierr));
-#else
- // PETSc/SLEPc version must be > 3.1.0.
- Assert ((false),
- ExcMessage ("Your SLEPc installation does not include a copy of the "
- "Jacobi-Davidson solver. A SLEPc version > 3.1.0 is required."));
-#endif
}
/* ---------------------- LAPACK ------------------------- */
DEAL_II_NAMESPACE_CLOSE
#endif // DEAL_II_WITH_SLEPC
-
TransformationBase(mpi_communicator),
additional_data (data)
{
-#if DEAL_II_PETSC_VERSION_LT(3,1,0)
- PetscErrorCode ierr = STSetType (st, const_cast<char *>(STSINV));
-#else
PetscErrorCode ierr = STSetType (st, const_cast<char *>(STSINVERT));
-#endif
AssertThrow (ierr == 0, SolverBase::ExcSLEPcError(ierr));
ierr = STSetShift (st, additional_data.shift_parameter);