[petsc-users] repeatedly direct solving a matrix that changes?
Barry Smith
bsmith at mcs.anl.gov
Sat Oct 10 14:50:57 CDT 2015
If you change any values in the matrix then KSP will automatically refactor the matrix for the next linear solve. If you want to use the same factorization even though you have changed the matrix you can use KSPSetReusePreconditioner()
Barry
> On Oct 10, 2015, at 2:37 PM, David Liu <xdavidliu at gmail.com> wrote:
>
> Hi,
>
> I have a matrix A that I am trying to solve (currently using Mumps). Between solves, I'm changing some of the elements of A, but not changing the nonzero pattern.
>
> In the past, with Petsc 3.4 and below, I was able to pass options like SAME_NONZERO_PATTERN and SAME_PRECONDITIONER to KSPSetOperators. By fiddling around with this (I don't recall exactly how), as well as re-calling KSPSetOperators between solves (iirc), I was able to switch at will between one of two things:
>
> 1) re-doing the LU factorization at each solve, so that the iterative part of the KSPSolve takes only one iteration to converge (because the "preconditioner" is just the inverse matrix) (I believe that's what it's doing, sorry if I am butchering the nomenclature)
>
> 2) doing the LU factorization on the first solve only, so that for the subsequent solves, the LU factorized matrix from the FIRST solve is used, so now the iterative part takes more than 1 iteration to converge.
>
> I don't recall exactly the exact steps I took to switch between 1) and 2); it had something to do with the very last option passed to KSPSetOperators. All I know is that option 2) actually worked fine for me because my A matrix was only changing slightly between solves.
>
> However, now I updated to 3.5, and it looks like that very last option to KSPSetOperators has been removed, as recorded in the following commit on bitbucket: https://bitbucket.org/petsc/petsc/issues/50/eliminate-the-need-for-matstructure-flag
>
> Now it looks like my code is exclusively doing 2) (if I am not mistaken), even though I am currently repeatedly calling KSPSetOperators between solves. How do I get my code to do 1)?
>
> thanks
> best,
> David Liu
>
More information about the petsc-users
mailing list