Boundary condition in periodic mesh

hello everyone, i have juste i small probleme about defining a dirichlet contion in down (y=-1)and up boundary (y=-1 +ny*L) for the hall domain, it’s a porous media problem and i try to represent the solution in MACRO schele with darcy equation ,this is the code .
"load “msh3”
load “iovtk”

// Paramètres
real r = 0.2;
int n = 10;

// Définition des bords (identique à votre code macro)
border C01(t=-r, r){x=-1; y=t; label=10;}
border C02(t=-1, -r){x=t; y=r; label=1;}
border C03(t=-1, -r){x=t; y=-r; label=2;}
border C04(t=r, 1){x=-r; y=t; label=3;}
border C05(t=-1, -r){x=-r; y=t; label=4;}
border C06(t=-r, r){x=t; y=1; label=11;}
border C07(t=-r, r){x=t; y=-1; label=22;}
border C08(t=-1, -r){x=r; y=t; label=5;}
border C09(t=r, 1){x=r; y=t; label=6;}
border C10(t=r, 1){x=t; y=r; label=7;}
border C11(t=r, 1){x=t; y=-r; label=8;}
border C12(t=-r, r){x=1; y=t; label=36;}

// Construction du maillage de base
mesh ThBase = 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));

// Création du domaine périodique macro
int nx = 10, ny = 10;
real L = 2.0;
mesh ThMulti = movemesh(ThBase, [x, y]);

for (int i = 0; i < nx; i++) {
for (int j = 0; j < ny; j++) {
if (i != 0 || j != 0) {
mesh ThTmp = movemesh(ThBase, [x + iL, y + jL]);
ThMulti = ThMulti + ThTmp;
}
}
}

plot(ThMulti, wait=true, cmm=“Domaine macro”);

fespace Vh(ThMulti, P1);
Vh p, q; // Pression
real K=0.001;
real mu=1;
real Pup= 100;
real Pdown = 200;
problem Darcy(p, q)
= int2d(ThMulti)( K * dx(p)*dx(q) + K * dy(p)*dy(q) )

  • on(??, p = Pup)
  • on(??, p = Pdown);

// Résolution
Darcy;

// Champ de vitesse macroscopique
Vh vx = -K/mu * dx(p);
Vh vy = -K/mu * dy(p);

// Visualisation
plot(p, fill=true, value=true, wait=true, cmm=“Pression P^0”);
plot([vx, vy], wait=true, cmm=“Champ de vitesse macroscopique V^0”);

fespace Vh1(ThMulti, P1);
Vh1 Ux1 = vx, Uy1 = vy, p1 = p;

int[int] order = [1, 1, 1]; 
savevtk("StokesSolutionnn.vtu", ThMulti, Ux1, Uy1, p1, 
        dataname="Velocity_X Velocity_Y Pressure", order=order);



        " and thank you so much for your help

Hello,
You have to use the command change to change the labels. For example

labs=[22,100];
 ThTmp = change(ThTmp,refe=labs);

changes the boundary label 22 to the new value 100.
You can also remove internal edges by
ThMulti = change(ThMulti,rmInternalEdges=true);

I have put the label 100 on the bottom edges, and 200 on the top edges.
porous-periodic.edp (2.0 KB)

1 Like

It works perfectly,thank you so much !!