Skip to content

Commit

Permalink
More guards
Browse files Browse the repository at this point in the history
  • Loading branch information
lindsayad committed Dec 24, 2024
1 parent 5559c3f commit a7df39b
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions examples/miscellaneous/miscellaneous_ex17/miscellaneous_ex17.C
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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

Expand All @@ -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];
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a7df39b

Please sign in to comment.