--- name: cube-period category: mathematics and porous media folder: 3d --- ## Solve a PDE in a cube with periodic conditions Here the cube is generated by an extrusion in the vertical direction of a square ~~~freefem int nn=10; mesh Th2=square(nn,nn,region=0); fespace Vh2(Th2,P2); ~~~ The numbering of the faces of the cube is done by hand here ~~~freefem int[int] rup=[0,5], rdown=[0,6], rmid=[4,1,2,2, 1,3 ,3,4]; // label face numbering // 1 : ( x == xmin) 2 : ( x == xmax) // 3 : ( y == ymin) 4 : ( y == ymax) // 5 : ( z == zmin) 6 : ( z == zmax) // --- real zmin=0,zmax=1; mesh3 Th=buildlayers(Th2,nn, zbound=[zmin,zmax], // region=r1, labelmid=rmid, reffaceup = rup, reffacelow = rdown); cout << "Th : nv = " << Th.nv << " nt =" << Th.nt << endl; //savemesh(Th,"Th.mesh"); ~~~ Let us read as many messages as possible by setting the verbosity to level 10. The periodic conditions work by pairs. for instance $\texttt{periodic=[[1,y,z],[2,y,z]]}$ means periodicity in x and y between face 1 (x=xmin) and face 2 (x=xmax). ~~~freefem verbosity=10; // the Finite element space with full periodic condition in 3 axes fespace Vh(Th,P2,periodic=[[1,y,z],[2,y,z],[3,x,z],[4,x,z],[5,x,y],[6,x,y]]); verbosity=2; ~~~ The following aims at verifying that all went well ~~~freefem fespace Vhh(Th,P2); int[int] num(Vhh.ndof); num=-1; int er=0; for(int k=0;k