dune-pdelab  2.0.0
petscutility.hh
Go to the documentation of this file.
1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 #ifndef DUNE_PETSCUTILITY_HH
4 #define DUNE_PETSCUTILITY_HH
5 
6 #if HAVE_PETSC
7 
8 #include <petscsys.h>
9 #include <petscversion.h>
10 #include <dune/common/exceptions.hh>
11 
12 namespace Dune {
13  namespace PDELab {
14 
15  class PetscException
16  : public Dune::Exception
17  {};
18 
19  } // namespace PDELab
20 } // namespace Dune
21 
22 
23 #define PETSC_GUARD_START {
24 
25 #define PETSC_GUARD_END(err_var) \
26  if (err_var != 0) DUNE_THROW(Dune::PDELab::PetscException,"PETSc problem"); \
27 }
28 
29 #define PETSC_CALL(x) \
30 PETSC_GUARD_START \
31 PetscErrorCode __petsc_err = (x); \
32 PETSC_GUARD_END(__petsc_err)
33 
34 
35 #define DUNE_PETSC_NEWER(MAJOR,MINOR,SUBMINOR) \
36  PETSC_VERSION_MAJOR > MAJOR || \
37  (PETSC_VERSION_MAJOR >= MAJOR && \
38  PETSC_VERSION_MINOR >= MINOR && \
39  PETSC_VERSION_SUBMINOR >= SUBMINOR)
40 
41 #endif // HAVE_PETSC
42 
43 #endif // DUNE_PETSCUTILITY_HH