[petsc-users] Using Finite Difference Jacobian with TS

Jed Brown jed at jedbrown.org
Wed Feb 2 17:23:31 CST 2022


Matthew Knepley <knepley at gmail.com> writes:

> On Wed, Feb 2, 2022 at 6:08 PM Jorti, Zakariae via petsc-users <
> petsc-users at mcs.anl.gov> wrote:
>
>> Hello,
>>
>> I am using a TS to solve a differential algebraic equation (DAE).
>> I do not provide the Jacobian matrix but instead set the TS to use a
>> finite difference jacobian with coloring.
>> For debugging, I only solve this DAE on one time step.
>> Is there a way to output this finite difference jacobian in a matlab
>> format (.m file)?
>> I have already tried this flag : -mat_view ascii:ColFDJac.m:ascii_matlab ,
>> but when I use it the test takes too long. My guess is that this flag  is
>> trying to save all the matrices involved in the computations. I am  only
>> interested in the jacobian though.
>>
>
> I tend to use -ksp_mat_view ascii:ColFDJac.m:ascii_matlab since that only
> outputs the KSP system matrix.

And it'll be more efficient to do binary output

  -ksp_mat_view binary:ColFDJac.petsc

and in MATLAB, use

  PetscBinaryRead('ColFDJac.petsc')

https://petsc.org/release/docs/manual/matlab/?highlight=matlab#dumping-binary-data-for-matlab


More information about the petsc-users mailing list