From a7df39b6231347188923002a366fee024a43ea35 Mon Sep 17 00:00:00 2001 From: Alex Lindsay Date: Mon, 23 Dec 2024 16:17:13 -0700 Subject: [PATCH] More guards --- .../miscellaneous_ex17/miscellaneous_ex17.C | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/examples/miscellaneous/miscellaneous_ex17/miscellaneous_ex17.C b/examples/miscellaneous/miscellaneous_ex17/miscellaneous_ex17.C index abcc2ace83..f22c6f043e 100644 --- a/examples/miscellaneous/miscellaneous_ex17/miscellaneous_ex17.C +++ b/examples/miscellaneous/miscellaneous_ex17/miscellaneous_ex17.C @@ -29,14 +29,12 @@ #include "libmesh/fe.h" // Define Gauss quadrature rules. -#include "libmesh/petsc_solver_exception.h" -#include "libmesh/petsc_vector.h" #include "libmesh/quadrature_gauss.h" // Define useful datatypes for finite element // matrix and vector components. -#include "libmesh/petsc_matrix.h" #include "libmesh/numeric_vector.h" +#include "libmesh/sparse_matrix.h" #include "libmesh/dense_matrix.h" #include "libmesh/dense_vector.h" #include "libmesh/elem.h" @@ -45,7 +43,11 @@ // Define the DofMap, which handles degree of freedom // indexing. #include "libmesh/dof_map.h" + #ifdef LIBMESH_HAVE_PETSC +// include PETSc headers +#include "libmesh/petsc_matrix.h" +#include "libmesh/petsc_vector.h" #include "petscksp.h" #endif @@ -67,9 +69,6 @@ int main (int argc, char ** argv) // Initialize libraries, like in example 2. LibMeshInit init (argc, argv); - // This example requires a linear solver package. - libmesh_example_requires(libMesh::default_solver_package() == PETSC_SOLVERS, "--enable-petsc"); - // Brief message to the user regarding the program name // and command line arguments. libMesh::out << "Running " << argv[0]; @@ -116,7 +115,11 @@ int main (int argc, char ** argv) // Add the preconditioner matrix auto & pre_sparse_matrix = system.add_matrix("preconditioner"); +#ifdef LIBMESH_HAVE_PETSC +#if PETSC_RELEASE_GREATER_EQUALS(3, 19, 0) pre_sparse_matrix.use_hash_table(true); +#endif +#endif // Initialize the data structures for the equation system. equation_systems.init(); @@ -149,6 +152,8 @@ int main (int argc, char ** argv) // solve solve(); + + // MatResetHash added in PETSc version 3.23 #if !PETSC_VERSION_LESS_THAN(3, 23, 0) // reset the memory // sys_matrix.reset_memory(); # See https://gitlab.com/petsc/petsc/-/merge_requests/8063