mirror of
https://bitbucket.org/cosmicvoids/vide_public.git
synced 2025-07-04 23:31:12 +00:00
Merge branch 'master' of bitbucket.org:cosmicvoids/void_identification
This commit is contained in:
commit
3a15a27955
2 changed files with 58 additions and 40 deletions
|
@ -127,7 +127,6 @@ void writeZoneFile(const std::string& zonfile, PARTICLE* p, pid_t np,
|
||||||
{
|
{
|
||||||
m[h] = new pid_t[z[h].np];
|
m[h] = new pid_t[z[h].np];
|
||||||
nm[h] = 0;
|
nm[h] = 0;
|
||||||
z[h].vol = 0.;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (pid_t i = 0; i < np; i++)
|
for (pid_t i = 0; i < np; i++)
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include <omp.h>
|
#include <omp.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <set>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <boost/format.hpp>
|
#include <boost/format.hpp>
|
||||||
|
@ -37,6 +38,7 @@ void doWatershed(PARTICLE *p, pid_t np, ZONE *z, int numZones, float maxvol, flo
|
||||||
int nhl;
|
int nhl;
|
||||||
int *links = new int[NLINKS];
|
int *links = new int[NLINKS];
|
||||||
bool *done_zones;
|
bool *done_zones;
|
||||||
|
int prev_ii = -1;
|
||||||
|
|
||||||
inyet = new char[numZones];
|
inyet = new char[numZones];
|
||||||
inyet2 = new char[numZones];
|
inyet2 = new char[numZones];
|
||||||
|
@ -49,20 +51,21 @@ void doWatershed(PARTICLE *p, pid_t np, ZONE *z, int numZones, float maxvol, flo
|
||||||
fill(done_zones, done_zones + numZones, false);
|
fill(done_zones, done_zones + numZones, false);
|
||||||
|
|
||||||
nhl = 0;
|
nhl = 0;
|
||||||
#pragma omp for schedule(dynamic,100)
|
#pragma omp for schedule(dynamic,1)
|
||||||
for (int ii = 0; ii < numZones; ii++)
|
for (int h = 0; h < numZones; h++)
|
||||||
{
|
{
|
||||||
int nhlcount = 0;
|
int nhlcount = 0;
|
||||||
int h = iord[ii];
|
|
||||||
float lowvol;
|
float lowvol;
|
||||||
bool beaten;
|
bool beaten;
|
||||||
|
set<int> to_process;
|
||||||
|
|
||||||
for (int hl = 0; hl < nhl; hl++)
|
for (int hl = 0; hl < nhl; hl++)
|
||||||
inyet[zonelist[hl]] = 0;
|
inyet[zonelist[hl]] = 0;
|
||||||
|
|
||||||
zonelist[0] = h;
|
zonelist[0] = h;
|
||||||
inyet[h] = 1;
|
inyet[h] = 1;
|
||||||
nhl = 1;
|
nhl = 1;
|
||||||
|
to_process.insert(h);
|
||||||
z[h].npjoin = z[h].np;
|
z[h].npjoin = z[h].np;
|
||||||
do {
|
do {
|
||||||
/* Find the lowest-volume (highest-density) adjacency */
|
/* Find the lowest-volume (highest-density) adjacency */
|
||||||
|
@ -71,38 +74,45 @@ void doWatershed(PARTICLE *p, pid_t np, ZONE *z, int numZones, float maxvol, flo
|
||||||
beaten = false;
|
beaten = false;
|
||||||
lowvol = BIGFLT;
|
lowvol = BIGFLT;
|
||||||
|
|
||||||
for (int hl = 0; hl < nhl; hl++)
|
set<int>::iterator iter = to_process.begin();
|
||||||
|
while (iter != to_process.end())
|
||||||
{
|
{
|
||||||
int h2 = zonelist[hl];
|
int h2 = *iter;
|
||||||
if (inyet[h2] == 1) { /* If it's not already identified as
|
ZONE& z_cur = z[h2];
|
||||||
an interior zone, with inyet=2 */
|
bool interior = true, touched = false;
|
||||||
bool interior = true;
|
assert(inyet[h2] == 1);
|
||||||
for (int za = 0; za < z[h2].nadj; za++)
|
|
||||||
{
|
for (int za = 0; za < z_cur.nadj; za++)
|
||||||
if (inyet[z[h2].adj[za]] == 0)
|
{
|
||||||
{
|
if (inyet[z_cur.adj[za]] == 0)
|
||||||
interior = false;
|
{
|
||||||
if (z[h2].slv[za] == lowvol)
|
interior = false;
|
||||||
|
if (z_cur.slv[za] == lowvol)
|
||||||
|
{
|
||||||
|
links[nl] = z_cur.adj[za];
|
||||||
|
touched = true;
|
||||||
|
nl ++;
|
||||||
|
if (nl == NLINKS)
|
||||||
|
{
|
||||||
|
printf("Too many links with the same rho_sl! Increase NLINKS from %d\n",nl);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (z_cur.slv[za] < lowvol)
|
||||||
{
|
{
|
||||||
links[nl] = z[h2].adj[za];
|
lowvol = z_cur.slv[za];
|
||||||
nl ++;
|
links[0] = z_cur.adj[za];
|
||||||
if (nl == NLINKS)
|
|
||||||
{
|
|
||||||
printf("Too many links with the same rho_sl! Increase NLINKS from %d\n",nl);
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (z[h2].slv[za] < lowvol)
|
|
||||||
{
|
|
||||||
lowvol = z[h2].slv[za];
|
|
||||||
links[0] = z[h2].adj[za];
|
|
||||||
nl = 1;
|
nl = 1;
|
||||||
|
touched = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (interior)
|
++iter;
|
||||||
inyet[h2] = 2; /* No bordering exter. zones */
|
if (interior || !touched)
|
||||||
}
|
to_process.erase(h2);
|
||||||
|
if (interior)
|
||||||
|
inyet[h2] = 2; /* No bordering exter. zones */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nl == 0)
|
if (nl == 0)
|
||||||
|
@ -157,7 +167,7 @@ void doWatershed(PARTICLE *p, pid_t np, ZONE *z, int numZones, float maxvol, flo
|
||||||
interior = false;
|
interior = false;
|
||||||
if (z[h2].slv[za] <= lowvol) {
|
if (z[h2].slv[za] <= lowvol) {
|
||||||
//if (!done_zones[link2]) { // Equivalent to p[z[link2].core].dens < p[z[h].core].dens)
|
//if (!done_zones[link2]) { // Equivalent to p[z[link2].core].dens < p[z[h].core].dens)
|
||||||
if (p[z[link2].core].dens < p[z[h].core].dens)
|
if (p[z[link2].core].dens < p[z[h].core].dens) {
|
||||||
beaten = true;
|
beaten = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -175,23 +185,32 @@ void doWatershed(PARTICLE *p, pid_t np, ZONE *z, int numZones, float maxvol, flo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int hl = 0; hl < nhl2; hl++)
|
|
||||||
inyet2[zonelist2[hl]] = 0;
|
|
||||||
|
|
||||||
/* See if there's a beater */
|
/* See if there's a beater */
|
||||||
if (beaten) {
|
if (beaten) {
|
||||||
z[h].leak = lowvol;
|
z[h].leak = lowvol;
|
||||||
} else {
|
} else {
|
||||||
for (int h2 = 0; h2 < nhl2; h2++) {
|
for (int h2 = 0; h2 < nhl2; h2++) {
|
||||||
zonelist[nhl] = zonelist2[h2];
|
int new_h = zonelist2[h2];
|
||||||
inyet[zonelist2[h2]] = 1;
|
|
||||||
|
zonelist[nhl] = new_h;
|
||||||
|
assert(inyet[new_h] == 0);
|
||||||
|
inyet[new_h] = 1;
|
||||||
|
if (inyet2[new_h] != 2)
|
||||||
|
to_process.insert(new_h);
|
||||||
nhl++;
|
nhl++;
|
||||||
z[h].npjoin += z[zonelist2[h2]].np;
|
z[h].npjoin += z[new_h].np;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int hl = 0; hl < nhl2; hl++)
|
||||||
|
inyet2[zonelist2[hl]] = 0;
|
||||||
if (nhl/10000 > nhlcount) {
|
if (nhl/10000 > nhlcount) {
|
||||||
|
if (nhlcount == 0)
|
||||||
|
(cout << format("Zone %d: %d") % h % nhl).flush();
|
||||||
|
else
|
||||||
|
(cout << format(" %d [%d]") % nhl % to_process.size()).flush();
|
||||||
nhlcount = nhl/10000;
|
nhlcount = nhl/10000;
|
||||||
printf(" %d",nhl); FF;
|
|
||||||
}
|
}
|
||||||
} while((lowvol < BIGFLT) && (!beaten));
|
} while((lowvol < BIGFLT) && (!beaten));
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue