Setting initial guess for nonlinear problem

Hi,

Is there a way to tell the solver of a NonlinearVariationalProblem that in the form of a up_initguess of type Function(VP) I have a really good initial guess?

I use the NonlinearVariationalProblem to solve a scheme with the built-in Newton method. The method does not converge when applied to the scheme, I get
“Newton iteration 1: r (abs) = -nan (tol = 1.000e-10) r (rel) = -nan (tol = 1.000e-09)” and so on.

I was wondering if I could make the scheme converge if I could use what I have, which is a good initial guess in the form of a function (not an Expression). I found something similar here: https://fenicsproject.org/qa/9536/how-to-set-initial-guess-for-nonlinear-variational-problem/, but I don’t have an Expression, only an initial guess Function(VP), up_initguess. But when I try to use it analogously as seen in the link attached, I get a runtime error.

up = TrialFunction(VP)
u,p = split(up)
u1, u2 = split(u)
(v, q) = TestFunctions(VP)
v1, v2 = split(v)

up_ = Function(VP)
(u_, p_) = split(up_)
(u1_, u2_) = split(u_)

(load initial guess into the trialfunctions in the scheme. here we don’t need to interpolate, as both sides are coordinates of functions defined in VP.)

u1 = u1_initguess
u2 = u2_initguess
u = u_initguess
p = p_initguess

F = inner(u, grad(u1)) * v1 * dx + inner(grad(u1),grad(v1)) * dx - p * div(v) * dx + q * div(u) * dx
F = action(F, up_)
J = derivative(F, up_, up)
problem = NonlinearVariationalProblem(F, up_, bcu, J)
solver = NonlinearVariationalSolver(problem)
solver.solve()

Thank you so much for any help.

Whatever is in the up_ vector will be used as the initial guess.

1 Like

Thank you so much nate!!

1 Like