Hello, I want to control the inlet and outlet direction of the flow. How can I set the directions as the photo that I added. Can you help me?
Thank you.
load "medit"
//mesh Th = square(30, 30);
int n = 20;
border left1(t=0,0.5){ x=0.0 ; y=0.5-t; label=1;};
border bot1(t=0,1.0){ x=t ; y=0.0; label=0;};
border left2(t=0,0.5){ x=1.0 ; y=0.0-t; label=0;};
border bot2(t=0,5.0){ x=1.0+t ; y=-0.5; label=0;};
border right(t=0,1.0){ x=6.0 ; y=-0.5+t; label=2;};
border top(t=0,6.0){ x=6.0-t ; y=0.5; label=0;};
mesh Th = buildmesh(left1(50)+bot1(50)+left2(50)+bot2(100)+right(10)+top(100));
plot(Th, wait=1);
fespace Uh(Th, P1b); Uh u1,u2,v1,v2, uold1 = 0, uold2 = 0, psi, phi;
fespace Ph(Th, P1); Ph p, q;
macro Grad(u)[dx(u), dy(u)]//
func f1 = 0;
func f2 = 0;
real T = 1, nu = 0.000001, dt = 0.01;
int count = 0;
solve NavierStokes (u1,u2,p,v1,v2,q,solver=Crout) =
int2d(Th)((u1*v1 + u2*v2)/dt)
+ int2d(Th)( nu*(Grad(u1)'*Grad(v1) + nu*Grad(u2)'*Grad(v2))
- 1e-8*p*q
- p*dx(v1) - p*dy(v2)
- dx(u1)*q - dy(u2)*q)
- int2d(Th)(f1*v1 + f2*v2)
- int2d(Th)(convect([uold1,uold2],-dt,uold1)*v1/dt
+ convect([uold1,uold2],-dt,uold2)*v2/dt)
+ on(1,u1=1,u2=0)
+ on(3,5, u1=0,u2=0);
solve streamlines(psi,phi) =
int2d(Th)( dx(psi)*dx(phi) + dy(psi)*dy(phi))
+ int2d(Th)( -phi*(dy(u1)-dx(u2)))
+ on(1,2,3,4,psi=0);
for (real t = 0; t <= T; t += dt)
{
uold1 = u1;
uold2 = u2;
NavierStokes;
streamlines;
plot([u1, u2],p);
// savemesh(Th, "Th." + count + ".mesh");
// savesol("Th." + count + ".sol", Th, [u1, u2], p);
// count ++;
}
plot(psi);![m2|690x247](upload://eAILxlWvzIPitqdBirASlCK7RLo.jpeg)