u = Function(V) # Displacement from previous iteration
So, the expression from the link does not reference the trial function, but a known function. If your expression uses the trial function I think you need to to express it directly in UFL. I believe expressions must evaluate to scalars, not arguments. Otherwise, you may be able to use iteration to solve your problem.
I see. In the problem I’m trying to solve, I have a non-linear source function, that is position and TrialFunction dependent, that relies on some scipy interpolations, which I can’t express directly in UFL. I guess there is no way to do it FENICS then?
If your problem is nonlinear you can either use the built-in nonlinear support in FEniCS (NewtonSolver) which uses iterations, but requires pure UFL (I believe, I have never used it), or you can implement Newton or Picard fixed point iteration yourself. Both using FEniCS, but with a loop that assembles and solves the problem until convergence
Did you try to find a solution?
I am stuck with a similar issue (link). I have non-linear coefficients that are dependent on the trial functions as well.