[petsc-users] Modifying Jacobian and Preconditioner in a Loop

Smith, Barry F. bsmith at mcs.anl.gov
Tue Jan 8 15:03:28 CST 2019



> On Jan 8, 2019, at 1:25 PM, Kevin Mattalo via petsc-users <petsc-users at mcs.anl.gov> wrote:
> 
> Hello,
> 
> I am currently solving a large linear system using a discontinuous Galerkin approach with an inexact Newton method. I begin with a small time step and then ramp up the time step every m outer iterations. I lag the update of both by a certain integer multiple to improve efficiency. Because of this, my Jacobian and therefore the preconditioner need to be modified, reassembled, and updated in a loop. Right now, for each update I zero the entries in my Jacobian, compute the entries, assemble the matrix, reset my operators using KSPSetOperators() and then call KSPGetPC and KSPSetUp() to get the new preconditioner.

   You don't actually need to call KSPSetOperators(), or KSPGetPC(), or KSPSetUp(). PETSc tracks if anything has changed in the matrix and then (and only then) does it rebuild the preconditioner on the next KSPSolve() call.

   Barry

> 
> Is there a more efficient way to continuously update the Jacobian?
> 
> Kevin



More information about the petsc-users mailing list