mirror of
https://bitbucket.org/cosmicvoids/vide_public.git
synced 2025-07-05 07:41:11 +00:00
FIXED zobov bug when only using one subdomain; added zobov buffer as tunable parameter
This commit is contained in:
parent
8730193e71
commit
23d665f7bd
6 changed files with 139 additions and 83 deletions
|
@ -17,7 +17,7 @@ int main(int argc, char *argv[]) {
|
|||
coordT rtemp[3], *parts;
|
||||
coordT deladjs[3*MAXVERVER], points[3*MAXVERVER];
|
||||
pointT intpoints[3*MAXVERVER];
|
||||
FILE *pos, *out;
|
||||
FILE *pos, *out, *testFile;
|
||||
char *posfile, outfile[200], *suffix, *outDir;
|
||||
PARTADJ *adjs;
|
||||
float *vols;
|
||||
|
@ -33,8 +33,11 @@ int main(int argc, char *argv[]) {
|
|||
realT c[3];
|
||||
int b[3];
|
||||
double totalvol;
|
||||
int isObs = 0;
|
||||
|
||||
if (argc != 10) {
|
||||
printf("Routine: voz1b1\n");
|
||||
|
||||
if (argc != 11) {
|
||||
printf("Wrong number of arguments.\n");
|
||||
printf("arg1: position file\n");
|
||||
printf("arg2: border size\n");
|
||||
|
@ -43,6 +46,7 @@ int main(int argc, char *argv[]) {
|
|||
printf("arg5: number of divisions\n");
|
||||
printf("arg6-8: b[0-2]\n\n");
|
||||
printf("arg9: output directory\n");
|
||||
printf("arg10: observation flag\n");
|
||||
exit(0);
|
||||
}
|
||||
posfile = argv[1];
|
||||
|
@ -79,8 +83,15 @@ int main(int argc, char *argv[]) {
|
|||
exit(0);
|
||||
}
|
||||
outDir = argv[9];
|
||||
|
||||
if (sscanf(argv[10],"%d",&isObs) != 1) {
|
||||
printf("That's no observation mode; try again.\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
printf("Working with subdomain b=[%d,%d,%d]\n", b[0], b[1], b[2]);
|
||||
|
||||
/* Boxsize should be the range in r, yielding a range 0-1 */
|
||||
printf("Reading particle file...\n");
|
||||
np = posread(posfile,&r,1./boxsize);
|
||||
printf("%d particles\n",np);fflush(stdout);
|
||||
|
||||
|
@ -90,7 +101,8 @@ int main(int argc, char *argv[]) {
|
|||
if (r[i][1]<ymin) ymin = r[i][1]; if (r[i][1]>ymax) ymax = r[i][1];
|
||||
if (r[i][2]<zmin) zmin = r[i][2]; if (r[i][2]>zmax) zmax = r[i][2];
|
||||
}
|
||||
printf("np: %d, x: %f,%f; y: %f,%f; z: %f,%f\n",np,xmin,xmax, ymin,ymax, zmin,zmax); fflush(stdout);
|
||||
printf("Full box particle stats: np: %d, x: %f,%f; y: %f,%f; z: %f,%f\n",np,
|
||||
xmin,xmax, ymin,ymax, zmin,zmax); fflush(stdout);
|
||||
|
||||
width = 1./(float)numdiv;
|
||||
width2 = 0.5*width;
|
||||
|
@ -108,7 +120,7 @@ int main(int argc, char *argv[]) {
|
|||
exit(0);
|
||||
}
|
||||
g = (bf / 2.)*(1. + sqrt(1 - 2.*s*s/(bf*bf)));
|
||||
printf("s = %f, bf = %f, g = %f.\n",s,bf,g);
|
||||
printf("Guard particle information: s = %f, bf = %f, g = %f.\n",s,bf,g);
|
||||
|
||||
fflush(stdout);
|
||||
|
||||
|
@ -118,11 +130,10 @@ int main(int argc, char *argv[]) {
|
|||
exit(1);
|
||||
}
|
||||
|
||||
DL c[d] = ((float)b[d])*width;
|
||||
printf("c: %f,%f,%f\n",c[0],c[1],c[2]);
|
||||
DL c[d] = ((float)b[d]+0.5)*width;
|
||||
printf("Counting particles in subdomain...\n");
|
||||
/* Assign temporary array*/
|
||||
nvpbuf = 0; /* Number of particles to tesselate, including
|
||||
buffer */
|
||||
nvpbuf = 0; /* Number of particles to tesselate, includng ibuffer */
|
||||
nvp = 0; /* Without the buffer */
|
||||
for (i=0; i<np; i++) {
|
||||
isitinbuf = 1;
|
||||
|
@ -139,8 +150,7 @@ int main(int argc, char *argv[]) {
|
|||
if (isitinmain) nvp++;
|
||||
}
|
||||
|
||||
nvpbuf += 6*(NGUARD+1)*(NGUARD+1); /* number of guard
|
||||
points */
|
||||
nvpbuf += 6*(NGUARD+1)*(NGUARD+1); /* number of guard points */
|
||||
|
||||
parts = (coordT *)malloc(3*nvpbuf*sizeof(coordT));
|
||||
orig = (pid_t *)malloc(nvpbuf*sizeof(pid_t));
|
||||
|
@ -156,6 +166,7 @@ int main(int argc, char *argv[]) {
|
|||
exit(1);
|
||||
}
|
||||
|
||||
printf("Placing particles in subdomain...\n");
|
||||
nvp = 0; nvpall = 0; /* nvp = number of particles without buffer */
|
||||
xmin = BF; xmax = -BF; ymin = BF; ymax = -BF; zmin = BF; zmax = -BF;
|
||||
for (i=0; i<np; i++) {
|
||||
|
@ -180,8 +191,13 @@ int main(int argc, char *argv[]) {
|
|||
if (rtemp[2] > zmax) zmax = rtemp[2];
|
||||
}
|
||||
}
|
||||
printf("nvp = %d\n",nvp);
|
||||
printf("x: %f,%f; y: %f,%f; z:%f,%f\n",xmin,xmax,ymin,ymax,zmin,zmax);
|
||||
printf("Subdomain: b=(%d,%d,%d), c=(%f,%f,%f)\n",
|
||||
b[0],b[1],b[2],c[0],c[1],c[2]);
|
||||
printf(" nvp=%d, nvpbuf=%d\n", nvp,nvpbuf);
|
||||
printf(" Particle ranges: x: %f,%f; y: %f,%f; z:%f,%f\n",
|
||||
xmin,xmax,ymin,ymax,zmin,zmax);
|
||||
|
||||
printf("Adding particles to buffer regions...\n");
|
||||
nvpbuf = nvp;
|
||||
for (i=0; i<np; i++) {
|
||||
isitinbuf = 1;
|
||||
|
@ -195,9 +211,6 @@ int main(int argc, char *argv[]) {
|
|||
isitinmain = isitinmain && (fabs(rtemp[d]) <= width2);
|
||||
}
|
||||
if (isitinbuf && !isitinmain) {
|
||||
/*printf("%3.3f ",sqrt(rtemp[0]*rtemp[0] + rtemp[1]*rtemp[1] +
|
||||
rtemp[2]*rtemp[2]));
|
||||
printf("|%2.2f,%2.2f,%2.2f,%f,%f",r[i][0],r[i][1],r[i][2],width2,totwidth2);*/
|
||||
parts[3*nvpbuf] = rtemp[0];
|
||||
parts[3*nvpbuf+1] = rtemp[1];
|
||||
parts[3*nvpbuf+2] = rtemp[2];
|
||||
|
@ -212,16 +225,19 @@ int main(int argc, char *argv[]) {
|
|||
if (rtemp[2] > zmax) zmax = rtemp[2];
|
||||
}
|
||||
}
|
||||
printf("nvpbuf = %d\n",nvpbuf);
|
||||
printf("x: %f,%f; y: %f,%f; z:%f,%f\n",xmin,xmax,ymin,ymax,zmin,zmax);
|
||||
nvpall = nvpbuf;
|
||||
predict = pow(width+2.*bf,3)*(float)np;
|
||||
printf("There should be ~ %f points; there are %d\n",predict,nvpbuf);
|
||||
printf("Total particles including buffer = %d (predicted ~%f)\n",
|
||||
nvpbuf, predict);
|
||||
printf(" Particle ranges including buffer: x: %f,%f; y: %f,%f; z:%f,%f\n",
|
||||
xmin,xmax,ymin,ymax,zmin,zmax);
|
||||
|
||||
for (i=0;i<np;i++) free(r[i]);
|
||||
free(r);
|
||||
|
||||
|
||||
|
||||
/* Add guard points */
|
||||
printf("Adding guard points to subdomain faces...\n");
|
||||
for (i=0; i<NGUARD+1; i++) {
|
||||
for (j=0; j<NGUARD+1; j++) {
|
||||
/* Bottom */
|
||||
|
@ -262,6 +278,23 @@ int main(int argc, char *argv[]) {
|
|||
nvpall++;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
// TEST TEMP
|
||||
testFile = fopen("test.txt", "a");
|
||||
for (i=0; i<nvpall; i++){
|
||||
int itype = 0;
|
||||
if (i > nvp) itype = 1; // it's a buffer particle
|
||||
if (i > nvpbuf) itype = 2; // it's a guard particle
|
||||
fprintf(testFile, "%f %f %f %d %f %f %f\n", c[0], c[1], c[2],
|
||||
itype,
|
||||
parts[3*i],
|
||||
parts[3*i+1],
|
||||
parts[3*i+2]);
|
||||
}
|
||||
fclose(testFile);
|
||||
*/
|
||||
|
||||
xmin = BF; xmax = -BF; ymin = BF; ymax = -BF; zmin = BF; zmax = -BF;
|
||||
for (i=nvpbuf;i<nvpall;i++) {
|
||||
if (parts[3*i] < xmin) xmin = parts[3*i];
|
||||
|
@ -274,7 +307,8 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
printf("Added guard points to total %d points (should be %d)\n",nvpall,
|
||||
nvpbuf + 6*(NGUARD+1)*(NGUARD+1));
|
||||
printf("x: %f,%f; y: %f,%f; z:%f,%f\n",xmin,xmax,ymin,ymax,zmin,zmax);
|
||||
printf("New particle ranges including guards: x: %f,%f; y: %f,%f; z:%f,%f\n",
|
||||
xmin,xmax,ymin,ymax,zmin,zmax);
|
||||
|
||||
/* Do tesselation*/
|
||||
printf("File read. Tessellating ...\n"); fflush(stdout);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue