I am trying to use an iterative solver to solve the Navistox equation.
Refer to it:
https://docs.fenicsproject.org/dolfinx/main/python/demos/demo_navier-stokes.html
I will replace the solver with gmres.
PCtype is ILU. ILU preprocessing does not allow diagonal 0 to appear.
Therefore, I added a rearrangement of the 0 diagonal elements to avoid this issue.
opts[“pc_factor_nonzeros_along_diagonal”]=10**(-8)
The solver as follow:
ksp = PETSc.KSP().create(msh.comm) # type: ignore
ksp.setOperators(A)ksp.setInitialGuessNonzero(True)
ksp.setConvergenceHistory(reset=True)
ksp.setType(“gmres”)
ksp.getPC().setType(“ilu”)opts = PETSc.Options() # type: ignore
opts[“ksp_rtol”] = 1.0e-10
opts[“ksp_atol”] = 1.0e-3
opts[“ksp_max_it”] = 800
opts[“pc_factor_nonzeros_along_diagonal”]=10**(-8)
ksp.setFromOptions()
errors:
petsc4py.PETSc.Error: error code 73
[0] KSPSolve() at /usr/local/petsc/src/ksp/ksp/interface/itfunc.c:1082
[0] KSPSolve_Private() at /usr/local/petsc/src/ksp/ksp/interface/itfunc.c:836
[0] KSPSetUp() at /usr/local/petsc/src/ksp/ksp/interface/itfunc.c:415
[0] PCSetUp() at /usr/local/petsc/src/ksp/pc/interface/precon.c:1068
[0] PCSetUp_ILU() at /usr/local/petsc/src/ksp/pc/impls/factor/ilu/ilu.c:135
[0] MatILUFactorSymbolic() at /usr/local/petsc/src/mat/interface/matrix.c:6939
[0] MatILUFactorSymbolic_SeqAIJ() at /usr/local/petsc/src/mat/impls/aij/seq/aijfact.c:1678
[0] Object is in wrong state
[0] Matrix is missing diagonal entry 2624