X-Git-Url: https://hackdaworld.org/gitweb/?p=physik%2Fnlsop.git;a=blobdiff_plain;f=nlsop.c;h=5d44239dd5180f60d3edfe8a2bcf6a3dbd9c6979;hp=9b9f8039e2a790556b7896037b1eb1a1e58b212a;hb=432c30bbaa659faf5103ca4c969285dade166df2;hpb=c37428b4496d4854ee7bd43b45be36238625c965 diff --git a/nlsop.c b/nlsop.c index 9b9f803..5d44239 100644 --- a/nlsop.c +++ b/nlsop.c @@ -328,6 +328,43 @@ int calc_max_extra(d3_lattice *d3_l) return max; } +int write_ac_distr(d3_lattice *d3_l,int ac_distr) +{ + int fd,x,y,z; + int count=0,offset; + char file[16]; + + if(ac_distr==1) strcpy(file,"a.plot"); + if(ac_distr==2) strcpy(file,"c.plot"); + if(ac_distr==3) strcpy(file,"b.plot"); + + if((fd=open(file,O_WRONLY|O_CREAT))<0) + { + puts("cannot open plot file"); + return -1; + } + + for(z=0;zmax_z;z++) + { + for(x=0;xmax_x;x++) + { + for(y=0;ymax_y;y++) + { + offset=x+y*d3_l->max_x+z*d3_l->max_x*d3_l->max_y; + if(ac_distr==1) + if(*(d3_l->status+offset)&AMORPH) count+=*(d3_l->extra+offset); + if(ac_distr==2) + if(!(*(d3_l->status+offset)&AMORPH)) count+=*(d3_l->extra+offset); + if(ac_distr==3) count+=*(d3_l->extra+offset); + } + } + dprintf(fd,"%d %d\n",z,count); + } + close(fd); + + return 1; +} + int write_bmp(d3_lattice *d3_l,int window,u32 x,u32 y,u32 z) { int fd,i,j,size=0,foo=0,end=0; @@ -658,7 +695,7 @@ int get_c_ratio(double *c_ratio,char *pfile,info *my_info,d3_lattice *d3_l) int main(int argc,char **argv) { u32 x,y,z,x_c,y_c,z_c; - int i,j,quit,escape,switchmode,nowait,bmp; + int i,j,quit,escape,switchmode,nowait,bmp,ac_distr; int refresh,resave; int c_step; char s_file[MAX_CHARS]; @@ -1002,9 +1039,10 @@ int main(int argc,char **argv) if(switchmode==2) strcpy(mode_txt,"view: a pressure mode"); d3_lattice_draw(&d3_l,x,y,z,25,arg_v,mode,max_extra); bmp=0; - scan_event(&d3_l,&x,&y,&z,&quit,&escape,&switchmode,&bmp); + ac_distr=0; + scan_event(&d3_l,&x,&y,&z,&quit,&escape,&switchmode,&bmp,&ac_distr); if(bmp) write_bmp(&d3_l,bmp,x,y,z); - + if(ac_distr) write_ac_distr(&d3_l,ac_distr); } d3_lattice_release(&d3_l);