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,256 @@
|
|
1
|
+
#include <stdio.h>
|
2
|
+
#include <stdlib.h>
|
3
|
+
#include <string>
|
4
|
+
#include <math.h>
|
5
|
+
#include "allvars.h"
|
6
|
+
#include "proto.h"
|
7
|
+
#include "functions.h"
|
8
|
+
#include "nr.h"
|
9
|
+
#include "tree.h"
|
10
|
+
|
11
|
+
|
12
|
+
/* this function wraps the distance x to the closest image
|
13
|
+
* for the given box size
|
14
|
+
*/
|
15
|
+
|
16
|
+
/* matrix multiplication of two matrices C=AB*/
|
17
|
+
void m_multiply(float **a, float **b,float **c,int n1, int n2,int transpose)
|
18
|
+
{
|
19
|
+
int i,j,k;
|
20
|
+
|
21
|
+
for (i=n1;i<=n2;i++)
|
22
|
+
for (j=n1;j<=n2;j++)
|
23
|
+
for (k=n1,c[i][j]=0.0;k<=n2;k++)
|
24
|
+
{
|
25
|
+
switch(transpose)
|
26
|
+
{
|
27
|
+
case 0: c[i][j]+=a[i][k]*b[k][j]; break;
|
28
|
+
case 1: c[i][j]+=a[k][i]*b[k][j]; break;
|
29
|
+
case 2: c[i][j]+=a[i][k]*b[j][k]; break;
|
30
|
+
case 3: c[i][j]+=a[k][i]*b[j][k]; break;
|
31
|
+
default: cout<<"give m_multiply options correctly"<<endl;endrun(10); break;
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
}
|
36
|
+
|
37
|
+
/* matrix operation on a vector C=AB*/
|
38
|
+
void m_multiply_a(float **a, float *b,float *c,int n1, int n2,int transpose)
|
39
|
+
{
|
40
|
+
int i,k;
|
41
|
+
|
42
|
+
for (i=n1;i<=n2;i++)
|
43
|
+
for (k=n1,c[i]=0.0;k<=n2;k++)
|
44
|
+
{
|
45
|
+
|
46
|
+
if(transpose)
|
47
|
+
c[i]+=a[k][i]*b[k];
|
48
|
+
else
|
49
|
+
c[i]+=a[i][k]*b[k];
|
50
|
+
// switch(transpose)
|
51
|
+
// {
|
52
|
+
// case 0: c[i]+=a[i][k]*b[k]; break;
|
53
|
+
// case 1: c[i]+=a[k][i]*b[k]; break;
|
54
|
+
// default: cout<<"give m_multiply options correctly"<<endl;endrun(10); break;
|
55
|
+
// }
|
56
|
+
}
|
57
|
+
|
58
|
+
}
|
59
|
+
|
60
|
+
/* print matrix */
|
61
|
+
void m_print(float **a,int n1 ,int n2)
|
62
|
+
{
|
63
|
+
int i,j;
|
64
|
+
for (i=n1;i<=n2;i++)
|
65
|
+
for (j=n1;j<=n2;j++)
|
66
|
+
{
|
67
|
+
printf("%12.6f ",a[i][j]);
|
68
|
+
if(j==n2) cout<<endl;
|
69
|
+
}
|
70
|
+
}
|
71
|
+
|
72
|
+
/* copy matrix */
|
73
|
+
void m_copy(float **a,float **b,int n1, int n2,int transpose)
|
74
|
+
{
|
75
|
+
int i,j;
|
76
|
+
for (i=n1;i<=n2;i++)
|
77
|
+
for (j=n1;j<=n2;j++)
|
78
|
+
{
|
79
|
+
if (transpose) b[i][j]=a[j][i];
|
80
|
+
else b[i][j]=a[i][j];
|
81
|
+
}
|
82
|
+
}
|
83
|
+
|
84
|
+
|
85
|
+
/* copy array */
|
86
|
+
void a_copy(float *a,float *b,int n1, int n2)
|
87
|
+
{
|
88
|
+
int i;
|
89
|
+
for (i=n1;i<=n2;i++)
|
90
|
+
b[i]=a[i];
|
91
|
+
|
92
|
+
}
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
/* print array */
|
97
|
+
void a_print(float *a,int n1,int n2)
|
98
|
+
{
|
99
|
+
int i;
|
100
|
+
for (i=n1;i<=n2;i++)
|
101
|
+
{
|
102
|
+
printf("%12.6e ",a[i]);
|
103
|
+
if(i==n2) cout<<endl;
|
104
|
+
}
|
105
|
+
}
|
106
|
+
|
107
|
+
/* max element array */
|
108
|
+
float a_max(float *a,int n1 , int n2)
|
109
|
+
{
|
110
|
+
int i;
|
111
|
+
float amax=a[n1];
|
112
|
+
for (i=n1;i<=n2;i++)
|
113
|
+
{
|
114
|
+
if(a[i] > amax ) amax=a[i];
|
115
|
+
}
|
116
|
+
return amax;
|
117
|
+
}
|
118
|
+
|
119
|
+
/* min element array */
|
120
|
+
float a_min(float *a,int n1, int n2)
|
121
|
+
{
|
122
|
+
int i;
|
123
|
+
float amin=a[n1];
|
124
|
+
for (i=n1;i<=n2;i++)
|
125
|
+
{
|
126
|
+
if(a[i] < amin ) amin=a[i];
|
127
|
+
}
|
128
|
+
return amin;
|
129
|
+
}
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
double second(void)
|
136
|
+
{
|
137
|
+
return ((double)((unsigned int)clock()))/CLOCKS_PER_SEC;
|
138
|
+
|
139
|
+
/* note: on AIX and presumably many other 32bit systems,
|
140
|
+
* clock() has only a resolution of 10ms=0.01sec
|
141
|
+
*/
|
142
|
+
}
|
143
|
+
|
144
|
+
|
145
|
+
/* returns the time difference between two measurements
|
146
|
+
* obtained with second(). The routine takes care of the
|
147
|
+
* possible overflow of the tick counter on 32bit systems.
|
148
|
+
*/
|
149
|
+
double timediff(double t0,double t1)
|
150
|
+
{
|
151
|
+
double dt;
|
152
|
+
|
153
|
+
dt=t1-t0;
|
154
|
+
|
155
|
+
if(dt<0) /* overflow has occured */
|
156
|
+
{
|
157
|
+
dt=t1 + pow(2.0,32.0)/CLOCKS_PER_SEC - t0;
|
158
|
+
}
|
159
|
+
|
160
|
+
return dt;
|
161
|
+
}
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
/* returns the maximum of two double
|
166
|
+
*/
|
167
|
+
double dmax(double x,double y)
|
168
|
+
{
|
169
|
+
if(x>y)
|
170
|
+
return x;
|
171
|
+
else
|
172
|
+
return y;
|
173
|
+
}
|
174
|
+
|
175
|
+
/* returns the minimum of two double
|
176
|
+
*/
|
177
|
+
double dmin(double x,double y)
|
178
|
+
{
|
179
|
+
if(x<y)
|
180
|
+
return x;
|
181
|
+
else
|
182
|
+
return y;
|
183
|
+
}
|
184
|
+
|
185
|
+
/* returns the maximum of two integers
|
186
|
+
*/
|
187
|
+
int imax(int x,int y)
|
188
|
+
{
|
189
|
+
if(x>y)
|
190
|
+
return x;
|
191
|
+
else
|
192
|
+
return y;
|
193
|
+
}
|
194
|
+
|
195
|
+
|
196
|
+
/* returns the minimum of two integers
|
197
|
+
*/
|
198
|
+
int imin(int x,int y)
|
199
|
+
{
|
200
|
+
if(x<y)
|
201
|
+
return x;
|
202
|
+
else
|
203
|
+
return y;
|
204
|
+
}
|
205
|
+
|
206
|
+
|
207
|
+
|
208
|
+
/* end the run */
|
209
|
+
void endrun(int ierr)
|
210
|
+
{
|
211
|
+
if(ierr)
|
212
|
+
{
|
213
|
+
fprintf(stdout,"endrun called with an error level of %d\n\n\n", ierr);
|
214
|
+
exit(1);
|
215
|
+
}
|
216
|
+
exit(0);
|
217
|
+
}
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
void checkrun(string s1 ,string s2, string s3)
|
222
|
+
{
|
223
|
+
int temp;
|
224
|
+
cout<<s1<<endl;
|
225
|
+
cout<<"Type 0 to "<<s2<<" or 1 to "<<s3<<" :";
|
226
|
+
cin>>temp;
|
227
|
+
if(temp!=1)
|
228
|
+
exit(1);
|
229
|
+
}
|
230
|
+
|
231
|
+
|
232
|
+
void endrunm(string s )
|
233
|
+
{
|
234
|
+
cout<<s<<endl;
|
235
|
+
exit(1);
|
236
|
+
}
|
237
|
+
|
238
|
+
|
239
|
+
|
240
|
+
/* calculate the gamma function */
|
241
|
+
float gammln(float xx)
|
242
|
+
{
|
243
|
+
double x,y,tmp,ser;
|
244
|
+
static double cof[6]={76.18009172947146,-86.50532032941677,
|
245
|
+
24.01409824083091,-1.231739572450155,
|
246
|
+
0.1208650973866179e-2,-0.5395239384953e-5};
|
247
|
+
int j;
|
248
|
+
|
249
|
+
y=x=xx;
|
250
|
+
tmp=x+5.5;
|
251
|
+
tmp -= (x+0.5)*log(tmp);
|
252
|
+
ser=1.000000000190015;
|
253
|
+
for (j=0;j<=5;j++) ser += cof[j]/++y;
|
254
|
+
return -tmp+log(2.5066282746310005*ser/x);
|
255
|
+
}
|
256
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
double dmax(double,double);
|
2
|
+
double dmin(double,double);
|
3
|
+
double drand48();
|
4
|
+
void endrun(int);
|
5
|
+
int imax(int,int);
|
6
|
+
int imin(int,int);
|
7
|
+
double second(void);
|
8
|
+
double timediff(double t0,double t1);
|
9
|
+
void m_multiply(float **a, float **b,float **c,int ,int , int);
|
10
|
+
void m_print(float **a,int ,int);
|
11
|
+
void m_copy(float **a,float **b,int , int, int);
|
12
|
+
void a_copy(float *a,float *b,int , int);
|
13
|
+
void a_print(float *a,int , int);
|
14
|
+
float a_max(float *a,int n1 , int n2);
|
15
|
+
float a_min(float *a,int n1 , int n2);
|
16
|
+
void m_multiply_a(float **a, float *b,float *c,int , int ,int );
|
17
|
+
double pow(double, double);
|
18
|
+
float gammln(float xx);
|
19
|
+
void checkrun(string s1,string s2,string s3);
|
20
|
+
void endrunm(string s);
|
Binary file
|
@@ -0,0 +1,299 @@
|
|
1
|
+
#include <stdio.h>
|
2
|
+
#include <stdlib.h>
|
3
|
+
#include <string.h>
|
4
|
+
#include <math.h>
|
5
|
+
#include "allvars.h"
|
6
|
+
#include "proto.h"
|
7
|
+
#include "tree.h"
|
8
|
+
#include "functions.h"
|
9
|
+
|
10
|
+
/*
|
11
|
+
* init() reads in the initial conditions,
|
12
|
+
* and allocates storage for the tree(s).
|
13
|
+
* Then generates the tree and finally calculates
|
14
|
+
* the density.
|
15
|
+
*/
|
16
|
+
void init(void)
|
17
|
+
{
|
18
|
+
int i,j;
|
19
|
+
float h2,m_min,m_max;
|
20
|
+
double t1,t2,xmean[ND];
|
21
|
+
|
22
|
+
t11=second();
|
23
|
+
// if(BatchFlag==1)
|
24
|
+
// sprintf(All.InitCondFile,"%s%s_%03d",All.InputDir,All.InitFileBase,Var.FileNum);
|
25
|
+
|
26
|
+
if(All.AnisotropicKernel==1)
|
27
|
+
{
|
28
|
+
if((All.TypeOfSmoothing!=2)and(All.TypeOfSmoothing!=3))
|
29
|
+
{
|
30
|
+
cout<<"For AnisotropicKernel=1, TypeOfSmoothing should be 2 or 3"<<endl;
|
31
|
+
endrun(10);
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
|
36
|
+
switch(All.ICFormat)
|
37
|
+
{
|
38
|
+
case 0:read_ic0(All.InitCondFile);break;
|
39
|
+
case 1:read_ic1(All.InitCondFile);break;
|
40
|
+
case 2:read_ic2(All.InitCondFile);break;
|
41
|
+
default:cout<<"Parameter ICFormat should be between 0 to 2"<<endl;endrun(10);
|
42
|
+
}
|
43
|
+
|
44
|
+
|
45
|
+
if(All.TypeListOn)
|
46
|
+
{
|
47
|
+
char buf[100];
|
48
|
+
char file_suf[10]="_typelist";
|
49
|
+
sprintf(buf,"%s%s",All.InitCondFile,file_suf);
|
50
|
+
read_typelist(buf,npart,P);
|
51
|
+
}
|
52
|
+
|
53
|
+
#ifdef PERIODIC
|
54
|
+
if(All.PeriodicBoundaryOn==1)
|
55
|
+
{
|
56
|
+
char file_periodic[21]="periodic_lengths.txt";
|
57
|
+
read_periodic_lengths(file_periodic,All.boxh);
|
58
|
+
|
59
|
+
for(j=0,i=0;j<int(npart.size());j++)
|
60
|
+
if(npart[j]>0) i++;
|
61
|
+
if(i>1)
|
62
|
+
{
|
63
|
+
cout<<"WARNING:multiple species present,"<<endl;
|
64
|
+
#ifdef WARN
|
65
|
+
checkrun("a constant global periodic boundary will be used for all of them","exit","continue");
|
66
|
+
#else
|
67
|
+
cout<<"a constant global periodic boundary will be used for all of them"<<endl;
|
68
|
+
#endif
|
69
|
+
}
|
70
|
+
|
71
|
+
}
|
72
|
+
else
|
73
|
+
{
|
74
|
+
cout<<"Code compiled with PERIODIC option, Set parameter PeriodicBoundaryOn to 1"<<endl;
|
75
|
+
endrun(10);
|
76
|
+
}
|
77
|
+
#else
|
78
|
+
if(All.PeriodicBoundaryOn!=0)
|
79
|
+
{
|
80
|
+
cout<<"Set parameter PeriodicBoundaryOn to 0"<<endl;
|
81
|
+
endrun(10);
|
82
|
+
}
|
83
|
+
#endif
|
84
|
+
|
85
|
+
// check multiple mass and issue warning
|
86
|
+
for(j=0;j<int(npart.size());j++)
|
87
|
+
{
|
88
|
+
i=npartc[j]+1;
|
89
|
+
m_min=P[i].Mass; m_max=P[i].Mass;
|
90
|
+
for(i=npartc[j]+1;i<=(npartc[j]+npart[j]);i++)
|
91
|
+
{
|
92
|
+
if(m_min>P[i].Mass) m_min=P[i].Mass;
|
93
|
+
if(m_max<P[i].Mass) m_max=P[i].Mass;
|
94
|
+
}
|
95
|
+
if(m_min!=m_max)
|
96
|
+
{
|
97
|
+
if(All.TypeOfSmoothing==1)
|
98
|
+
{
|
99
|
+
cout<<"For FiEstAS smoothing multiple mass support for same species of particle is not available"<<endl;
|
100
|
+
endrun(10);
|
101
|
+
}
|
102
|
+
else
|
103
|
+
{
|
104
|
+
#ifdef WARN
|
105
|
+
checkrun("WARNING! particles with multiple mass results might not be accurate","exit","continue");
|
106
|
+
#else
|
107
|
+
cout<<"WARNING! particles with multiple mass results might not be accurate"<<endl;
|
108
|
+
#endif
|
109
|
+
}
|
110
|
+
|
111
|
+
}
|
112
|
+
}
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
header1.flag_density=1;
|
117
|
+
treeallocate( All.MaxPart);
|
118
|
+
|
119
|
+
|
120
|
+
/* scaling the velocity and spatial co-ordinates */
|
121
|
+
for(j=0;j<ND;j++)
|
122
|
+
All.hs[j]=1.0;
|
123
|
+
|
124
|
+
if(All.SpatialScale>0)
|
125
|
+
{
|
126
|
+
if(ND==6)
|
127
|
+
{
|
128
|
+
for(j=0;j<3;j++)
|
129
|
+
All.hs[j]=All.SpatialScale;
|
130
|
+
}
|
131
|
+
}
|
132
|
+
else
|
133
|
+
{
|
134
|
+
for(j=0;j<ND;j++)
|
135
|
+
xmean[j]=0.0;
|
136
|
+
for(i=1; i<=NumPart; i++) /* start-up initialization */
|
137
|
+
{
|
138
|
+
for(j=0;j<ND;j++)
|
139
|
+
{
|
140
|
+
xmean[j]+=P[i].Pos[j];
|
141
|
+
}
|
142
|
+
}
|
143
|
+
for(j=0;j<ND;j++)
|
144
|
+
xmean[j]/=NumPart;
|
145
|
+
|
146
|
+
for(i=1; i<=NumPart; i++) /* start-up initialization */
|
147
|
+
{
|
148
|
+
for(j=0;j<ND;j++)
|
149
|
+
{
|
150
|
+
All.hs[j]+=(P[i].Pos[j]-xmean[j])*(P[i].Pos[j]-xmean[j]);
|
151
|
+
}
|
152
|
+
}
|
153
|
+
|
154
|
+
for(j=0;j<ND;j++)
|
155
|
+
All.hs[j]=sqrt(All.hs[j]/NumPart);
|
156
|
+
cout<<"Scaling Co-ordinates based on variance"<<endl;
|
157
|
+
h2=a_max(All.hs,0,ND-1);
|
158
|
+
for(j=0;j<ND;j++)
|
159
|
+
{
|
160
|
+
cout<<"i = "<<j<<" Sigma = "<<All.hs[j]<<" Scale = "<<All.hs[j]/h2<<endl;
|
161
|
+
All.hs[j]=All.hs[j]/h2;
|
162
|
+
}
|
163
|
+
|
164
|
+
}
|
165
|
+
|
166
|
+
for(j=0,All.hsv=1.0;j<ND;j++)
|
167
|
+
All.hsv*=All.hs[j];
|
168
|
+
cout<<"Scaling Co-ordinates as x[i]=x[i]/h[i] with h[i]->"<<endl;
|
169
|
+
for(j=0;j<ND;j++)
|
170
|
+
{
|
171
|
+
cout<<All.hs[j]<<" ";
|
172
|
+
}
|
173
|
+
cout<<"\n"<<endl;
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
for(i=1; i<=NumPart; i++) /* start-up initialization */
|
178
|
+
{
|
179
|
+
for(j=0;j<ND;j++)
|
180
|
+
{
|
181
|
+
P[i].Pos[j]=P[i].Pos[j]/All.hs[j];
|
182
|
+
}
|
183
|
+
}
|
184
|
+
|
185
|
+
#ifdef PERIODIC
|
186
|
+
for(j=0;j<ND;j++)
|
187
|
+
{
|
188
|
+
if(All.boxh[j]>0)
|
189
|
+
{
|
190
|
+
All.boxh[j]=All.boxh[j]/All.hs[j];
|
191
|
+
}
|
192
|
+
}
|
193
|
+
#endif
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
/* Build Tree */
|
198
|
+
if((All.NodeSplittingCriterion==1)&&(All.CubicCells==1))
|
199
|
+
{
|
200
|
+
if((ND!=6)&&(ND!=3))
|
201
|
+
{
|
202
|
+
cout<<"Cubic Cells not allowed for dimensions other than 3 or 6 here Dim="<<ND<<endl;
|
203
|
+
cout<<"Choose another option or modify routine"<<endl;
|
204
|
+
endrun(10);
|
205
|
+
}
|
206
|
+
}
|
207
|
+
|
208
|
+
printf("Starting to Build Tree ......."); fflush(stdout);
|
209
|
+
for(i=1; i<=NumPart; i++)
|
210
|
+
{
|
211
|
+
P[i].Density=0.0;
|
212
|
+
}
|
213
|
+
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
t1=second();
|
218
|
+
treebuild_all();
|
219
|
+
t2=second();
|
220
|
+
cout<<"Treebuild time = "<<timediff(t1,t2)<<" s \n"<<endl;
|
221
|
+
t22=second(); t00+=timediff(t11,t22);
|
222
|
+
|
223
|
+
|
224
|
+
All.order_flag=1;
|
225
|
+
if(All.order_flag==1)
|
226
|
+
{
|
227
|
+
for(i=0; i<NumPart; i++)
|
228
|
+
list_kdt[i]=list_kd[i];
|
229
|
+
order_particles(P+1,list_kd,NumPart,0);
|
230
|
+
for(i=0; i<NumPart; i++)
|
231
|
+
list_kd[i]=i;
|
232
|
+
}
|
233
|
+
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
density_par();
|
238
|
+
|
239
|
+
|
240
|
+
if(All.order_flag==1)
|
241
|
+
order_particles(P+1,list_kdt,NumPart,1);
|
242
|
+
|
243
|
+
// for(int ii=0;ii<100;ii++)
|
244
|
+
// cout<<"problem "<<Part[ii].Density<<endl;
|
245
|
+
|
246
|
+
savepositions();
|
247
|
+
|
248
|
+
|
249
|
+
/* correct for global scaling */
|
250
|
+
t22=second(); t00+=timediff(t11,t22);
|
251
|
+
|
252
|
+
}
|
253
|
+
|
254
|
+
|
255
|
+
|
256
|
+
template <class type> void order_particles(type* P,int *Id,int Nmax, int reverse)
|
257
|
+
{
|
258
|
+
int i;
|
259
|
+
type Psave;
|
260
|
+
int idsource, idest,*Id1;
|
261
|
+
|
262
|
+
Id1= (int *) malloc(sizeof(int)*Nmax);
|
263
|
+
|
264
|
+
if(reverse==1)
|
265
|
+
for(i = 0; i < Nmax; i++)
|
266
|
+
Id1[Id[i]]=i;
|
267
|
+
else
|
268
|
+
for(i = 0; i < Nmax; i++)
|
269
|
+
Id1[i]=Id[i];
|
270
|
+
|
271
|
+
for(i = 0; i < Nmax; i++)
|
272
|
+
{
|
273
|
+
if(Id1[i] != i)
|
274
|
+
{
|
275
|
+
Psave=P[i];
|
276
|
+
idest = i;
|
277
|
+
do
|
278
|
+
{
|
279
|
+
idsource=Id1[idest];
|
280
|
+
if(idsource == i)
|
281
|
+
{
|
282
|
+
P[idest]=Psave;
|
283
|
+
Id1[idest] =idest;
|
284
|
+
break;
|
285
|
+
}
|
286
|
+
P[idest] = P[idsource];
|
287
|
+
Id1[idest] = idest;
|
288
|
+
idest = idsource;
|
289
|
+
}
|
290
|
+
while(1);
|
291
|
+
}
|
292
|
+
}
|
293
|
+
free(Id1);
|
294
|
+
}
|
295
|
+
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
|
Binary file
|