Navier-Stokes periodic boundary conditions

Hello,

I tried adapting the example NSE.edp in the FreeFem documentation to be fully periodic on the square. I get the error

Problem build of FEspace (2d) (may be : due to periodic Boundary condition missing ) FH
The number of DF must be 3600 and it is 3803

I am hoping someone can point me to an example. The critical part of my code is below.

Thanks,

Mike

fespace Xh(Th, P2, periodic=[[2, y], [4, y], [1, x], [3, x]]); //velocity component space
fespace Mh(Th, P1, periodic=[[2, y], [4, y], [1, x], [3, x]]); //pressure space
real dt = 0.01, nu=.1;
real alpha=20/dt;
Xh u2, v2, up1, up2;
Xh u1, v1, f1, f2;
Mh p, q;
problem NS (u1, u2, p, v1, v2, q, solver=Crout, init=i)
= int2d(Th)(
alpha*(u1v1 + u2v2)
+ nu * (
dx(u1)dx(v1) + dy(u1)dy(v1)
+ dx(u2)dx(v2) + dy(u2)dy(v2)
)
- p
q
(0.000001)
- p
dx(v1) - p
dy(v2)
- dx(u1)q - dy(u2)q
)
+ int2d(Th)(
- (f1
v1+f2
v2)
)
+ int2d(Th)(
- alpha*convect([up1,up2],-dt,up1)v1
- alpha
convect([up1,up2],-dt,up2)*v2
)
;

Hi Mike,

can you show us exactly how you define the mesh?

Best,
Ugis

Dear Ugis,

Thanks for taking a look.

Here’s how I define the mesh:

Th = square(npts, npts, [2xpi, 2ypi]);

Full code is attached.

Kind regards,

Mike

NSEper.edp (1.19 KB)

Hi again,

Thanks for the code. Now I see, the mesh should be fine. But the thing is if you use periodic conditions in FreeFEM along with vectorial equations, you had to use mixed FE space definition (vectorial space definition). Otherwise there is a problem with periodicty. I don’t know the exact reason, probably outcome of how the software is constructed.

In essence, instead of individual P1/P2 spaces, use:
fespace UUPh(Th, [P2,P2,P1], periodic=[[2, y], [4, y], [1, x], [3, x]]); //fluid space

And header in problem definition:
problem NS ([u1, u2, p], [v1, v2, q], solver=Crout, init=i)

Check the full modified code (seems to work on my computer).

Best,
Ugis
NSEper_UL.edp (1.3 KB)