update petsc code

- api changes in newer versions
- do not manually destroy the preconditioner. this is, and has always
  been, owned by the ksp object and dies with its destruction.
This commit is contained in:
Arne Morten Kvarving 2016-09-29 14:19:48 +02:00
parent 35ce9f5884
commit 0728d503b6

View File

@ -148,7 +148,6 @@ namespace{
VecDestroy( &b );
MatDestroy( &A );
KSPDestroy( &ksp );
PCDestroy( &preconditioner );
}
};
@ -197,7 +196,12 @@ namespace{
PetscReal residual;
KSPConvergedReason reason;
#if PETSC_VERSION_MAJOR <= 3 && PETSC_VERSION_MINOR < 5
KSPSetOperators( t.ksp, t.A, t.A, DIFFERENT_NONZERO_PATTERN );
#else
KSPSetOperators( t.ksp, t.A, t.A );
KSPSetReusePreconditioner(t.ksp, PETSC_FALSE);
#endif
KSPGetPC( t.ksp, &t.preconditioner );
auto err = KSPSetType( t.ksp, method );
CHKERRXX( err );
@ -216,7 +220,7 @@ namespace{
if( ksp_view )
KSPView( t.ksp, PETSC_VIEWER_STDOUT_WORLD );
err = PetscPrintf( PETSC_COMM_WORLD, "KSP Iterations %D, Final Residual %G\n", its, residual );
err = PetscPrintf( PETSC_COMM_WORLD, "KSP Iterations %D, Final Residual %g\n", its, (double)residual );
CHKERRXX( err );
}