mirror of
https://bitbucket.org/cosmicvoids/vide_public.git
synced 2025-07-04 15:21:11 +00:00
Allow for a particle duplicate in voztie if and only if the adjacencies are strictly equal.
This commit is contained in:
parent
91a222a3c3
commit
5c40a6c226
1 changed files with 29 additions and 6 deletions
|
@ -2,8 +2,21 @@
|
|||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "voz.h"
|
||||
|
||||
int compare_int(const void *a, const void *b)
|
||||
{
|
||||
const int *ia = (const int *)a;
|
||||
const int *ib = (const int *)b;
|
||||
if ((*ia) < (*ib))
|
||||
return -1;
|
||||
else if ((*ia) > (*ib))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
FILE *part, *adj, *vol;
|
||||
|
@ -135,15 +148,25 @@ int main(int argc, char *argv[]) {
|
|||
fread(&na,1,sizeof(int),part);
|
||||
pid_t pid = orig[p];
|
||||
if (na > 0) {
|
||||
assert(adjs[pid].nadj == 0);// || adjs[pid].nadj == na);
|
||||
adjs[orig[p]].nadj = na;
|
||||
if (adjs[pid].adj == 0)
|
||||
adjs[orig[p]].adj = (pid_t *)malloc(na*sizeof(pid_t));
|
||||
if (adjs[orig[p]].adj == 0) {
|
||||
pid_t *previous_adj = adjs[pid].adj;
|
||||
assert(adjs[pid].nadj == 0 || adjs[pid].nadj == na);
|
||||
adjs[pid].nadj = na;
|
||||
adjs[pid].adj = (pid_t *)malloc(na*sizeof(pid_t));
|
||||
if (adjs[pid].adj == 0) {
|
||||
printf("Couldn't allocate adjs[orig[%d]].adj.\n",p);
|
||||
exit(0);
|
||||
}
|
||||
fread(adjs[orig[p]].adj,na,sizeof(pid_t),part);
|
||||
fread(adjs[pid].adj,na,sizeof(pid_t),part);
|
||||
if (previous_adj != 0)
|
||||
{
|
||||
qsort(previous_adj, na, sizeof(pid_t), compare_int);
|
||||
qsort(adjs[pid].adj, na, sizeof(pid_t), compare_int);
|
||||
if (memcmp(previous_adj, adjs[pid].adj, sizeof(pid_t)*na) != 0)
|
||||
{
|
||||
printf("Inconsistent adjacencies between two divisions.\n");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
printf("0"); fflush(stdout);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue