SNES and TS intentionally left out since those changes will be in separate commits
#ifdef DEAL_II_WITH_PETSC
-# include <petscconf.h>
# include <petscksp.h>
# include <petscmat.h>
# include <petscpc.h>
# include <petscsnes.h>
# include <petscts.h>
+# if DEAL_II_PETSC_VERSION_LT(3, 19, 0)
+# define PETSC_SUCCESS 0
+# endif
# include <string>
// we are allowed to call MPI_Init ourselves and PETScInitialize will
// detect this. This allows us to use MPI_Init_thread instead.
#ifdef DEAL_II_WITH_PETSC
+ PetscErrorCode pierr;
# ifdef DEAL_II_WITH_SLEPC
// Initialize SLEPc (with PETSc):
finalize_petscslepc = SlepcInitializeCalled ? false : true;
- ierr = SlepcInitialize(&argc, &argv, nullptr, nullptr);
- AssertThrow(ierr == 0, SLEPcWrappers::SolverBase::ExcSLEPcError(ierr));
+ pierr = SlepcInitialize(&argc, &argv, nullptr, nullptr);
+ AssertThrow(pierr == 0, SLEPcWrappers::SolverBase::ExcSLEPcError(pierr));
# else
// or just initialize PETSc alone:
finalize_petscslepc = PetscInitializeCalled ? false : true;
- ierr = PetscInitialize(&argc, &argv, nullptr, nullptr);
- AssertThrow(ierr == 0, ExcPETScError(ierr));
+ pierr = PetscInitialize(&argc, &argv, nullptr, nullptr);
+ AssertThrow(pierr == 0, ExcPETScError(pierr));
# endif
// Disable PETSc exception handling. This just prints a large wall
// of text that is not particularly helpful for what we do:
- PetscPopSignalHandler();
+ pierr = PetscPopSignalHandler();
+ AssertThrow(pierr == 0, ExcPETScError(pierr));
#endif
// Initialize zoltan
# ifdef DEAL_II_WITH_SLEPC
// and now end SLEPc with PETSc if we did so
if (finalize_petscslepc)
- SlepcFinalize();
+ {
+ PetscErrorCode ierr = SlepcFinalize();
+ AssertThrow(ierr == 0, SLEPcWrappers::SolverBase::ExcSLEPcError(ierr))
+ }
# else
// or just end PETSc if we did so
if (finalize_petscslepc)
- PetscFinalize();
+ {
+ PetscErrorCode ierr = PetscFinalize();
+ AssertThrow(ierr == 0, ExcPETScError(ierr));
+ }
# endif
#endif
#include <deal.II/lac/exceptions.h>
#ifdef DEAL_II_WITH_PETSC
-# include <petscconf.h>
# include <petscsys.h>
#endif // DEAL_II_WITH_PETSC
// PetscErrorMessage changes the value in a pointer to refer to a
// statically allocated description of the current error message.
const char * petsc_message;
- const PetscErrorCode ierr = PetscErrorMessage(error_code,
- &petsc_message,
- /*specific=*/nullptr);
+ const PetscErrorCode ierr =
+ PetscErrorMessage(static_cast<PetscErrorCode>(error_code),
+ &petsc_message,
+ /*specific=*/nullptr);
if (ierr == 0 && petsc_message != nullptr)
{
out << "The description of the error provided by PETSc is \""
// since this is a collective operation
IS index_set;
- ISCreateGeneral(get_mpi_communicator(),
- rows.size(),
- petsc_rows.data(),
- PETSC_COPY_VALUES,
- &index_set);
+ PetscErrorCode ierr;
+ ierr = ISCreateGeneral(get_mpi_communicator(),
+ rows.size(),
+ petsc_rows.data(),
+ PETSC_COPY_VALUES,
+ &index_set);
+ AssertThrow(ierr == 0, ExcPETScError(ierr));
- const PetscErrorCode ierr =
- MatZeroRowsIS(matrix, index_set, new_diag_value, nullptr, nullptr);
+ ierr = MatZeroRowsIS(matrix, index_set, new_diag_value, nullptr, nullptr);
+ AssertThrow(ierr == 0, ExcPETScError(ierr));
+ ierr = ISDestroy(&index_set);
AssertThrow(ierr == 0, ExcPETScError(ierr));
- ISDestroy(&index_set);
}
void
// since this is a collective operation
IS index_set;
- ISCreateGeneral(get_mpi_communicator(),
- rows.size(),
- petsc_rows.data(),
- PETSC_COPY_VALUES,
- &index_set);
+ PetscErrorCode ierr;
+ ierr = ISCreateGeneral(get_mpi_communicator(),
+ rows.size(),
+ petsc_rows.data(),
+ PETSC_COPY_VALUES,
+ &index_set);
+ AssertThrow(ierr == 0, ExcPETScError(ierr));
- const PetscErrorCode ierr =
+ ierr =
MatZeroRowsColumnsIS(matrix, index_set, new_diag_value, nullptr, nullptr);
AssertThrow(ierr == 0, ExcPETScError(ierr));
- ISDestroy(&index_set);
+ ierr = ISDestroy(&index_set);
+ AssertThrow(ierr == 0, ExcPETScError(ierr));
}
// interface code of PCSetUp in PETSc.
// We handle it here.
PetscCall(pc_set_failed_reason(ppc, PC_NOERROR));
- PetscFunctionReturn(0);
+ PetscFunctionReturn(PETSC_SUCCESS);
}
PetscErrorCode
"Failure in pcapply from dealii::PETScWrappers::NonlinearSolver");
}
petsc_increment_state_counter(y);
- PetscFunctionReturn(0);
+ PetscFunctionReturn(PETSC_SUCCESS);
}
PetscErrorCode
"Failure in pcapply_transpose from dealii::PETScWrappers::NonlinearSolver");
}
petsc_increment_state_counter(y);
- PetscFunctionReturn(0);
+ PetscFunctionReturn(PETSC_SUCCESS);
}
}
- int
+ PetscErrorCode
SolverBase::convergence_test(KSP /*ksp*/,
const PetscInt iteration,
const PetscReal residual_norm,
KSPConvergedReason *reason,
void * solver_control_x)
{
+ PetscFunctionBeginUser;
SolverControl &solver_control =
*reinterpret_cast<SolverControl *>(solver_control_x);
Assert(false, ExcNotImplemented());
}
- // return without failure
- return 0;
+ PetscFunctionReturn(PETSC_SUCCESS);
}
void
check_petsc_allocations()
{
- PetscStageLog stageLog;
- PetscLogGetStageLog(&stageLog);
+ PetscStageLog stageLog;
+ PetscErrorCode ierr;
+
+ ierr = PetscLogGetStageLog(&stageLog);
+ AssertThrow(ierr == 0, ExcPETScError(ierr));
// I don't quite understand petsc and it looks like
// stageLog->stageInfo->classLog->classInfo[i].id is always -1, so we look