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" 26 #include "libmesh/petsc_macro.h" 30 # define LIBMESH_SAW_I 33 #include "libmesh/ignore_warnings.h" 35 #include "libmesh/restore_warnings.h" 38 # undef I // Avoid complex.h contamination 45 #ifdef LIBMESH_ENABLE_EXCEPTIONS 58 auto ierr = PetscErrorMessage(cast_int<PetscErrorCode>(
error_code), &text, &specific);
77 #define LIBMESH_CHKERRQ(ierr) \ 80 throw libMesh::PetscSolverException(ierr); \ 86 #define LIBMESH_CHKERRA(comm, ierr) \ 88 libmesh_ignore(comm); \ 89 LIBMESH_CHKERRQ(ierr); \ 96 #define LIBMESH_CHKERRQ(ierr) CHKERRQ(ierr); 97 #define LIBMESH_CHKERRA(comm, ierr) CHKERRABORT(comm, ierr); 101 #define PETSC_BEGIN_END(Function) \ 102 template<class ...Args> \ 104 void Function ## BeginEnd(const Parallel::Communicator & comm, const Args&... args) \ 106 PetscErrorCode ierr = LIBMESH_PETSC_SUCCESS; \ 107 ierr = Function ## Begin(args...); \ 108 LIBMESH_CHKERRA(comm.get(), ierr); \ 109 ierr = Function ## End(args...); \ 110 LIBMESH_CHKERRA(comm.get(), ierr); \ 113 PETSC_BEGIN_END(VecScatter)
114 PETSC_BEGIN_END(MatAssembly)
115 PETSC_BEGIN_END(VecAssembly)
116 PETSC_BEGIN_END(VecGhostUpdate)
119 #define LibmeshPetscCallQ(...) \ 122 PetscErrorCode libmesh_petsc_call_ierr; \ 123 libmesh_petsc_call_ierr = __VA_ARGS__; \ 124 LIBMESH_CHKERRQ(libmesh_petsc_call_ierr); \ 128 #define LibmeshPetscCallA(comm, ...) \ 131 PetscErrorCode libmesh_petsc_call_ierr; \ 132 libmesh_petsc_call_ierr = __VA_ARGS__; \ 133 LIBMESH_CHKERRA(comm, libmesh_petsc_call_ierr); \ 138 #define LibmeshPetscCall(...) \ 139 LibmeshPetscCallA(this->comm().get(), __VA_ARGS__) 143 #define LibmeshPetscCall2(comm, ...) \ 144 LibmeshPetscCallA(comm.get(), __VA_ARGS__) 146 #ifdef LIBMESH_ENABLE_EXCEPTIONS 147 #define LibmeshPetscCallExternal(func, ...) \ 149 const auto libmesh_petsc_call_external_ierr = cast_int<int>(func(__VA_ARGS__)); \ 150 if (libmesh_petsc_call_external_ierr != 0) \ 151 throw PetscSolverException(libmesh_petsc_call_external_ierr); \ 154 #define LibmeshPetscCallExternal(func, ...) \ 156 const auto libmesh_petsc_call_external_ierr = cast_int<int>(func(__VA_ARGS__)); \ 157 if (libmesh_petsc_call_external_ierr != 0) \ 158 libmesh_terminate_handler(); \ 165 #endif // LIBMESH_HAVE_PETSC 166 #endif // LIBMESH_PETSC_SOLVER_EXCEPTION_H int error_code
The error code generated by the solver.
The libMesh namespace provides an interface to certain functionality in the library.
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.
void libmesh_ignore(const Args &...)