Debian Codegraph @

idp/cube.idp

raw
1 load "medit"
2 // ! basic functions to build regular mesh of a cube
3 /*
4 mesh3 Cube(NN,BB,L);
5 -- build the surface mesh of a 3d box
6 where: for exqmple:
7 int[int] NN=[nx,ny,nz]; // the number of seg in the 3 direction
8 real [int,int] BB=[[xmin,xmax],[ymin,ymax],[zmin,zmax]]; // bounding bax
9 int [int,int] L=[[1,2],[3,4],[5,6]]; // the label of the 6 face left,right, front, back, down, right
10 */
11 func mesh3 Cube(int[int] & NN,real[int,int] &BB ,int[int,int] & L)
12 {
13 // first build the 6 faces of the hex.
14 real x0=BB(0,0),x1=BB(0,1);
15 real y0=BB(1,0),y1=BB(1,1);
16 real z0=BB(2,0),z1=BB(2,1);
17
18 int nx=NN[0],ny=NN[1],nz=NN[2];
19 mesh Thx = square(nx,ny,[x0+(x1-x0)*x,y0+(y1-y0)*y]);
20
21 int[int] rup=[0,L(2,1)], rdown=[0,L(2,0)],
22 rmid=[1,L(1,0), 2,L(0,1), 3, L(1,1), 4, L(0,0) ];
23 mesh3 Th=buildlayers(Thx,nz, zbound=[z0,z1],
24 labelmid=rmid, labelup = rup,
25 labeldown = rdown);
26
27 return Th;
28 }
29 func mesh3 Cube(int Nx,int Ny,int Nz)
30 {
31 int[int] NN=[Nx,Ny,Nz];
32 real [int,int] BB=[[0,1],[0,1],[0,1]];
33 int[int,int] LL=[[1,2],[3,4],[5,6]];
34 return Cube(NN,BB,LL);
35 }
36
37
38