You need to add a global
to your u
:
....
global u
u = u_new
end
But note that after above statement your u
and u_new
point to the same array, which is probably not what you want. Probably best to swap bindings:
....
global u, u_new
u, u_new = u_new, u
end
Next time, please post a minimal, working (or erroring) example to make it easy on your helpers: Please read: make it easier to help you
Also, note that running stuff in global scope, i.e. not in a function is not performant. Check the performance-tips of the docs.