Periodic conditions boundary

hello everyone, i’m trying to put periodic condition on stokes equation "real Mu = 1.;
real pEps = 1.e-10;

border C01(t=-0.05, 0.05){x=-1; y=t; label=10;}
border C02(t=-1, -0.05){x=t; y=0.05; label=1;}
border C03(t=-1, -0.05){x=t; y=-0.05; label=2;}
border C04(t=0.05, 1){x=-0.05; y=t; label=3;}
border C05(t=-1, -0.05){x=-0.05; y=t; label=4;}
border C06(t=-0.05, 0.05){x=t; y=1; label=11;}
border C07(t=-0.05, 0.05){x=t; y=-1; label=22;}
border C08(t=-1, -0.05){x=0.05; y=t; label=5;}
border C09(t=0.05, 1){x=0.05; y=t; label=6;}
border C10(t=0.05, 1){x=t; y=0.05; label=7;}
border C11(t=0.05, 1){x=t; y=-0.05; label=8;}
border C12(t=-0.05, 0.05){x=1; y=t; label=36;}

int n = 100;
plot(C01(-n)+C02(-n)+ C03(-n)+C04(n)+C05(n)+ C06(n)

  • C07(n)+ C08(n)+ C09(n)+ C10(n)+C11(n)+C12(n) , wait=true);

mesh Th = buildmesh(C01(-n)+C02(-n)+C04(-n)+ C06(-n)
+C09(n)+C10(-n)+C12(n)+C11(n)+C08(n)+ C07(n)+C05(-n) + C03(n));

plot(Th, wait=true);

// Fespace
fespace Uh(Th, P2,periodic=[[10,y],[36,y],[11,x],[22,x]]);
Uh Ux, Uy;
Uh Uhx, Uhy;

fespace Ph(Th, P1);
Ph p;
Ph ph;

// Macro
macro grad(u) [dx(u), dy(u)] //
macro Grad(U) [grad(U#x), grad(U#y)] //
macro div(ux, uy) (dx(ux) + dy(uy)) //
macro Div(U) div(U#x, U#y) //

// Problem
problem Stokes ([Ux, Uy, p], [Uhx, Uhy, ph])
= int2d(Th)(
Mu * (Grad(U) : Grad(Uh))
- p Div(Uh)
- ph * Div(U)
- pEps * p * ph
)
+ int2d(Th)( 1 * Uhx + 1
Uhy)
+ on(1,2,3,4,5,6,7,8, Ux=0, Uy=0)
;

// Solve
Stokes;

// Plot
plot(Ux, fill=true, value=true, wait=true);

real area = int2d(Th)(1.0);

real Kxx = -int2d(Th)(Ux) / 4;
real Kyy = -int2d(Th)(Uy) / 4;

cout << "Kxx = " << Kxx << endl;
cout << “Kyy = " << Kyy << endl;
" but it always give me this error"esh: Nb of Triangles = 132, Nb of Vertices 125
Problem build of FEspace (2d) (may be : due to periodic Boundary condition missing ) FH
The number of DF must be 811 and it is 887
current line = 61
Assertion fail : (snbdf == NbOfDF)
line :937, in file ../femlib/FESpace.cpp
Assertion fail : (snbdf == NbOfDF)
line :937, in file ../femlib/FESpace.cpp
err code 6 , mpirank 0” i have been struggling for a long time with this ,i really need your help ,and thank you so much in advance

Use the composite tool to solve this problem
see:

1 Like

It seems to me that the pressure space should be periodic also.
Then you can use

fespace UPh(Th,[P2,P2,P1],periodic=[[10,y],[36,y],[11,x],[22,x]]);
UPh [Ux,Uy,p],[Uhx,Uhy,ph];

problem Stokes ([Ux, Uy, p], [Uhx, Uhy, ph])
= int2d(Th)(
Mu * (grad(Ux)'*grad(Uhx)+grad(Uy)'*grad(Uhy))
- p * div(Uhx,Uhy)
- ph * div(Ux,Uy)
- pEps * p * ph
)
+ int2d(Th)( 1 * Uhx + 1 * Uhy)
+ on(1,2,3,4,5,6,7,8, Ux=0, Uy=0)
;

thank you so much it worked

thanks for your help

I agree with François