#if DLMFD# define NPARTICLES 2# define mydt 1e-1# include "dlmfd.h"#else# include "navier-stokes/centered.h"#endifint main(){ size (2.); origin (0,-L0/2.); stokes =true; TOLERANCE =1e-5;constfacevector g[]={1.,0.}; a = g;#if !DLMFDconstfacevector muc[]={1.,1.}; mu = muc;#endiffor(N =8; N <=64; N *=2)run();}u.t[top]=dirichlet(0);u.t[bottom]=dirichlet(0);u.n[left]=neumann(0);p[left]=dirichlet(0);u.n[right]=neumann(0);p[right]=dirichlet(0);scalar un[];event init (i =0){#if !DLMFDmask(y >0.5? top : y <-0.5? bottom : none);#endifforeach(){ un[]= u.x[];}#if DLMFD/* initial condition: particles position */particle* p = particles;for(int k =0; k < NPARTICLES; k++){ p[k].iswall =1; coord wallmin, wallmax, wallpos; wallmin.x =0; wallmax.x = L0; wallmax.y =-L0/4+ k*3*L0/4; wallmin.y =-L0/2+ k*3*L0/4;if(k ==0) wallpos.y = wallmax.y;if(k ==1) wallpos.y = wallmin.y; p[k].wallmin = wallmin; p[k].wallmax = wallmax; p[k].wallpos = wallpos;}#endif}event logfile (t +=0.1; t <=10.){double du =change(u.x, un);if(i >0&& du <1e-6)return1;/* stop */}event profile (t = end){printf("\n");scalar e[];foreach(){ e[]= u.x[]-0.5*(0.25- y*y)*(fabs(y)<0.5);printf("%g%g%g%g%g%g%d\n", x, y, u.x[], u.y[], p[], e[], N);}norm n =normf(e);fprintf(stderr,"%d%g%g%g\n", N, n.avg, n.rms, n.max);#if DLMFD/* performances display/output */particle* p = particles;output_dlmfd_perf(dlmfd_globaltiming, i, p);char name[80];sprintf(name,"dump_dlmfd-%d", N);dump(name);#endif}
Solution comparison
Mask() function
plot[-0.5:0.5][0:0.14]\"< grep '8$' out" u 2:3 t 'N = 8', \"< grep '16$' out" u 2:3 t 'N = 16', \"< grep '32$' out" u 2:3 t 'N = 32', \"< grep '64$' out" u 2:3 t 'N = 64', \"< grep '128$' out" u 2:3 t 'N = 128', \ 0.5*(0.25 - x*x)