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 57 #if PETSC_VERSION_LESS_THAN(3,25,0) 60 const char * specific;
62 auto ierr = PetscErrorMessage(cast_int<PetscErrorCode>(
error_code), &text, &specific);
81 #define LIBMESH_CHKERRQ(ierr) \ 84 throw libMesh::PetscSolverException(ierr); \ 90 #define LIBMESH_CHKERRA(comm, ierr) \ 92 libmesh_ignore(comm); \ 93 LIBMESH_CHKERRQ(ierr); \ 100 #define LIBMESH_CHKERRQ(ierr) CHKERRQ(ierr); 101 #define LIBMESH_CHKERRA(comm, ierr) CHKERRABORT(comm, ierr); 105 #define PETSC_BEGIN_END(Function) \ 106 template<class ...Args> \ 108 void Function ## BeginEnd(const Parallel::Communicator & comm, const Args&... args) \ 110 PetscErrorCode ierr = LIBMESH_PETSC_SUCCESS; \ 111 ierr = Function ## Begin(args...); \ 112 LIBMESH_CHKERRA(comm.get(), ierr); \ 113 ierr = Function ## End(args...); \ 114 LIBMESH_CHKERRA(comm.get(), ierr); \ 117 PETSC_BEGIN_END(VecScatter)
118 PETSC_BEGIN_END(MatAssembly)
119 PETSC_BEGIN_END(VecAssembly)
120 PETSC_BEGIN_END(VecGhostUpdate)
123 #define LibmeshPetscCallQ(...) \ 126 PetscErrorCode libmesh_petsc_call_ierr; \ 127 libmesh_petsc_call_ierr = __VA_ARGS__; \ 128 LIBMESH_CHKERRQ(libmesh_petsc_call_ierr); \ 132 #define LibmeshPetscCallA(comm, ...) \ 135 PetscErrorCode libmesh_petsc_call_ierr; \ 136 libmesh_petsc_call_ierr = __VA_ARGS__; \ 137 LIBMESH_CHKERRA(comm, libmesh_petsc_call_ierr); \ 142 #define LibmeshPetscCall(...) \ 143 LibmeshPetscCallA(this->comm().get(), __VA_ARGS__) 147 #define LibmeshPetscCall2(comm, ...) \ 148 LibmeshPetscCallA(comm.get(), __VA_ARGS__) 150 #ifdef LIBMESH_ENABLE_EXCEPTIONS 151 #define LibmeshPetscCallExternal(func, ...) \ 153 const auto libmesh_petsc_call_external_ierr = cast_int<int>(func(__VA_ARGS__)); \ 154 if (libmesh_petsc_call_external_ierr != 0) \ 155 throw PetscSolverException(libmesh_petsc_call_external_ierr); \ 158 #define LibmeshPetscCallExternal(func, ...) \ 160 const auto libmesh_petsc_call_external_ierr = cast_int<int>(func(__VA_ARGS__)); \ 161 if (libmesh_petsc_call_external_ierr != 0) \ 162 libmesh_terminate_handler(); \ 169 #endif // LIBMESH_HAVE_PETSC 170 #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 &...)