31 int nx_,
int ny_,
int nz_,
bool xperiodic_,
bool yperiodic_,
bool zperiodic_,
int init_mem,
int ps_)
32 :
voro_base(nx_,ny_,nz_,(bx_-ax_)/nx_,(by_-ay_)/ny_,(bz_-az_)/nz_),
33 ax(ax_), bx(bx_), ay(ay_), by(by_), az(az_), bz(bz_),
34 xperiodic(xperiodic_), yperiodic(yperiodic_), zperiodic(zperiodic_),
35 id(new int*[nxyz]), p(new double*[nxyz]), co(new int[nxyz]), mem(new int[nxyz]), ps(ps_) {
37 for(l=0;l<
nxyz;l++)
co[l]=0;
38 for(l=0;l<
nxyz;l++)
mem[l]=init_mem;
39 for(l=0;l<
nxyz;l++)
id[l]=
new int[init_mem];
40 for(l=0;l<
nxyz;l++)
p[l]=
new double[
ps*init_mem];
46 for(l=0;l<
nxyz;l++)
delete []
p[l];
47 for(l=0;l<
nxyz;l++)
delete []
id[l];
65 int nx_,
int ny_,
int nz_,
bool xperiodic_,
bool yperiodic_,
bool zperiodic_,
int init_mem)
66 :
container_base(ax_,bx_,ay_,by_,az_,bz_,nx_,ny_,nz_,xperiodic_,yperiodic_,zperiodic_,init_mem,3),
67 vc(*this,xperiodic_?2*nx_+1:nx_,yperiodic_?2*ny_+1:ny_,zperiodic_?2*nz_+1:nz_) {}
80 int nx_,
int ny_,
int nz_,
bool xperiodic_,
bool yperiodic_,
bool zperiodic_,
int init_mem)
81 :
container_base(ax_,bx_,ay_,by_,az_,bz_,nx_,ny_,nz_,xperiodic_,yperiodic_,zperiodic_,init_mem,4),
82 vc(*this,xperiodic_?2*nx_+1:nx_,yperiodic_?2*ny_+1:ny_,zperiodic_?2*nz_+1:nz_) {
ppr=
p;}
91 double *pp=
p[ijk]+3*co[ijk]++;
92 *(pp++)=x;*(pp++)=y;*pp=z;
104 double *pp=
p[ijk]+4*co[ijk]++;
105 *(pp++)=x;*(pp++)=y;*(pp++)=z;*pp=r;
120 double *pp=
p[ijk]+3*co[ijk]++;
121 *(pp++)=x;*(pp++)=y;*pp=z;
136 double *pp=
p[ijk]+4*co[ijk]++;
137 *(pp++)=x;*(pp++)=y;*(pp++)=z;*pp=r;
156 #if VOROPP_REPORT_OUT_OF_BOUNDS ==1
157 fprintf(stderr,
"Out of bounds: (x,y,z)=(%g,%g,%g)\n",x,y,z);
176 else if(ijk<0||ijk>=
nx)
return false;
180 else if(j<0||j>=
ny)
return false;
184 else if(k<0||k>=
nz)
return false;
200 inline bool container_base::remap(
int &ai,
int &aj,
int &ak,
int &ci,
int &cj,
int &ck,
double &x,
double &y,
double &z,
int &ijk) {
235 int ai,aj,ak,ci,cj,ck,ijk;
241 if(!
remap(ai,aj,ak,ci,cj,ck,x,y,z,ijk))
return false;
242 vc.find_voronoi_cell(x,y,z,ci,cj,ck,ijk,w,mrs);
273 int ai,aj,ak,ci,cj,ck,ijk;
279 if(!
remap(ai,aj,ak,ci,cj,ck,x,y,z,ijk))
return false;
280 vc.find_voronoi_cell(x,y,z,ci,cj,ck,ijk,w,mrs);
303 int l,nmem=
mem[i]<<1;
307 if(nmem>max_particle_memory)
309 #if VOROPP_VERBOSE >=3
310 fprintf(stderr,
"Particle memory in region %d scaled up to %d\n",i,nmem);
314 int *idp=
new int[nmem];
315 for(l=0;l<
co[i];l++) idp[l]=
id[i][l];
316 double *pp=
new double[
ps*nmem];
317 for(l=0;l<
ps*co[i];l++) pp[l]=
p[i][l];
321 delete []
id[i];
id[i]=idp;
322 delete []
p[i];
p[i]=pp;
333 while((j=fscanf(fp,
"%d %lg %lg %lg",&i,&x,&y,&z))==4)
put(i,x,y,z);
346 while((j=fscanf(fp,
"%d %lg %lg %lg",&i,&x,&y,&z))==4)
put(vo,i,x,y,z);
358 while((j=fscanf(fp,
"%d %lg %lg %lg %lg",&i,&x,&y,&z,&r))==5)
put(i,x,y,z,r);
371 while((j=fscanf(fp,
"%d %lg %lg %lg %lg",&i,&x,&y,&z,&r))==5)
put(vo,i,x,y,z,r);
379 for(k=0;k<
nz;k++)
for(j=0;j<
ny;j++)
for(i=0;i<
nx;i++)
380 printf(
"Region (%d,%d,%d): %d particles\n",i,j,k,*(cop++));
385 for(
int *cop=
co;cop<
co+
nxyz;cop++) *cop=0;
391 for(
int *cop=
co;cop<
co+
nxyz;cop++) *cop=0;
416 FILE *fp=safe_fopen(filename,
"w");
426 FILE *fp=safe_fopen(filename,
"w");
482 if(x<ax||x>
bx||y<ay||y>
by||z<az||z>
bz)
return false;
489 fprintf(fp,
"%g %g %g\n%g %g %g\n%g %g %g\n%g %g %g\n",
ax,
ay,
az,
bx,
ay,
az,
bx,
by,
az,
ax,
by,
az);
490 fprintf(fp,
"%g %g %g\n%g %g %g\n%g %g %g\n%g %g %g\n",
ax,
by,
bz,
bx,
by,
bz,
bx,
ay,
bz,
ax,
ay,
bz);
491 fprintf(fp,
"%g %g %g\n\n%g %g %g\n%g %g %g\n\n",
ax,
by,
bz,
ax,
ay,
az,
ax,
ay,
bz);
492 fprintf(fp,
"%g %g %g\n%g %g %g\n\n%g %g %g\n%g %g %g\n\n",
bx,
ay,
az,
bx,
ay,
bz,
bx,
by,
az,
bx,
by,
bz);
498 fprintf(fp,
"cylinder{<%g,%g,%g>,<%g,%g,%g>,rr}\n"
499 "cylinder{<%g,%g,%g>,<%g,%g,%g>,rr}\n",
ax,
ay,
az,
bx,
ay,
az,
ax,
by,
az,
bx,
by,
az);
500 fprintf(fp,
"cylinder{<%g,%g,%g>,<%g,%g,%g>,rr}\n"
501 "cylinder{<%g,%g,%g>,<%g,%g,%g>,rr}\n",
ax,
by,
bz,
bx,
by,
bz,
ax,
ay,
bz,
bx,
ay,
bz);
502 fprintf(fp,
"cylinder{<%g,%g,%g>,<%g,%g,%g>,rr}\n"
503 "cylinder{<%g,%g,%g>,<%g,%g,%g>,rr}\n",
ax,
ay,
az,
ax,
by,
az,
bx,
ay,
az,
bx,
by,
az);
504 fprintf(fp,
"cylinder{<%g,%g,%g>,<%g,%g,%g>,rr}\n"
505 "cylinder{<%g,%g,%g>,<%g,%g,%g>,rr}\n",
bx,
ay,
bz,
bx,
by,
bz,
ax,
ay,
bz,
ax,
by,
bz);
506 fprintf(fp,
"cylinder{<%g,%g,%g>,<%g,%g,%g>,rr}\n"
507 "cylinder{<%g,%g,%g>,<%g,%g,%g>,rr}\n",
ax,
ay,
az,
ax,
ay,
bz,
bx,
ay,
az,
bx,
ay,
bz);
508 fprintf(fp,
"cylinder{<%g,%g,%g>,<%g,%g,%g>,rr}\n"
509 "cylinder{<%g,%g,%g>,<%g,%g,%g>,rr}\n",
bx,
by,
az,
bx,
by,
bz,
ax,
by,
az,
ax,
by,
bz);
510 fprintf(fp,
"sphere{<%g,%g,%g>,rr}\nsphere{<%g,%g,%g>,rr}\n"
511 "sphere{<%g,%g,%g>,rr}\nsphere{<%g,%g,%g>,rr}\n",
ax,
ay,
az,
bx,
ay,
az,
ax,
by,
az,
bx,
by,
az);
512 fprintf(fp,
"sphere{<%g,%g,%g>,rr}\nsphere{<%g,%g,%g>,rr}\n"
513 "sphere{<%g,%g,%g>,rr}\nsphere{<%g,%g,%g>,rr}\n",
ax,
ay,
bz,
bx,
ay,
bz,
ax,
by,
bz,
bx,
by,
bz);
519 current_wall_size(init_wall_size) {}
544 while(wp<
wep) *(nwp++)=*(wp++);
bool remap(int &ai, int &aj, int &ak, int &ci, int &cj, int &ck, double &x, double &y, double &z, int &ijk)
#define VOROPP_MEMORY_ERROR
Class for looping over all of the particles in a container.
double sum_cell_volumes()
Structure for holding information about a particle.
bool put_remap(int &ijk, double &x, double &y, double &z)
void import(FILE *fp=stdin)
void increase_wall_memory()
Class containing data structures common across all particle container classes.
A class for storing a list of pointers to walls.
void draw_domain_gnuplot(FILE *fp=stdout)
#define VOROPP_FILE_ERROR
bool find_voronoi_cell(double x, double y, double z, double &rx, double &ry, double &rz, int &pid)
int step_mod(int a, int b)
container_base(double ax_, double bx_, double ay_, double by_, double az_, double bz_, int nx_, int ny_, int nz_, bool xperiodic_, bool yperiodic_, bool zperiodic_, int init_mem, int ps_)
bool put_locate_block(int &ijk, double &x, double &y, double &z)
container(double ax_, double bx_, double ay_, double by_, double az_, double bz_, int nx_, int ny_, int nz_, bool xperiodic_, bool yperiodic_, bool zperiodic_, int init_mem)
void print_custom(c_loop &vl, const char *format, FILE *fp)
int step_div(int a, int b)
bool point_inside_walls(double x, double y, double z)
bool find_voronoi_cell(double x, double y, double z, double &rx, double &ry, double &rz, int &pid)
Class for representing a particle system in a three-dimensional rectangular box.
Header file for the container_base and related classes.
double sum_cell_volumes()
void put(int n, double x, double y, double z)
bool compute_cell(v_cell &c, c_loop &vl)
container_poly(double ax_, double bx_, double ay_, double by_, double az_, double bz_, int nx_, int ny_, int nz_, bool xperiodic_, bool yperiodic_, bool zperiodic_, int init_mem)
Pure virtual class from which wall objects are derived.
void import(FILE *fp=stdin)
Extension of the voronoicell_base class to represent a Voronoi cell without neighbor information...
void put(int n, double x, double y, double z, double r)
void print_custom(c_loop &vl, const char *format, FILE *fp)
bool compute_cell(v_cell &c, c_loop &vl)
void add_particle_memory(int i)
A class for storing ordering information when particles are added to a container. ...
void draw_domain_pov(FILE *fp=stdout)
bool point_inside(double x, double y, double z)