18 #ifndef LIBMESH_PETSC_SOLVER_EXCEPTION_H
19 #define LIBMESH_PETSC_SOLVER_EXCEPTION_H
21 #include "libmesh/libmesh_common.h"
23 #ifdef LIBMESH_HAVE_PETSC
25 #include "libmesh/libmesh_exceptions.h"
28 # define LIBMESH_SAW_I
31 #include "libmesh/ignore_warnings.h"
33 #include "libmesh/restore_warnings.h"
36 # undef I // Avoid complex.h contamination
49 #ifdef LIBMESH_ENABLE_EXCEPTIONS
64 PetscErrorMessage(
error_code, &text, &specific);
79 #define LIBMESH_CHKERR(ierr) \
82 throw PetscSolverException(ierr); \
89 #define LIBMESH_CHKERR2(comm, ierr) \
91 libmesh_ignore(comm); \
92 LIBMESH_CHKERR(ierr); \
99 #define LIBMESH_CHKERR(ierr) CHKERRABORT(this->comm().get(), ierr);
103 #define LIBMESH_CHKERR2(comm, ierr) CHKERRABORT(comm.get(), ierr);
106 #define LIBMESH_CHKERRABORT(ierr) LIBMESH_CHKERR(ierr)
110 #define PETSC_BEGIN_END(Function) \
111 template<class ...Args> \
113 void Function ## BeginEnd(const Parallel::Communicator & comm, const Args&... args) \
115 PetscErrorCode ierr = 0; \
116 ierr = Function ## Begin(args...); \
117 LIBMESH_CHKERR2(comm, ierr); \
118 ierr = Function ## End(args...); \
119 LIBMESH_CHKERR2(comm, ierr); \
122 PETSC_BEGIN_END(VecScatter)
123 PETSC_BEGIN_END(MatAssembly)
124 PETSC_BEGIN_END(VecAssembly)
125 PETSC_BEGIN_END(VecGhostUpdate)
129 #endif // LIBMESH_HAVE_PETSC
130 #endif // LIBMESH_PETSC_SOLVER_EXCEPTION_H
int error_code
The error code generated by the solver.
PetscSolverException(int error_code_in)
std::string what_message
string which holds the message built in the constructor.
A class representing an exception during a solve.
A specialization of the SolverException class for PETSc.