Huge difference between LU solver and GMRES


64
views
0
5 weeks ago by
Hello All,
I tried solve an adjoint equation with GMRES and direct solver and found there are huge difference between the solutions.

My direct solver to get the adjoint velocity is:
def Solve_Adjoint_LU(variables):
    ...
    a, L = lhs(F), rhs(F)
    w = Function(W)
    problem = LinearVariationalProblem(a,L,w,bc)
    solver  = LinearVariationalSolver(problem)
    solver.solve()
    return w
w1 = Solve_Adjoint_LU(variables)
u1,p1 = w1.split()​


My GMRES solver to get the adjoint velocity is:

def Solve_Adjoint_Gmres(variables):
    ...
    a, L = lhs(F), rhs(F)
    w = Function(W)
    problem = LinearVariationalProblem(a,L,w,bc)
    solver  = LinearVariationalSolver(problem)
    
    solver.parameters['linear_solver'] ='gmres'
    solver.parameters['preconditioner']='hypre_amg'
    solver.parameters['krylov_solver']['monitor_convergence']=True

    solver.solve()
    return w
w2 = Solve_Adjoint_Gmres(variables)
u2,p2 = w2.split()​​

The GMRES iteration monitor is:

Then I found there are huge difference between u1 and u2 by:

u_1 = Function(V)
u_2 = Function(V)
assign(u_1,w1.sub(0))
assign(u_2,w2.sub(0))

diff = (u_1.vector().get_local()-u_2.vector().get_local())
error = np.linalg.norm(diff, ord = np.Inf)


I would prefer the direct solver because with that I can have my sensitivity correct(and with GMRES my sensitivity is incorrect), but considering the performance, I need the iteration method to run parallel.

Any idea how can I decrease the error?
Best.

Community: FEniCS Project
Make the iterative tolerance stricter -ksp_rtol 1e-12.
written 5 weeks ago by Nate  
Please login to add an answer/comment or follow this question.

Similar posts:
Search »