DOLFINx 0.12.0.0
DOLFINx C++
Loading...
Searching...
No Matches
dolfinx::common::petsc Namespace Reference

PETSc error handling helpers shared across DOLFINx's PETSc wrappers. More...

Functions

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.
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.
void set_option (std::string option)
 Set a PETSc option in the PETSc options/parameter database. The option must not be prefixed by '-', e.g.
template<typename T>
requires requires(const T& value) { std::format("{}", value); }
void set_option (std::string option, const T &value)
 Set a PETSc option that takes a value in the PETSc options/parameter database. The option must not be prefixed by '-', e.g.
void clear_option (std::string option)
 Clear a PETSc option from the PETSc options/parameter database.
void clear_options ()
 Clear the PETSc global options/parameter database.

Detailed Description

PETSc error handling helpers shared across DOLFINx's PETSc wrappers.

Function Documentation

◆ check()

void check ( PetscErrorCode ierr,
std::string_view petsc_function,
std::source_location loc = std::source_location::current() )
inline

Throw a std::runtime_error via error() if ierr indicates a PETSc call failed.

Parameters
[in]ierrPETSc error code returned by petsc_function
[in]petsc_functionName of the PETSc function that returned ierr
[in]locCall site of the failed PETSc call (captured automatically; do not pass explicitly)

◆ error()

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.

Parameters
[in]error_codePETSc error code
[in]petsc_functionName of the PETSc function that returned error_code
[in]locCall site of the failed PETSc call (captured automatically; do not pass explicitly)

◆ set_option() [1/2]

void set_option ( std::string option)

Set a PETSc option in the PETSc options/parameter database. The option must not be prefixed by '-', e.g.

common::petsc::set_option("mat_mumps_icntl_14", 40); 

◆ set_option() [2/2]

template<typename T>
requires requires(const T& value) { std::format("{}", value); }
void set_option ( std::string option,
const T & value )

Set a PETSc option that takes a value in the PETSc options/parameter database. The option must not be prefixed by '-', e.g.

common::petsc::set_option("mat_mumps_icntl_14", 40);