Time-dependent Navier–Stokes equations

But you don’t change u in your new code. I mean the exact u could be

u1_ex = 10 * pow(x[0], 2) * pow((x[0] - 1), 2) * x[1] * (x[1] - 1) * (2 * x[1] - 1) * cos(t)
u2_ex = - 10 * x[0] * (x[0] - 1) * (2 * x[0] - 1) * pow(x[1], 2) * pow((x[1] - 1), 2) * cos(t)

I think it’s not difficult to verify \mathrm{div}\,u = 0.

Thanks Mr.Sun1130
Thank you again for your reply. I’m sorry, I misunderstood your meaning.
You are right, this exact solution did lack a minus sign when I wrote this program, but when I used Matlab to solve f1_ex and f2_ex, I used the correct solution.
After the correct u1_ex, u2_ex are brought into the original equation, the obtained results remain the same. Now I’m wondering if there’s something wrong with the variation. Thank you again!

I implemented the semi-implicit Euler scheme by using FEniCSx last month, and you can take this as a reference.

F = dot((u - u_n) / k, v) * dx + 0.5 * (dot(dot(u_n, nabla_grad(u)), v) - dot(dot(u_n, nabla_grad(v)), u)) * dx + nu * inner(grad(u), grad(v)) * dx - p * div(v) * dx + div(u) * q * dx - dot(fh, v) * dx
a = form(ufl.lhs(F))
L = form(ufl.rhs(F))

The code is a little bit different, but I think it can help.

Thanks Mr.Sun1130
I try your Euler scheme,but results is same.I was frustrated :smiling_face_with_tear: