Hi all,

I’m solving a non-linear advection-diffusion problem in 2D and am testing the 
routine on various meshes. The non-linearity is handled via Newton’s method. If 
I consider the unit square [0,1]^2, my results were fine. I tried testing on 
[-1,1]^2 and got either garbage results or a warning about zero pivots.

I thought my Jacobian might be computed incorrectly, but I think that isn’t the 
case since I applied -pc-factor_shift_type POSITIVE DEFINITE and miraculously 
got the correct result now. But in applying this factor shift over various 
trials on the same problem, the results seem to be pretty random. Since I am 
testing on manufactured solutions, I force the problem to be linear since I 
have prior knowledge of the exact solution and Newton’s method should converge 
in one iteration.  For instance, this is what the result should be (iterations 
and errors are for each Newton iteration)

> student-113-wless94-099:NonlinearAdvectionDiffusion justindong$ ./main 
> -pc_factor_shift_type POSITIVE_DEFINITE
> Iteration: 1, Error: 0.000000e+00
> Iterations for convergence: 1
> Iteration: 1, Error: 0.000000e+00
> Iterations for convergence: 1
> Iteration: 1, Error: 0.000000e+00
> Iterations for convergence: 1
> Iteration: 1, Error: 0.000000e+00
> Iterations for convergence: 1
> Iteration: 1, Error: 0.000000e+00
> Iterations for convergence: 1
> Error in L2-norm:
> 4.55137e-02 
> 3.28222e-03 
> 2.24076e-04 
> 1.41531e-05 
> 8.87205e-07 
> 
> Error in H1-norm:
> 4.72542e-01 
> 6.63469e-02 
> 9.33978e-03 
> 1.18329e-03 
> 1.48449e-04 
> 
> 
> Convergence in L2-norm:
> 3.793556 
> 3.872613 
> 3.984794 
> 3.995709 
> 
> Convergence in H1-norm:
> 2.832342 
> 2.828567 
> 2.980589 
> 2.994760 


But then this call gives a completely different result.

> student-113-wless94-099:NonlinearAdvectionDiffusion justindong$ ./main 
> -pc_factor_shift_type POSITIVE_DEFINITE
> Iteration: 1, Error: 1.116824e-01
> Iteration: 2, Error: 1.788701e-14
> Iterations for convergence: 2
> Iteration: 1, Error: 4.592120e-02
> Iteration: 2, Error: 6.520052e-03
> Iteration: 3, Error: 0.000000e+00
> Iterations for convergence: 3
> Iteration: 1, Error: 4.706179e-02
> Iteration: 2, Error: 0.000000e+00
> Iterations for convergence: 2
> Iteration: 1, Error: 0.000000e+00
> Iterations for convergence: 1
> Iteration: 1, Error: 0.000000e+00
> Iterations for convergence: 1
> Error in L2-norm:
> 1.20600e-01 
> 4.33519e-02 
> 4.70623e-02 
> 1.41531e-05 
> 8.87205e-07 
> 
> Error in H1-norm:
> 6.04173e-01 
> 1.72409e-01 
> 1.82071e-01 
> 1.18329e-03 
> 1.48449e-04 
> 
> 
> Convergence in L2-norm:
> 1.476068 
> -0.118478 
> 11.699236 
> 3.995709 
> 
> Convergence in H1-norm:
> 1.809128 
> -0.078670 
> 7.265561 
> 2.994760 



Since I’m still just testing various examples using my code, I could just run 
it until it gives me the correct result, but that seems silly. Is there anyway 
I can get consistent results? I know I can specify the amount of the shift, but 
since I’m not well versed in these solvers, I’m not sure what to specify.

Reply via email to