14#include <source_location>
31void error(PetscErrorCode error_code, std::string_view petsc_function,
32 std::source_location loc = std::source_location::current());
41inline void check(PetscErrorCode ierr, std::string_view petsc_function,
42 std::source_location loc = std::source_location::current())
45 error(ierr, petsc_function, loc);
60 requires requires(
const T& value) { std::format(
"{}", value); }
64 option =
'-' + option;
66 check(PetscOptionsSetValue(
nullptr, option.c_str(),
67 std::format(
"{}", value).c_str()),
68 "PetscOptionsSetValue");
PETSc error handling helpers shared across DOLFINx's PETSc wrappers.
Definition petsc.h:23
void check(PetscErrorCode ierr, std::string_view petsc_function, std::source_location loc=std::source_location::current())
Throw a std::runtime_error via error() if ierr indicates a PETSc call failed.
Definition petsc.h:41
void error(PetscErrorCode error_code, std::string_view petsc_function, std::source_location loc=std::source_location::current())
Print error message for a PETSc call that returned an error and throw a std::runtime_error.
Definition petsc.cpp:21
void clear_option(std::string option)
Clear a PETSc option from the PETSc options/parameter database.
Definition petsc.cpp:47
void clear_options()
Clear the PETSc global options/parameter database.
Definition petsc.cpp:56
void set_option(std::string option)
Set a PETSc option in the PETSc options/parameter database. The option must not be prefixed by '-',...
Definition petsc.cpp:42
Miscellaneous classes, functions and types.
Definition dolfinx_common.h:8