I'm trying to solve a nonlinear problem, say
nabla.(k(u).nabla(u)) = C.
I have a problem in that i don't know k(u) in terms of a function of u, or a function of spatial coordinates, but only as a list of u and its corresponding k. I currently have a function which interpolates the data, and if a solution u is known, I can find out the corresponding k's from this function.
However, I don't think this is working once it's incorporated into the problem as it solves. I've been told making a subclass in Expression might be worth looking into, but i have no idea how i'm supposed to do this since i don't know things in terms of x[0] etc.
Any help appreciated - below is a snippet of code which explains where my k is.
interpolate_table is my interpolating code that takes points on u and uses k_data which is teh list of data and outputs corresponding k (if i do plot(project(k,V)) it works as expected). I had used this code with k_data being points with k=1+u^2 and C was the corresponding source term with u=x^2 as the solution.
u = Function(V)
v = TestFunction(V)
k = interpolate_table(u,k_data)
C = Expression("-2.0-10.0*x[0]*x[0]*x[0]*x[0]")
diff_part = inner(k*grad(u),grad(v))*dx
source_part = S*v*dx
Res = diff_part - source_part
J = derivative(Res,u)
problem = NonlinearVariationalProblem(Res, u, bcs, J)
solver = NonlinearVariationalSolver(problem)
solver.solve()
prm = solver.parameters['newton_solver']
prm['relative_tolerance'] = 1E-6
prm['maximum_iterations'] = 100