Check that a particular condition is true
Collective; No Fortran Support
cond - The boolean condition
comm - The communicator on which the check can be collective on
ierr - A nonzero error code, see include/petscerror.h for the complete list
message - Error message in printf format
Enabled in both optimized and debug builds.
As a general rule,
PetscCheck() is used to check “usage error” (for example, passing an incorrect value as a function argument),
PetscAssert() is used to “check for bugs in PETSc” (for example, is a value in a PETSc data structure nonsensical).
However, for functions that are called in a “hot spot”, for example, thousands of times in a loop,
PetscAssert() should be used instead
PetscCheck() since the former is compiled out in PETSc’s optimization code.