enbid-ananke 0.3.1__py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- enbid_ananke/Enbid-2.0/.DS_Store +0 -0
- enbid_ananke/Enbid-2.0/COPYING +341 -0
- enbid_ananke/Enbid-2.0/COPYRIGHT +18 -0
- enbid_ananke/Enbid-2.0/Documentation/enbid.pdf +0 -0
- enbid_ananke/Enbid-2.0/Documentation/users-guide.pdf +0 -0
- enbid_ananke/Enbid-2.0/Documentation/users-guide.tex +679 -0
- enbid_ananke/Enbid-2.0/Documentation/users-guide.tex.flc +4 -0
- enbid_ananke/Enbid-2.0/Enbid +0 -0
- enbid_ananke/Enbid-2.0/Examples/hernquist1_small/snapshot_ici +0 -0
- enbid_ananke/Enbid-2.0/Examples/hernquist1_small/snapshot_ici_typelist +2 -0
- enbid_ananke/Enbid-2.0/Examples/uniform_6d_box_4/snapshot_ici +0 -0
- enbid_ananke/Enbid-2.0/Examples/uniform_6d_box_4/snapshot_ici_3d.ascii +10000 -0
- enbid_ananke/Enbid-2.0/Examples/uniform_6d_box_4/snapshot_ici_6d.ascii +10000 -0
- enbid_ananke/Enbid-2.0/parameterfiles/myparameterfile1 +37 -0
- enbid_ananke/Enbid-2.0/parameterfiles/myparameterfile2 +37 -0
- enbid_ananke/Enbid-2.0/parameterfiles/myparameterfile3 +37 -0
- enbid_ananke/Enbid-2.0/parameterfiles/myparameterfile4 +37 -0
- enbid_ananke/Enbid-2.0/periodic_lengths.txt +5 -0
- enbid_ananke/Enbid-2.0/src/Makefile +43 -0
- enbid_ananke/Enbid-2.0/src/allocate.cpp +47 -0
- enbid_ananke/Enbid-2.0/src/allocate.o +0 -0
- enbid_ananke/Enbid-2.0/src/allvars.cpp +62 -0
- enbid_ananke/Enbid-2.0/src/allvars.h +263 -0
- enbid_ananke/Enbid-2.0/src/allvars.o +0 -0
- enbid_ananke/Enbid-2.0/src/begrun.cpp +361 -0
- enbid_ananke/Enbid-2.0/src/begrun.o +0 -0
- enbid_ananke/Enbid-2.0/src/density_nd.cpp +130 -0
- enbid_ananke/Enbid-2.0/src/density_nd.o +0 -0
- enbid_ananke/Enbid-2.0/src/functions.cpp +256 -0
- enbid_ananke/Enbid-2.0/src/functions.h +20 -0
- enbid_ananke/Enbid-2.0/src/functions.o +0 -0
- enbid_ananke/Enbid-2.0/src/init.cpp +299 -0
- enbid_ananke/Enbid-2.0/src/init.o +0 -0
- enbid_ananke/Enbid-2.0/src/io.cpp +255 -0
- enbid_ananke/Enbid-2.0/src/io.o +0 -0
- enbid_ananke/Enbid-2.0/src/main.cpp +108 -0
- enbid_ananke/Enbid-2.0/src/main.o +0 -0
- enbid_ananke/Enbid-2.0/src/ngb_search.cpp +2315 -0
- enbid_ananke/Enbid-2.0/src/ngb_search.h +35 -0
- enbid_ananke/Enbid-2.0/src/ngb_search.o +0 -0
- enbid_ananke/Enbid-2.0/src/nr.cpp +186 -0
- enbid_ananke/Enbid-2.0/src/nr.h +13 -0
- enbid_ananke/Enbid-2.0/src/nr.o +0 -0
- enbid_ananke/Enbid-2.0/src/proto.h +22 -0
- enbid_ananke/Enbid-2.0/src/read_ic.cpp +434 -0
- enbid_ananke/Enbid-2.0/src/read_ic.o +0 -0
- enbid_ananke/Enbid-2.0/src/tree.cpp +973 -0
- enbid_ananke/Enbid-2.0/src/tree.h +34 -0
- enbid_ananke/Enbid-2.0/src/tree.o +0 -0
- enbid_ananke/Enbid-2.0/src/tree_search.cpp +597 -0
- enbid_ananke/Enbid-2.0/src/tree_search.o +0 -0
- enbid_ananke/__init__.py +318 -0
- enbid_ananke/__license__/LICENSE +339 -0
- enbid_ananke/__license__/__init__.py +9 -0
- enbid_ananke/__metadata__.py +160 -0
- enbid_ananke/_builtin_utils.py +62 -0
- enbid_ananke/_constants.py +56 -0
- enbid_ananke/_defaults.py +36 -0
- enbid_ananke/_name.py +10 -0
- enbid_ananke/_templates.py +71 -0
- enbid_ananke/_version.py +21 -0
- enbid_ananke/utils.py +11 -0
- enbid_ananke-0.3.1.dist-info/LICENSE +339 -0
- enbid_ananke-0.3.1.dist-info/METADATA +33 -0
- enbid_ananke-0.3.1.dist-info/RECORD +67 -0
- enbid_ananke-0.3.1.dist-info/WHEEL +7 -0
- enbid_ananke-0.3.1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,34 @@
|
|
1
|
+
/***************************************************************************
|
2
|
+
tree.h - description
|
3
|
+
-------------------
|
4
|
+
begin : Mon Jan 16 2006
|
5
|
+
copyright : (C) 2006 by Sanjib Sharma
|
6
|
+
email : sharma@wesleyan.edu
|
7
|
+
***************************************************************************/
|
8
|
+
|
9
|
+
/***************************************************************************
|
10
|
+
* *
|
11
|
+
* This program is free software; you can redistribute it and/or modify *
|
12
|
+
* it under the terms of the GNU General Public License as published by *
|
13
|
+
* the Free Software Foundation; either version 2 of the License, or *
|
14
|
+
* (at your option) any later version. *
|
15
|
+
* *
|
16
|
+
***************************************************************************/
|
17
|
+
// tree building routines
|
18
|
+
void treeallocate(int maxpart);
|
19
|
+
void treefree(void);
|
20
|
+
int treebuild_all(void);
|
21
|
+
int treebuild_single(int startnode, vector<int> &npart, int type,int *creatednodes);
|
22
|
+
void treebuild(int);
|
23
|
+
void treeprint(int no);
|
24
|
+
void sort2(unsigned long n, float arr[], int brr[]);
|
25
|
+
//* search in a box routines
|
26
|
+
void ngb_treesearch_kdts(int no);
|
27
|
+
void ngb_treesearch_kdts_vc(int no);
|
28
|
+
void ngb_treesearch_kdts_h(int no);
|
29
|
+
float ngb_treedensity_fiestas(float xyz[ND], struct NODE* nodes1);
|
30
|
+
float ngb_treedensity_raw(float xyz[ND], struct NODE* nodes1);
|
31
|
+
void ngb_calculate_metric(float xyz[ND], struct NODE* nodes1);
|
32
|
+
|
33
|
+
|
34
|
+
|
Binary file
|
@@ -0,0 +1,597 @@
|
|
1
|
+
/***************************************************************************
|
2
|
+
tree_search.cpp - description
|
3
|
+
-------------------
|
4
|
+
begin : Mon Jan 16 2006
|
5
|
+
copyright : (C) 2006 by Sanjib Sharma
|
6
|
+
email : ssharma@aip.de
|
7
|
+
***************************************************************************/
|
8
|
+
|
9
|
+
/***************************************************************************
|
10
|
+
* *
|
11
|
+
* This program is free software; you can redistribute it and/or modify *
|
12
|
+
* it under the terms of the GNU General Public License as published by *
|
13
|
+
* the Free Software Foundation; either version 2 of the License, or *
|
14
|
+
* (at your option) any later version. *
|
15
|
+
* *
|
16
|
+
***************************************************************************/
|
17
|
+
#include <stdio.h>
|
18
|
+
#include <stdlib.h>
|
19
|
+
#include <string.h>
|
20
|
+
#include <math.h>
|
21
|
+
#include "allvars.h"
|
22
|
+
//#include "proto.h"
|
23
|
+
#include "nr.h"
|
24
|
+
#include "tree.h"
|
25
|
+
#include "functions.h"
|
26
|
+
|
27
|
+
static real msmooth,vsmooth;
|
28
|
+
|
29
|
+
|
30
|
+
// **************************************
|
31
|
+
// * Below we have the routines *
|
32
|
+
// * dealing with neighbour finding. *
|
33
|
+
// **************************************
|
34
|
+
|
35
|
+
|
36
|
+
// This routine maps a coordinate difference
|
37
|
+
// to the nearest periodic image
|
38
|
+
//
|
39
|
+
void ngb_calculate_metric(float xyz[ND], struct NODE* nodes1)
|
40
|
+
{
|
41
|
+
real sr[ND],fac=1.2,mp1; /* search radius */
|
42
|
+
int th=0,j,it=0;
|
43
|
+
|
44
|
+
nodesC=nodes1;
|
45
|
+
mp1=1;
|
46
|
+
if(searchcenter[0]==0.0)
|
47
|
+
{
|
48
|
+
th=1;
|
49
|
+
while(nodes1[th].count>1)
|
50
|
+
{
|
51
|
+
j=nodes1[th].k1;
|
52
|
+
if(xyz[j] < nodes1[LOWER(th,nodes1)].bnd->x[j][1])
|
53
|
+
th=LOWER(th,nodes1);
|
54
|
+
else
|
55
|
+
th=UPPER(th,nodes1);
|
56
|
+
}
|
57
|
+
|
58
|
+
for(j=0; j<ND; j++)
|
59
|
+
{
|
60
|
+
sr[j]=real(nodes1[th].bnd->x[j][1]-nodes1[th].bnd->x[j][0])*0.5;
|
61
|
+
searchcenter[j]=sr[j];
|
62
|
+
}
|
63
|
+
|
64
|
+
}
|
65
|
+
else
|
66
|
+
for(j=0; j<ND; j++)
|
67
|
+
{
|
68
|
+
sr[j]=searchcenter[j];
|
69
|
+
searchcenter[j]=0.0;
|
70
|
+
}
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
// temp=(mp1+mp2)*0.5;
|
75
|
+
for(j=0; j<ND; j++)
|
76
|
+
{
|
77
|
+
sr[j]=fac*sr[j]*0.5;
|
78
|
+
// sr[j]*=All.SearchFactor*0.5*pow(temp,1.0/ND);
|
79
|
+
searchx[j][0]=xyz[j];
|
80
|
+
searchx[j][1]=xyz[j];
|
81
|
+
}
|
82
|
+
// cout<<th<<" a "<<msmooth<<" "<<mp1<<" "<<" "<<sr[0]<<endl;
|
83
|
+
msmooth=0.0; vsmooth=0.0;
|
84
|
+
// msmooth=2;
|
85
|
+
while(msmooth<mp1)
|
86
|
+
{
|
87
|
+
msmooth=0.0; vsmooth=0.0;
|
88
|
+
for(j=0; j<ND; j++)
|
89
|
+
{
|
90
|
+
sr[j]*=2;
|
91
|
+
searchx[j][0]=xyz[j]-sr[j];
|
92
|
+
searchx[j][1]=xyz[j]+sr[j];
|
93
|
+
searchcenter[j]=0.0;
|
94
|
+
}
|
95
|
+
|
96
|
+
ngb_treesearch_kdts_h(1);
|
97
|
+
|
98
|
+
// if(msmooth<0.1)
|
99
|
+
// {
|
100
|
+
// msmooth=mp1;
|
101
|
+
// for(j=0; j<ND; j++)
|
102
|
+
// searchcenter[j]=1.0;
|
103
|
+
// endrun(10);
|
104
|
+
// }
|
105
|
+
// else
|
106
|
+
if(msmooth>mp1)
|
107
|
+
{
|
108
|
+
for(j=0; j<ND; j++)
|
109
|
+
{
|
110
|
+
searchcenter[j]/=vsmooth;
|
111
|
+
}
|
112
|
+
|
113
|
+
|
114
|
+
}
|
115
|
+
it++;
|
116
|
+
if(it>100)
|
117
|
+
{
|
118
|
+
cout<<it<<" too many iterations ngb_calculate _metric"<<msmooth<<endl;
|
119
|
+
for(j=0;j<ND;j++)
|
120
|
+
cout<<xyz[j]<<" "<<sr[j]<<endl;
|
121
|
+
endrun(2);
|
122
|
+
}
|
123
|
+
if(it>20)
|
124
|
+
cout<<th<<" a "<<msmooth<<" "<<mp1<<" "<<xyz[0]<<" "<<sr[0]<<endl;
|
125
|
+
|
126
|
+
// cout<<th<<" a "<<msmooth<<" "<<mp1<<" "<<xyz[0]<<" "<<sr[0]<<endl;
|
127
|
+
|
128
|
+
}
|
129
|
+
|
130
|
+
}
|
131
|
+
|
132
|
+
// Fiestas style density calculation. Calculate a search box
|
133
|
+
//enclosing a given mass and then calculate density
|
134
|
+
|
135
|
+
float ngb_treedensity_fiestas(float xyz[ND], struct NODE* nodes1)
|
136
|
+
{
|
137
|
+
double temp,temp1;
|
138
|
+
real sr[ND],fac=1.0; /* search radius */
|
139
|
+
int th=0,it,j;
|
140
|
+
double mp1,mp2,mass_unit;
|
141
|
+
|
142
|
+
// cout<<xyz[0]<<endl;
|
143
|
+
mp1=All.DesNumNgb*0.99;
|
144
|
+
mp2=All.DesNumNgb*1.01;
|
145
|
+
|
146
|
+
|
147
|
+
// cout<<list_kd[nodes1[1].lid]<<endl;
|
148
|
+
mass_unit=Part[list_kd[nodes1[1].lid]].Mass;
|
149
|
+
|
150
|
+
|
151
|
+
|
152
|
+
// nodes1=nodes+(parttype-1);
|
153
|
+
nodesC=nodes1;
|
154
|
+
|
155
|
+
if(All.CubicCells==1)
|
156
|
+
{
|
157
|
+
th=1;
|
158
|
+
while(nodes1[th].count>1)
|
159
|
+
{
|
160
|
+
j=nodes1[th].k1;
|
161
|
+
if(xyz[j] < nodes1[LOWER(th,nodes1)].bnd->x[j][1])
|
162
|
+
th=LOWER(th,nodes1);
|
163
|
+
else
|
164
|
+
th=UPPER(th,nodes1);
|
165
|
+
|
166
|
+
}
|
167
|
+
|
168
|
+
for(j=0; j<ND; j++)
|
169
|
+
{
|
170
|
+
sr[j]=(nodes1[th].bnd->x[j][1]-nodes1[th].bnd->x[j][0])*0.1*pow(double(All.DesNumNgb*1.0/nodes1[th].count),1.0/ ND);
|
171
|
+
}
|
172
|
+
|
173
|
+
|
174
|
+
for(j=0,temp=1.0; j<3; j++)
|
175
|
+
temp*=(sr[j]);
|
176
|
+
temp=pow(temp,0.3333);
|
177
|
+
for(j=0; j<3; j++)
|
178
|
+
sr[j]=temp;
|
179
|
+
|
180
|
+
if(ND>3)
|
181
|
+
{
|
182
|
+
for(j=3,temp=1.0; j<6; j++)
|
183
|
+
temp*=(sr[j]);
|
184
|
+
temp=pow(temp,0.3333);
|
185
|
+
for(j=3; j<6; j++)
|
186
|
+
sr[j]=temp;
|
187
|
+
}
|
188
|
+
}
|
189
|
+
else
|
190
|
+
{
|
191
|
+
for(j=0; j<ND; j++)
|
192
|
+
searchcenter[j]=0.0;
|
193
|
+
|
194
|
+
ngb_calculate_metric(xyz,nodes1);
|
195
|
+
for(j=0; j<ND; j++)
|
196
|
+
{
|
197
|
+
sr[j]=searchcenter[j]*0.1*pow(double(All.DesNumNgb*1.0/1.0),1.0/ ND);
|
198
|
+
}
|
199
|
+
|
200
|
+
}
|
201
|
+
|
202
|
+
|
203
|
+
// temp=(mp1+mp2)*0.5;
|
204
|
+
for(j=0; j<ND; j++)
|
205
|
+
{
|
206
|
+
sr[j]=fac*sr[j]/2.0;
|
207
|
+
// sr[j]*=All.SearchFactor*0.5*pow(temp,1.0/ND);
|
208
|
+
searchx[j][0]=xyz[j];
|
209
|
+
searchx[j][1]=xyz[j];
|
210
|
+
}
|
211
|
+
// cout<<th<<" a "<<msmooth<<" "<<mp1<<" "<<mp2<<" "<<msmooth<<endl;
|
212
|
+
it=0;
|
213
|
+
msmooth=0.0;
|
214
|
+
vsmooth=0.0;
|
215
|
+
while(msmooth<mp1)
|
216
|
+
{
|
217
|
+
// cout<<th<<" b "<<msmooth<<" "<<mp1<<" "<<mp2<<" "<<sr[0]<<" "<<par<<endl;
|
218
|
+
it++;
|
219
|
+
if(it > 100)
|
220
|
+
{
|
221
|
+
cout<<"Too many iterations check smoothing"<<endl;
|
222
|
+
cout<<th<<" "<<msmooth<<" "<<mp1<<" "<<mp2<<" "<<endl;
|
223
|
+
endrun(10);
|
224
|
+
}
|
225
|
+
msmooth=0.0;
|
226
|
+
vsmooth=0.0;
|
227
|
+
for(j=0; j<ND; j++)
|
228
|
+
{
|
229
|
+
sr[j]*=2;
|
230
|
+
searchx[j][0]=xyz[j]-sr[j];
|
231
|
+
searchx[j][1]=xyz[j]+sr[j];
|
232
|
+
}
|
233
|
+
|
234
|
+
if(All.VolCorr==1)
|
235
|
+
ngb_treesearch_kdts_vc(1);
|
236
|
+
else
|
237
|
+
ngb_treesearch_kdts(1);
|
238
|
+
|
239
|
+
if((it==1)&&(msmooth>mp1))
|
240
|
+
{
|
241
|
+
for(j=0; j<ND; j++)
|
242
|
+
sr[j]/=4; // actually this halfs the box length since it was already doubled earlier
|
243
|
+
it=0; msmooth=0.0;
|
244
|
+
// cout<<th<<endl;
|
245
|
+
}
|
246
|
+
|
247
|
+
}
|
248
|
+
|
249
|
+
for(j=0; j<ND; j++)
|
250
|
+
sr[j]=sr[j]*0.5;
|
251
|
+
// cout<<th<<" c "<<msmooth<<" "<<mp1<<" "<<mp2<<" "<<msmooth<<endl;
|
252
|
+
|
253
|
+
it=0;
|
254
|
+
while((msmooth<mp1)||(msmooth>mp2))
|
255
|
+
{
|
256
|
+
// cout<<th<<" d "<<trees[parttype]<<" "<<sr[0]<<" "<<mp1<<" "<<mp2<<" "<<msmooth<<endl;
|
257
|
+
|
258
|
+
it++;
|
259
|
+
if(it > 100)
|
260
|
+
{
|
261
|
+
cout<<"Too many iterations check smoothing"<<endl;
|
262
|
+
cout<<th<<" "<<msmooth<<" "<<mp1<<" "<<mp2<<" "<<endl;
|
263
|
+
endrun(10);
|
264
|
+
}
|
265
|
+
|
266
|
+
if(msmooth>mp2)
|
267
|
+
for(j=0; j<ND; j++)
|
268
|
+
{
|
269
|
+
sr[j]=sr[j]*0.5;
|
270
|
+
searchx[j][0]+=sr[j];
|
271
|
+
searchx[j][1]-=sr[j];
|
272
|
+
}
|
273
|
+
if(msmooth<mp1)
|
274
|
+
for(j=0; j<ND; j++)
|
275
|
+
{
|
276
|
+
sr[j]=sr[j]*0.5;
|
277
|
+
searchx[j][0]-=sr[j];
|
278
|
+
searchx[j][1]+=sr[j];
|
279
|
+
}
|
280
|
+
msmooth=0.0;
|
281
|
+
vsmooth=0.0;
|
282
|
+
|
283
|
+
if(All.VolCorr==1)
|
284
|
+
ngb_treesearch_kdts_vc(1);
|
285
|
+
else
|
286
|
+
ngb_treesearch_kdts(1);
|
287
|
+
|
288
|
+
}
|
289
|
+
|
290
|
+
|
291
|
+
|
292
|
+
for(j=0,temp=1.0; j<ND; j++)
|
293
|
+
temp*=(searchx[j][1]-searchx[j][0]);
|
294
|
+
|
295
|
+
if(All.CubicCells==1) temp1=0.5; else temp1=0.9; //0.2 0.5
|
296
|
+
|
297
|
+
if(All.VolCorr==1)
|
298
|
+
{
|
299
|
+
if (vsmooth/temp <temp1)
|
300
|
+
return (msmooth*mass_unit/vsmooth);
|
301
|
+
else
|
302
|
+
return (msmooth*mass_unit/temp);
|
303
|
+
}
|
304
|
+
else
|
305
|
+
return (msmooth*mass_unit/temp);
|
306
|
+
|
307
|
+
}
|
308
|
+
|
309
|
+
|
310
|
+
float ngb_treedensity_raw(float xyz[ND], struct NODE* nodes1)
|
311
|
+
{
|
312
|
+
double temp;
|
313
|
+
int th,j;
|
314
|
+
// nodes1=nodes+parttype-1;
|
315
|
+
th=1;
|
316
|
+
while(nodes1[th].count>1)
|
317
|
+
{
|
318
|
+
j=nodes1[th].k1;
|
319
|
+
if(xyz[j] < nodes1[LOWER(th,nodes1)].bnd->x[j][1])
|
320
|
+
th=LOWER(th,nodes1);
|
321
|
+
else
|
322
|
+
th=UPPER(th,nodes1);
|
323
|
+
}
|
324
|
+
|
325
|
+
for(j=0,temp=1.0; j<ND; j++)
|
326
|
+
{
|
327
|
+
temp*=real(nodes1[th].bnd->x[j][1]-nodes1[th].bnd->x[j][0]);
|
328
|
+
}
|
329
|
+
|
330
|
+
return Part[list_kd[nodes1[th].lid]].Mass/temp;
|
331
|
+
|
332
|
+
}
|
333
|
+
|
334
|
+
|
335
|
+
// Search kd tree to find particles in a given box
|
336
|
+
void ngb_treesearch_kdts(int no)
|
337
|
+
{
|
338
|
+
int k,l;
|
339
|
+
real kvol=1.0,temp1,temp2,temp3,temp4;
|
340
|
+
struct NODE *nfreep;
|
341
|
+
struct PNODE *pnfreep;
|
342
|
+
// struct XNODE *pnfreep;
|
343
|
+
|
344
|
+
nfreep= &nodesC[no];
|
345
|
+
|
346
|
+
if(nfreep->count > 1)
|
347
|
+
{
|
348
|
+
k=nfreep->k1;
|
349
|
+
temp1=nfreep->kcut;
|
350
|
+
l=LOWER(no,nodesC);
|
351
|
+
if(temp1>searchx[k][0])
|
352
|
+
ngb_treesearch_kdts(l);
|
353
|
+
l=UPPER(no,nodesC);
|
354
|
+
if(temp1<searchx[k][1])
|
355
|
+
ngb_treesearch_kdts(l);
|
356
|
+
}
|
357
|
+
else
|
358
|
+
{
|
359
|
+
pnfreep= &pnodes[nfreep->k1];
|
360
|
+
// pnfreep=nodesC[no].bnd;
|
361
|
+
// pnfreep= &xnodes[no];
|
362
|
+
for(k=0; k<ND; k++)
|
363
|
+
{
|
364
|
+
temp1=searchx[k][0]; temp2=searchx[k][1];
|
365
|
+
temp3=pnfreep->x[k][0]; temp4=pnfreep->x[k][1];
|
366
|
+
if(temp3>temp1) temp1=temp3;
|
367
|
+
if(temp4<temp2) temp2=temp4;
|
368
|
+
if(temp2<=temp1) return;
|
369
|
+
else
|
370
|
+
{
|
371
|
+
kvol*=(temp2-temp1)/(temp4-temp3);
|
372
|
+
}
|
373
|
+
}
|
374
|
+
msmooth+=kvol;
|
375
|
+
}
|
376
|
+
|
377
|
+
return;
|
378
|
+
|
379
|
+
}
|
380
|
+
|
381
|
+
|
382
|
+
// Search kd tree to find particles in a given box along with volume calculation
|
383
|
+
void ngb_treesearch_kdts_vc(int no)
|
384
|
+
{
|
385
|
+
int k,l;
|
386
|
+
real kvol=1.0,temp1,temp2,temp3,temp4;
|
387
|
+
real kvol1=1.0;
|
388
|
+
struct NODE *nfreep;
|
389
|
+
struct PNODE *pnfreep;
|
390
|
+
// struct XNODE *pnfreep;
|
391
|
+
nfreep= &nodesC[no];
|
392
|
+
|
393
|
+
if(nfreep->count > 1)
|
394
|
+
{
|
395
|
+
k=nfreep->k1;
|
396
|
+
temp1=nfreep->kcut;
|
397
|
+
l=LOWER(no,nodesC);
|
398
|
+
if(temp1>searchx[k][0])
|
399
|
+
ngb_treesearch_kdts_vc(l);
|
400
|
+
l=UPPER(no,nodesC);
|
401
|
+
if(temp1<searchx[k][1])
|
402
|
+
ngb_treesearch_kdts_vc(l);
|
403
|
+
}
|
404
|
+
else
|
405
|
+
{
|
406
|
+
pnfreep= &pnodes[nfreep->k1];
|
407
|
+
// pnfreep=nodesC[no].bnd;
|
408
|
+
// pnfreep= &xnodes[no];
|
409
|
+
for(k=0; k<ND; k++)
|
410
|
+
{
|
411
|
+
temp1=searchx[k][0]; temp2=searchx[k][1];
|
412
|
+
temp3=pnfreep->x[k][0]; temp4=pnfreep->x[k][1];
|
413
|
+
if(temp3>temp1) temp1=temp3;
|
414
|
+
if(temp4<temp2) temp2=temp4;
|
415
|
+
if(temp2<=temp1) return;
|
416
|
+
else
|
417
|
+
{
|
418
|
+
kvol*=(temp2-temp1)/(temp4-temp3);
|
419
|
+
kvol1*=(temp2-temp1);
|
420
|
+
}
|
421
|
+
}
|
422
|
+
|
423
|
+
msmooth+=kvol;
|
424
|
+
vsmooth+=kvol1;
|
425
|
+
}
|
426
|
+
return;
|
427
|
+
}
|
428
|
+
|
429
|
+
|
430
|
+
|
431
|
+
void ngb_treesearch_kdts_h(int no)
|
432
|
+
{
|
433
|
+
int k,l;
|
434
|
+
real temp1,temp2,temp3,temp4,kvol=1.0;
|
435
|
+
struct NODE *nfreep;
|
436
|
+
// struct PNODE *pnfreep;
|
437
|
+
struct XNODE *pnfreep;
|
438
|
+
|
439
|
+
|
440
|
+
nfreep= &nodesC[no];
|
441
|
+
|
442
|
+
if(nfreep->count > 1)
|
443
|
+
{
|
444
|
+
k=nfreep->k1;
|
445
|
+
temp1=nfreep->kcut;
|
446
|
+
|
447
|
+
l=LOWER(no,nodesC);
|
448
|
+
if(temp1>searchx[k][0])
|
449
|
+
ngb_treesearch_kdts_h(l);
|
450
|
+
l=UPPER(no,nodesC);
|
451
|
+
if(temp1<searchx[k][1])
|
452
|
+
ngb_treesearch_kdts_h(l);
|
453
|
+
}
|
454
|
+
else
|
455
|
+
{
|
456
|
+
// pnfreep= &pnodes[nfreep->k1];
|
457
|
+
pnfreep=nodesC[no].bnd;
|
458
|
+
// pnfreep= &xnodes[no];
|
459
|
+
for(k=0; k<ND; k++)
|
460
|
+
{
|
461
|
+
temp1=searchx[k][0]; temp2=searchx[k][1];
|
462
|
+
temp3=pnfreep->x[k][0]; temp4=pnfreep->x[k][1];
|
463
|
+
if(temp3>temp1) temp1=temp3;
|
464
|
+
if(temp4<temp2) temp2=temp4;
|
465
|
+
if(temp2<=temp1) return;
|
466
|
+
else
|
467
|
+
{
|
468
|
+
kvol*=(temp2-temp1)/(temp4-temp3);
|
469
|
+
// kvol1*=(temp2-temp1);
|
470
|
+
}
|
471
|
+
}
|
472
|
+
|
473
|
+
for(k=0; k<ND; k++)
|
474
|
+
{
|
475
|
+
temp3=pnfreep->x[k][0]; temp4=pnfreep->x[k][1];
|
476
|
+
searchcenter[k]+=((temp4-temp3));
|
477
|
+
// cout<<k<<" "<<searchcenter[k]<<endl;
|
478
|
+
}
|
479
|
+
msmooth+=kvol;
|
480
|
+
vsmooth=vsmooth+1.0;
|
481
|
+
}
|
482
|
+
return;
|
483
|
+
}
|
484
|
+
|
485
|
+
|
486
|
+
|
487
|
+
void treeprint(int no)
|
488
|
+
{
|
489
|
+
int k,l;
|
490
|
+
// real kvol=1.0,temp1,temp2,temp3,temp4;
|
491
|
+
struct NODE *nfreep;
|
492
|
+
// struct PNODE *pnfreep;
|
493
|
+
struct SNODE *snfreep;
|
494
|
+
struct XNODE *xnfreep;
|
495
|
+
|
496
|
+
nfreep= &nodes[no];
|
497
|
+
xnfreep= &xnodes[no];
|
498
|
+
snfreep= &snodes[no];
|
499
|
+
fprintf(treefile_fpt," %d %e %d %d\n",nfreep->k1,nfreep->kcut,nfreep->count,snfreep->lid);
|
500
|
+
for(k=0;k<ND;k++)
|
501
|
+
fprintf(treefile_fpt," %e %e\n",xnfreep->x[k][0],xnfreep->x[k][1]);
|
502
|
+
|
503
|
+
if(nfreep->count > 1)
|
504
|
+
{
|
505
|
+
l=LOWER(no,nodesC);
|
506
|
+
treeprint(l);
|
507
|
+
l=UPPER(no,nodesC);
|
508
|
+
treeprint(l);
|
509
|
+
}
|
510
|
+
return;
|
511
|
+
}
|
512
|
+
|
513
|
+
|
514
|
+
|
515
|
+
|
516
|
+
#define SWAP(a,b) temp=(a);(a)=(b);(b)=temp;
|
517
|
+
#define SWAPI(a,b) tempi=(a);(a)=(b);(b)=tempi;
|
518
|
+
#define M 7
|
519
|
+
#define NSTACK 50
|
520
|
+
void sort2(unsigned long n, float arr[], int brr[])
|
521
|
+
{
|
522
|
+
unsigned long i,ir=n,j,k,l=1;
|
523
|
+
int *istack,jstack=0;
|
524
|
+
float a,temp;
|
525
|
+
int b,tempi;
|
526
|
+
istack=ivector(1,NSTACK);
|
527
|
+
for (;;) {
|
528
|
+
if (ir-l < M) {
|
529
|
+
for (j=l+1;j<=ir;j++) {
|
530
|
+
a=arr[j];
|
531
|
+
b=brr[j];
|
532
|
+
for (i=j-1;i>=l;i--) {
|
533
|
+
if (arr[i] <= a) break;
|
534
|
+
arr[i+1]=arr[i];
|
535
|
+
brr[i+1]=brr[i];
|
536
|
+
}
|
537
|
+
arr[i+1]=a;
|
538
|
+
brr[i+1]=b;
|
539
|
+
}
|
540
|
+
if (!jstack) {
|
541
|
+
free_ivector(istack,1,NSTACK);
|
542
|
+
return;
|
543
|
+
}
|
544
|
+
ir=istack[jstack];
|
545
|
+
l=istack[jstack-1];
|
546
|
+
jstack -= 2;
|
547
|
+
} else {
|
548
|
+
k=(l+ir) >> 1;
|
549
|
+
SWAP(arr[k],arr[l+1])
|
550
|
+
SWAPI(brr[k],brr[l+1])
|
551
|
+
if (arr[l] > arr[ir]) {
|
552
|
+
SWAP(arr[l],arr[ir])
|
553
|
+
SWAPI(brr[l],brr[ir])
|
554
|
+
}
|
555
|
+
if (arr[l+1] > arr[ir]) {
|
556
|
+
SWAP(arr[l+1],arr[ir])
|
557
|
+
SWAPI(brr[l+1],brr[ir])
|
558
|
+
}
|
559
|
+
if (arr[l] > arr[l+1]) {
|
560
|
+
SWAP(arr[l],arr[l+1])
|
561
|
+
SWAPI(brr[l],brr[l+1])
|
562
|
+
}
|
563
|
+
i=l+1;
|
564
|
+
j=ir;
|
565
|
+
a=arr[l+1];
|
566
|
+
b=brr[l+1];
|
567
|
+
for (;;) {
|
568
|
+
do i++; while (arr[i] < a);
|
569
|
+
do j--; while (arr[j] > a);
|
570
|
+
if (j < i) break;
|
571
|
+
SWAP(arr[i],arr[j])
|
572
|
+
SWAPI(brr[i],brr[j])
|
573
|
+
}
|
574
|
+
arr[l+1]=arr[j];
|
575
|
+
arr[j]=a;
|
576
|
+
brr[l+1]=brr[j];
|
577
|
+
brr[j]=b;
|
578
|
+
jstack += 2;
|
579
|
+
if (jstack > NSTACK) nrerror("NSTACK too small in sort2.");
|
580
|
+
if (ir-i+1 >= j-l) {
|
581
|
+
istack[jstack]=ir;
|
582
|
+
istack[jstack-1]=i;
|
583
|
+
ir=j-1;
|
584
|
+
} else {
|
585
|
+
istack[jstack]=j-1;
|
586
|
+
istack[jstack-1]=l;
|
587
|
+
l=i;
|
588
|
+
}
|
589
|
+
}
|
590
|
+
}
|
591
|
+
}
|
592
|
+
#undef M
|
593
|
+
#undef NSTACK
|
594
|
+
#undef SWAP
|
595
|
+
#undef SWAPI
|
596
|
+
|
597
|
+
|
Binary file
|