[petsc-users] degub of computating Jacobian for SNES

WANG, LEI lei.wang at durham.ac.uk
Tue Jul 3 11:45:29 CDT 2018

Thank you very much, Hong.

I just output the local matrix which I inserted into the global matrix A just before calling MatSetValues. Every entry of this local matrix is correct, without any ‘nan’. There is no other operation on A before MatAssemblyBegin(). But the MatView(A) just after MatAssembly shows some ‘nan’ included in A. This seems odd.


From: Hong [mailto:hzhang at mcs.anl.gov]
Sent: 03 July 2018 17:30
Cc: petsc-users at mcs.anl.gov
Subject: Re: [petsc-users] degub of computating Jacobian for SNES

One strange thing is that the Jacobian stiffness matrix include ‘nan’. I output the element stiffness matrix and the element degree of freedom before assembly. There is nothing abnormal.
How do you check the element? Some elements might divide zero.

But after assembly by
ierr1 = MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr1);
ierr1 = MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr1);
I got some ‘nan’ in the stiffness matrix A. Any idea on this?

For sequential run, MatAssemly() does do much. Check every element of your matrix.
With 1 MPI process and LU precondition, the code should work with correctly assembled matrix.

Nonlinear solve did not converge due to DIVERGED_FNORM_NAN iterations 0
SNES Object: 1 MPI processes
  type: newtonls
  maximum iterations=40, maximum function evaluations=40
  tolerances: relative=0.0001, absolute=0.0001, solution=1e-08
  total number of linear solver iterations=0
  total number of function evaluations=1
  norm schedule ALWAYS
  SNESLineSearch Object:   1 MPI processes
    type: basic
    maxstep=1.000000e+08, minlambda=1.000000e-12
    tolerances: relative=1.000000e-08, absolute=1.000000e-15, lambda=1.000000e-08
    maximum iterations=40
  KSP Object:   1 MPI processes
    type: gmres
      GMRES: restart=30, using Classical (unmodified) Gram-Schmidt Orthogonalization with no iterative refinement
      GMRES: happy breakdown tolerance 1e-30
    maximum iterations=100, initial guess is zero
    tolerances:  relative=1e-10, absolute=1e-10, divergence=10000.
    left preconditioning
    using DEFAULT norm type for convergence test
  PC Object:   1 MPI processes
    type: lu
    PC has not been set up so information may be incomplete
      LU: out-of-place factorization
      tolerance for zero pivot 2.22045e-14
      matrix ordering: nd
    linear system matrix = precond matrix:
    Mat Object:     1 MPI processes
      type: seqaij
      rows=78, cols=78
      total: nonzeros=3204, allocated nonzeros=46800
      total number of mallocs used during MatSetValues calls =0
        using I-node routines: found 25 nodes, limit used is 5
No. of Iterations: 0
Convergence reason: -4: SNES_DIVERGED_FNORM_NAN

From: Hong [mailto:hzhang at mcs.anl.gov<mailto:hzhang at mcs.anl.gov>]
Sent: 03 July 2018 15:31
Cc: petsc-users at mcs.anl.gov<mailto:petsc-users at mcs.anl.gov>
Subject: Re: [petsc-users] degub of computating Jacobian for SNES

Run your code with option '-snes_converged_reason -ksp_converged_reason -ksp_monitor -snes_monitor' to check which solver leads to divergence. Then use option '-snes_view' to check what solver is used.
Dear all

I am using SNES for solving a large nonlinear system for Material Point Method. But it always diverged after server steps, I think there are some bug in the computation of Jacobian matrix. Do anyone have practical approach for identified these bugs in a large matrix? Currently, I saved the matrix to a txt file and load it to Matlab for checking. Is there function for checking Petsc Mat in Petsc itself?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20180703/61fdd8e1/attachment.html>

More information about the petsc-users mailing list