Jie,
> I wrapped up my A preconditioner with an inner CG solver (I am using IMEX
> scheme which moves the convection term to the RHS so A is symmetric) but the
> SparseILU still seems not to work.
But if A is symmetric, then you can use AMG again, and there is likely no
better preconditioner for that other than a geometric multigrid.
> I attached my code here, if you could take
> a look, it is very easy to reproduce the issue:
> 1. compile and run it, you will see everything works as expected
> 2. comment out line 221 and uncomment line 222, the program just hangs.
>
> Wolfgang does have a point: if I were able to use a direct solver on A then I
> might as well apply it on the whole system. I think I should get SparseILU
> working at least.
The problem with the SparseILU class is that it (i) is only an approximation
of an inverse matrix and, as a preconditioner far worse than the direct
solver, (ii) our implementation is neither very good nor optimized for
performance. There is also the issue that *any* ILU implementation that is
good will have *many* parameters, such as how to deal with fill-in,
strengthening the diagonal, pivoting, etc.
The deal.II SparseILU class is almost certainly not good enough to deal with
complicated problems such as yours. You may have better luck with the
implementations in PETSc or Trilinos, but in the end as Timo already said: the
question of what preconditioners to use for the N-S equations (at least if you
move the advection term to the left hand side) is an active research question
where the answer is neither obvious nor settled.
This is also part of why projection schemes are so attractive: They don't
require solving the coupled problem.