[petsc-users] Matrix-Free J*v in PETSc
Zhang, Hong
hongzhang at anl.gov
Tue Jul 8 12:21:05 CDT 2025
Hi Art,
Here is a TS example that uses MatShell for implicit time integration and adjoint sensitivity calculation:
src/ts/tutorials/advection-diffusion-reaction/ex5adj_mf.c
You will need to provide a (jvp) routine like MyIMatMult() in this example. Adjoints require vjp (vector-Jacobian product) routines that are also included in this example.
Hong
From: petsc-users <petsc-users-bounces at mcs.anl.gov> on behalf of Art <mac3bar at gmail.com>
Date: Monday, July 7, 2025 at 9:33 AM
To: "petsc-users at mcs.anl.gov" <petsc-users at mcs.anl.gov>
Subject: [petsc-users] Matrix-Free J*v in PETSc
Hi all,
I am integrating a stiff system of ODEs/PDEs using PETSc TS (typically with BDF or other implicit time-stepping schemes), and I would like to exploit the fact that I can efficiently compute the action of the Jacobian on a vector (Jv) without assembling the full Jacobian matrix. Since for a large system it becomes expensive to assemble the Jacobian in each iteration. In scikits.odes (SUNDIALS/CVODE), there is a native API for passing only a J*v routine to the time integrator. In my experience, when I use only a Jacobian-vector product routine (without assembling the full matrix), the performance improves significantly for large systems. However, in PETSc TS, the workflow seems more matrix-centric, and I have only found the possibility to use MatShell for the Jacobian
Is there a way to do something similar in PETSc TS (for BDF or other implicit schemes)?
Currently, I use the matrix-free Newton-Krylov method to approximate the Jacobian and have adjusted the tolerances to achieve convergence, as recommended by Barry. In that case, I obtain similar integration times with scikits.odes CVODE without using the Jacobian times vector.
Best regards,
Art
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20250708/1957fd7d/attachment.html>
More information about the petsc-users
mailing list