[petsc-users] [EXTERNAL] Re: Finite difference approximation of Jacobian

Jorti, Zakariae zjorti at lanl.gov
Mon Dec 13 12:03:53 CST 2021


Hi Matt,


Thanks for the reply.

I tested the following flags.


- With -snes_fd_color and -snes_fd_color_use_mat

I got a segmentation violation. I was able to get the call stack as I am using a debugger:

MatCreateSubmatrix_MPIAIJ_All

MatGetSeqNonzeroStructure_MPIAIJ

MatGetSeqNonzeroStructure

MatColoringApply_SL

MatColoringApply

SNESComputeJacobianDefaultColor


- With -snes_fd_color -snes_fd_color_use_mat -mat_coloring_type greedy -mat_coloring_weight_type lf , I get this error message:

[0]PETSC ERROR: Object is in wrong state

[0]PETSC ERROR: Not for unassembled matrix

[0]PETSC ERROR: See https://www.mcs.anl.gov/petsc/documentation/faq.html for trouble shooting.

[0]PETSC ERROR: Petsc Release Version 3.15.0, unknown

[0]PETSC ERROR: /global/u1/z/zjorti/Gitlab_repos/runaway_develop/runaway/cutcell/MFDsolver/QuasiStatic_Normalized/main on a arch-linux-c-debug named nid00223 by zjorti Mon Dec 13 09:14:12 2021

[0]PETSC ERROR: Configure options CC=cc CXX=CC FC=ftn COPTFLAGS=-g CXXOPTFLAGS=-g FOPTFLAGS=-g --download-superlu_dist --download-scalapack --download-mumps --download-hypre --with-debugging=1 --with-cxx-dialect=C++11

[0]PETSC ERROR: #1 MatIncreaseOverlap() at /global/project/projectdirs/m3016/Master_PETSc/Debug_PETSc/petsc/src/mat/interface/matrix.c:7302

[0]PETSC ERROR: #2 MatColoringGetDegrees() at /global/project/projectdirs/m3016/Master_PETSc/Debug_PETSc/petsc/src/mat/color/utils/weights.c:59

[0]PETSC ERROR: #3 MatColoringCreateLargestFirstWeights() at /global/project/projectdirs/m3016/Master_PETSc/Debug_PETSc/petsc/src/mat/color/utils/weights.c:131

[0]PETSC ERROR: #4 MatColoringCreateWeights() at /global/project/projectdirs/m3016/Master_PETSc/Debug_PETSc/petsc/src/mat/color/utils/weights.c:347

[0]PETSC ERROR: #5 MatColoringApply_Greedy() at /global/project/projectdirs/m3016/Master_PETSc/Debug_PETSc/petsc/src/mat/color/impls/greedy/greedy.c:563

[0]PETSC ERROR: #6 MatColoringApply() at /global/project/projectdirs/m3016/Master_PETSc/Debug_PETSc/petsc/src/mat/color/interface/matcoloring.c:355

[0]PETSC ERROR: #7 SNESComputeJacobianDefaultColor() at /global/project/projectdirs/m3016/Master_PETSc/Debug_PETSc/petsc/src/snes/interface/snesj2.c:86

[0]PETSC ERROR: #8 SNESComputeJacobian() at /global/project/projectdirs/m3016/Master_PETSc/Debug_PETSc/petsc/src/snes/interface/snes.c:2713

[0]PETSC ERROR: #9 SNESSolve_NEWTONLS() at /global/project/projectdirs/m3016/Master_PETSc/Debug_PETSc/petsc/src/snes/impls/ls/ls.c:222

[0]PETSC ERROR: #10 SNESSolve() at /global/project/projectdirs/m3016/Master_PETSc/Debug_PETSc/petsc/src/snes/interface/snes.c:4653

[0]PETSC ERROR: #11 TSStep_ARKIMEX() at /global/project/projectdirs/m3016/Master_PETSc/Debug_PETSc/petsc/src/ts/impls/arkimex/arkimex.c:845

[0]PETSC ERROR: #12 TSStep() at /global/project/projectdirs/m3016/Master_PETSc/Debug_PETSc/petsc/src/ts/interface/ts.c:3777

[0]PETSC ERROR: #13 TSSolve() at /global/project/projectdirs/m3016/Master_PETSc/Debug_PETSc/petsc/src/ts/interface/ts.c:4174


- With -snes_fd_color -snes_fd_color_use_mat -mat_coloring_type greedy, there is this error:

[8]PETSC ERROR: Null argument, when expecting valid pointer

[8]PETSC ERROR: Null Object: Parameter # 1

[8]PETSC ERROR: See https://www.mcs.anl.gov/petsc/documentation/faq.html for trouble shooting.

[8]PETSC ERROR: Petsc Release Version 3.15.0, unknown

[8]PETSC ERROR: /global/u1/z/zjorti/Gitlab_repos/runaway_develop/runaway/cutcell/MFDsolver/QuasiStatic_Normalized/main on a arch-linux-c-debug named nid00223 by zjorti Mon Dec 13 09:27:11 2021

[8]PETSC ERROR: Configure options CC=cc CXX=CC FC=ftn COPTFLAGS=-g CXXOPTFLAGS=-g FOPTFLAGS=-g --download-superlu_dist --download-scalapack --download-mumps --download-hypre --with-debugging=1 --with-cxx-dialect=C++11

[8]PETSC ERROR: #1 VecGetLocalSize() at /global/project/projectdirs/m3016/Master_PETSc/Debug_PETSc/petsc/src/vec/vec/interface/vector.c:688

[8]PETSC ERROR: #2 GreedyColoringLocalDistanceTwo_Private() at /global/project/projectdirs/m3016/Master_PETSc/Debug_PETSc/petsc/src/mat/color/impls/greedy/greedy.c:258



Besides, I found this thread "Questions about residual function can't be reduced" (https://www.mail-archive.com/search?l=petsc-users@mcs.anl.gov&q=subject:%22%5C%5Bpetsc%5C-users%5C%5D+questions%22&o=newest&f=1) where you are saying that the user needs to preallocate the Jacobian matrix correctly. Is it true only for user provided Jacobian matrix, or also for finite difference approximation with coloring? In the latter case, how can we do that?

Many thanks.


Zakariae

________________________________
From: petsc-users <petsc-users-bounces at mcs.anl.gov> on behalf of Matthew Knepley <knepley at gmail.com>
Sent: Saturday, December 11, 2021 2:28:33 PM
To: Tang, Qi
Cc: petsc-users at mcs.anl.gov
Subject: [EXTERNAL] Re: [petsc-users] Finite difference approximation of Jacobian

On Sat, Dec 11, 2021 at 1:58 PM Tang, Qi <tangqi at msu.edu<mailto:tangqi at msu.edu>> wrote:
Hi,
Does anyone have comment on finite difference coloring with DMStag? We are using DMStag and TS to evolve some nonlinear equations implicitly. It would be helpful to have the coloring Jacobian option with that.

Since DMStag produces the Jacobian connectivity, you can use -snes_fd_color_use_mat. It has many options. Here is an example of us using that:

  https://gitlab.com/petsc/petsc/-/blob/main/src/snes/tutorials/ex19.c#L898

  Thanks,

     Matt

Thanks,
Qi


On Oct 15, 2021, at 3:07 PM, Jorti, Zakariae via petsc-users <petsc-users at mcs.anl.gov<mailto:petsc-users at mcs.anl.gov>> wrote:

Hello,

Does the Jacobian approximation using coloring and finite differencing of the function evaluation work in DMStag?
Thank you.
Best regards,

Zakariae



--
What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.
-- Norbert Wiener

https://www.cse.buffalo.edu/~knepley/<http://www.cse.buffalo.edu/~knepley/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20211213/1fac76d7/attachment.html>


More information about the petsc-users mailing list