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.

Cheers
Lei

From: Hong [mailto:[email protected]]
Sent: 03 July 2018 17:30
To: WANG, LEI
Cc: [email protected]
Subject: Re: [petsc-users] degub of computating Jacobian for SNES

LEI :
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.
Hong

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:[email protected]<mailto:[email protected]>]
Sent: 03 July 2018 15:31
To: WANG, LEI
Cc: [email protected]<mailto:[email protected]>
Subject: Re: [petsc-users] degub of computating Jacobian for SNES

LEI:
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.
Hong
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?

Cheers
Lei


Reply via email to