Thank you very much for your help and the examples provided. I was able to
implement the Jacobian-times-vector (Jv) approach as recommended, and it
works great!.

Art

El mar, 8 jul 2025 a las 13:36, Zhang, Hong (<hongzh...@anl.gov>) escribió:

> For a python example, please take a look at
> src/binding/petsc4py/demo/legacy/ode/vanderpol.py and you will see how jvp
> is done in the class IJacShell.
>
>
>
> Hong
>
>
>
> *From: *petsc-users <petsc-users-boun...@mcs.anl.gov> on behalf of
> "Zhang, Hong via petsc-users" <petsc-users@mcs.anl.gov>
> *Reply-To: *"Zhang, Hong" <hongzh...@anl.gov>
> *Date: *Tuesday, July 8, 2025 at 12:21 PM
> *To: *Art <mac3...@gmail.com>, "petsc-users@mcs.anl.gov" <
> petsc-users@mcs.anl.gov>
> *Subject: *Re: [petsc-users] Matrix-Free J*v in PETSc
>
>
>
> 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-boun...@mcs.anl.gov> on behalf of Art <
> mac3...@gmail.com>
> *Date: *Monday, July 7, 2025 at 9:33 AM
> *To: *"petsc-users@mcs.anl.gov" <petsc-users@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
>

Reply via email to