Hi,

I am solving Ax=b repeatedly, and A does not change all the time. I did things like this:

%1. Set up entries for matrix A%%%
    CALL MATASSEMBLYBEGIN(A,MAT_FINAL_ASSEMBLY,IERR)
    CALL MATASSEMBLYEND(A,MAT_FINAL_ASSEMBLY,IERR)
    CALL MATSETOPTION(A,MAT_NEW_NONZERO_LOCATIONS,PETSC_FALSE,ierr)
    CALL KSPSetOperators(ksp,A,A,SAME_NONZERO_PATTERN,ierr)

    Call KSPSetOperators(ksp,A,A,SAME_NONZERO_PATTERN,ierr)

   Do i=1,100
           % Set up entries for vector b%%%%%
          CALL VECASSEMBLYBEGIN(b,IERR)
          CALL VECASSEMBLYEND(b,IERR)
          CALL KSPSolve(ksp,b,x,ierr)
    ENDDO

However, it does not work. I don't know why. Could anybody help me with this? Thank you very much.

Sincerely
Xingjun Fang

Reply via email to