From babe68f61d1fb4bd4c279ae547576516fa165ddd Mon Sep 17 00:00:00 2001 From: Denis Davydov Date: Fri, 1 Jan 2016 12:50:19 +0100 Subject: [PATCH] make sure that inside solve() PETSc preconditioner has a matrix set --- source/lac/petsc_solver.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/lac/petsc_solver.cc b/source/lac/petsc_solver.cc index bd8c986476..19372d48b3 100644 --- a/source/lac/petsc_solver.cc +++ b/source/lac/petsc_solver.cc @@ -95,6 +95,12 @@ namespace PETScWrappers ierr = KSPSetPC (solver_data->ksp, preconditioner.get_pc()); AssertThrow (ierr == 0, ExcPETScError(ierr)); + // make sure the preconditioner has an associated matrix set + const Mat B = preconditioner; + AssertThrow (B != NULL, + ExcMessage("PETSc preconditioner should have an" + "associated matrix set to be used in solver.")); + // setting the preconditioner overwrites the used matrices. // hence, we need to set the matrices after the preconditioner. #if DEAL_II_PETSC_VERSION_LT(3, 5, 0) -- 2.39.5