mirror of
https://bitbucket.org/cosmicvoids/vide_public.git
synced 2025-07-05 07:41:11 +00:00
Recount the number of adjacencies, which is not fully preserved by the merging and can cause assertion failure in other software
This commit is contained in:
parent
61bb0684cc
commit
9ce6b3f683
1 changed files with 29 additions and 4 deletions
|
@ -8,6 +8,7 @@ int main(int argc, char *argv[]) {
|
||||||
FILE *part, *adj, *vol;
|
FILE *part, *adj, *vol;
|
||||||
char partfile[200], *suffix, adjfile[200], volfile[200], *outDir;
|
char partfile[200], *suffix, adjfile[200], volfile[200], *outDir;
|
||||||
float *vols, volstemp;
|
float *vols, volstemp;
|
||||||
|
int *cnt_adj;
|
||||||
|
|
||||||
PARTADJ *adjs;
|
PARTADJ *adjs;
|
||||||
|
|
||||||
|
@ -78,13 +79,17 @@ int main(int argc, char *argv[]) {
|
||||||
if (mockIndex == -1) mockIndex = np;
|
if (mockIndex == -1) mockIndex = np;
|
||||||
// END PMS
|
// END PMS
|
||||||
|
|
||||||
|
cnt_adj = (int *)malloc(np*sizeof(int));
|
||||||
|
if (cnt_adj == NULL)
|
||||||
|
printf("Could not allocate cnt_adj.\n");
|
||||||
|
|
||||||
adjs = (PARTADJ *)malloc(np*sizeof(PARTADJ));
|
adjs = (PARTADJ *)malloc(np*sizeof(PARTADJ));
|
||||||
if (adjs == NULL) printf("Couldn't allocate adjs.\n");
|
if (adjs == NULL) printf("Couldn't allocate adjs.\n");
|
||||||
vols = (float *)malloc(np*sizeof(float));
|
vols = (float *)malloc(np*sizeof(float));
|
||||||
if (vols == NULL) printf("Couldn't allocate vols.\n");
|
if (vols == NULL) printf("Couldn't allocate vols.\n");
|
||||||
orig = (int *)malloc(nvpmax*sizeof(int));
|
orig = (int *)malloc(nvpmax*sizeof(int));
|
||||||
if (orig == NULL) printf("Couldn't allocate orig.\n");
|
if (orig == NULL) printf("Couldn't allocate orig.\n");
|
||||||
if ((vols == NULL) || (orig == NULL) || (adjs == NULL)) {
|
if ((cnt_adj==NULL) || (vols == NULL) || (orig == NULL) || (adjs == NULL)) {
|
||||||
printf("Not enough memory to allocate. Exiting.\n");
|
printf("Not enough memory to allocate. Exiting.\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
@ -238,11 +243,24 @@ printf("\n");
|
||||||
// END OMS
|
// END OMS
|
||||||
/* Adjacencies: first the numbers of adjacencies,
|
/* Adjacencies: first the numbers of adjacencies,
|
||||||
and the number we're actually going to write per particle */
|
and the number we're actually going to write per particle */
|
||||||
|
|
||||||
|
// Recount the number of adjacencies after merge
|
||||||
|
for(i=0;i<mockIndex;i++)
|
||||||
|
cnt_adj[i] = 0;
|
||||||
|
for(i=0;i<mockIndex;i++)
|
||||||
|
{
|
||||||
|
for (j=0;j<adjs[i].nadj;j++)
|
||||||
|
{
|
||||||
|
cnt_adj[adjs[i].adj[j]]++;
|
||||||
|
cnt_adj[i]++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// PMS
|
// PMS
|
||||||
for (i=0;i<mockIndex;i++)
|
for (i=0;i<mockIndex;i++)
|
||||||
//for (i=0;i<np;i++)
|
//for (i=0;i<np;i++)
|
||||||
// END PMS
|
// END PMS
|
||||||
fwrite(&adjs[i].nadj,1,sizeof(int),adj);
|
fwrite(&cnt_adj[i],1,sizeof(int),adj);
|
||||||
|
|
||||||
/* Now the lists of adjacencies (without double counting) */
|
/* Now the lists of adjacencies (without double counting) */
|
||||||
// PMS
|
// PMS
|
||||||
|
@ -253,9 +271,11 @@ printf("\n");
|
||||||
nout = 0;
|
nout = 0;
|
||||||
for (j=0;j<adjs[i].nadj; j++) if (adjs[i].adj[j] > i) nout++;
|
for (j=0;j<adjs[i].nadj; j++) if (adjs[i].adj[j] > i) nout++;
|
||||||
fwrite(&nout,1,sizeof(int),adj);
|
fwrite(&nout,1,sizeof(int),adj);
|
||||||
for (j=0;j<adjs[i].nadj; j++)
|
for (j=0;j<adjs[i].nadj; j++) {
|
||||||
if (adjs[i].adj[j] > i)
|
int id = adjs[i].adj[j];
|
||||||
|
if (id > i)
|
||||||
fwrite(&(adjs[i].adj[j]),1,sizeof(int),adj);
|
fwrite(&(adjs[i].adj[j]),1,sizeof(int),adj);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(adj);
|
fclose(adj);
|
||||||
|
@ -275,5 +295,10 @@ printf("\n");
|
||||||
|
|
||||||
fclose(vol);
|
fclose(vol);
|
||||||
|
|
||||||
|
free(vols);
|
||||||
|
free(cnt_adj);
|
||||||
|
free(adjs);
|
||||||
|
free(orig);
|
||||||
|
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue