new method for building void tree that avoids re-loading catalog

This commit is contained in:
Paul M. Sutter 2025-04-21 17:30:58 -04:00
parent d9efa15474
commit b9042c5ce7
2 changed files with 67 additions and 7 deletions

View file

@ -469,8 +469,10 @@ int main(int argc, char **argv) {
interval = 1.*(clock4 - clock3)/CLOCKS_PER_SEC;
printf(" Read voids (%.2f sec)...\n", interval);
// load voids *again* using Guilhem's code so we can get tree information
clock3 = clock();
// TODO - TEST NEW TREE BUILDING TECHNIQUE AND REMOVE THIS
/*
// load voids *again* using Guilhem's code so we can get tree information
printf(" Re-loading voids and building tree...\n");
ZobovRep zobovCat;
if (!loadZobov(args.voidDesc_arg, args.zone2Part_arg, args.void2Zone_arg,
@ -481,7 +483,65 @@ int main(int argc, char **argv) {
VoidTree *tree;
tree = new VoidTree(zobovCat);
zobovCat.allZones.erase(zobovCat.allZones.begin(), zobovCat.allZones.end());
*/
// if all of a void's zones also belong to another void,
// it is a child of that void
for (iVoid = 0; iVoid < numVoids; iVoid++) {
voidID = voids[iVoid].voidID;
int numMyZones = voids[iVoid].numZones;
for (int iCheck = 0; iCheck < numVoids; iCheck++) {
int numCheckZones = voids[iCheck].numZones;
if (numMyZones > numCheckZones) continue;
if (iVoid == iCheck) continue;
int checkID = voids[iCheck].voidID;
bool allZonesMatch = true;
for (iZ = 0; iZ < void2Zones[voidID].numZones; iZ++) {
int myZone = void2Zones[voidID].zoneIDs[iZ];
bool foundMatch = false;
for (int jZ = 0; jZ < void2Zones[checkID].numZones; jZ++) {
int checkZone = void2Zones[checkID].zoneIDs[jZ];
foundMatch = myZone == checkZone;
}
if (not foundMatch) {
allZonesMatch = false;
break;
}
}
if (allZonesMatch) {
voids[iVoid].parentID = checkID;
voids[iCheck].numChildren++;
}
}
} // end building tree
// compute level in tree
for (iVoid = 0; iVoid < numVoids; iVoid++) {
int level = 0;
int parentID = voids[iVoid].parentID;
while (parentID != -1) {
level++;
// find the index of the parent
for (i = 0; i < numVoids; i++) {
if (voids[i].voidID == parentID) {
parentID = voids[i].voidID;
break;
}
}
}
voids[iVoid].level = level;
}
// TODO - TEST NEW TREE BUILDING TECHNIQUE AND REMOVE THIS
/*
// copy tree information to our own data structures
for (iVoid = 0; iVoid < numVoids; iVoid++) {
voidID = voids[iVoid].voidID;
@ -497,9 +557,11 @@ int main(int argc, char **argv) {
}
voids[iVoid].level = level;
}
*/
clock4 = clock();
interval = 1.*(clock4 - clock3)/CLOCKS_PER_SEC;
printf(" Re-read voids (%.2f sec)...\n", interval);
printf(" Building void tree (%.2f sec)...\n", interval);
printf(" Computing void properties...\n");
@ -513,9 +575,6 @@ int main(int argc, char **argv) {
// main processing of each void
for (iVoid = 0; iVoid < numVoids; iVoid++) {
voidID = voids[iVoid].voidID;
//printf(" Working on void %d (of %d) %d %d %f\n",iVoid+1, numVoids, voidID,
// voids[iVoid].numPart,
// voids[iVoid].radius);
voids[iVoid].center[0] = part[voids[iVoid].coreParticle].x;
voids[iVoid].center[1] = part[voids[iVoid].coreParticle].y;

View file

@ -21,11 +21,12 @@
import os
from numpy import abs
#import matplotlib as mpl
#mpl.use('Agg')
LIGHT_SPEED = 299792.458
CENTRAL_VOID = 1
EDGE_VOID = 2
class Stack:
zMin = 0.0
zMax = 0.1