Hi everyone,
I want to check (numerically) whether or not the Neumann boundary condition is correctly applied (after I get a solution) for the following problem.
Here, Ix, Iy, It are image derivatives and u, v are velocity components.
Below is my main code.
(nx, ny) = I.shape
mesh = RectangleMesh(Point(0, 0), Point(ny-1, nx-1), ny-1, nx-1)
x = mesh.coordinates()
V = FunctionSpace(mesh, "CG",1)
f_x = image_to_CG1(Ix, V)# CG 1 interpolation
f_y = image_to_CG1(Iy, V)
f_t = image_to_CG1(It, V)
W = VectorFunctionSpace(mesh, "CG", 1, 2)
w = TrialFunction(W)
q = TestFunction(W)
(u, v) = split(w)
(q1, q2) = split(q)
lamda = Constant(0.01)
a = lamda*dot(grad(u), grad(q1))*dx + \
lamda*dot(grad(v), grad(q2))*dx + \
(f_x*u+f_y*v)*f_x*q1*dx + (f_x*u+f_y*v)*f_y*q2*dx
L = - f_t*f_x*q1*dx - f_t*f_y*q2*dx
c = Constant((1.0, 1.0))
w = Function(W)
init = interpolate(c, W) #nonzero_initial_guess
w.assign(init)
A = assemble(a)
b = assemble(L)
max_iter = 10000
solver = KrylovSolver('gmres', 'ilu')#cg/gmres jacobi/ilu
solver.parameters['absolute_tolerance'] = 1e-7
solver.parameters['relative_tolerance'] = 1e-5
solver.parameters['maximum_iterations'] = max_iter
#print(solver.parameters.keys())
solver.parameters['nonzero_initial_guess'] = True
solver.solve(A, w.vector(), b)
Thank you for any feed back.