enbid-ananke 0.3.0__cp310-cp310-manylinux_2_39_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.
- .cpython-310-x86_64-linux-gnu.so +0 -0
- 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.0.dist-info/METADATA +44 -0
- enbid_ananke-0.3.0.dist-info/RECORD +68 -0
- enbid_ananke-0.3.0.dist-info/WHEEL +5 -0
- enbid_ananke-0.3.0.dist-info/licenses/LICENSE +339 -0
- enbid_ananke-0.3.0.dist-info/top_level.txt +2 -0
@@ -0,0 +1,35 @@
|
|
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
|
+
void ngb_treesearch_sphere_metric(int no,struct NODE *nodes1, int NumBucket, int DesNumNgb,struct pqueue* pqxA,bool* imarkA);
|
18
|
+
void ngb_treesearch_sphere_metric_periodic(int no,struct NODE *nodes1, int NumBucket, int DesNumNgb,struct pqueue* pqxA,bool* imarkA);
|
19
|
+
void ngb_treesearch_sphere_gmatrix(int no,struct NODE *nodes1, int NumBucket, int DesNumNgb,struct pqueue* pqxA,bool * imarkA);
|
20
|
+
void ngb_treesearch_sphere_nometric(int no, struct NODE* nodes1,int NumBucket, int DesNumNgb,struct pqueue* pqxA,bool * imarkA);
|
21
|
+
void ngb_treesearch_box_metric(int no,struct NODE *nodes1, int NumBucket, int DesNumNgb,struct pqueue* pqxA, bool * imarkA);
|
22
|
+
float ngb_treedensity_sphere_metric(float xyz[ND],struct NODE *nodes1, int desngb, struct pqueue* pqxA, struct linklist* pqStartA, bool *idoneA,bool *imarkA);
|
23
|
+
float ngb_treedensity_sphere_metric_periodic(float xyz[ND],struct NODE *nodes1, int desngb, struct pqueue* pqxA, struct linklist* pqStartA, bool *idoneA,bool *imarkA);
|
24
|
+
float ngb_treedensity_sphere_nometric(float xyz[ND],struct NODE *nodes1, int desngb, struct pqueue* pqxA, struct linklist* pqStartA, bool *idoneA,bool *imarkA);
|
25
|
+
float ngb_treedensity_box_metric(float xyz[ND],struct NODE *nodes1, int desngb, struct pqueue* pqxA, struct linklist* pqStartA, bool *idoneA,bool *imarkA);
|
26
|
+
float ngb_treedensity_sphere_gmatrix(float xyz[ND],struct NODE *nodes1, int desngb, struct pqueue* pqxA, struct linklist* pqStartA, bool *idoneA,bool *imarkA);
|
27
|
+
float anisokernel_density(float xyz[ND],struct NODE *nodes1, int desngbA, struct pqueue* pqxA, struct linklist* pqStartA, bool *idoneA,bool *imarkA, int desngbB, struct pqueue* pqxB, struct linklist* pqStartB, bool *idoneB,bool *imarkB);
|
28
|
+
void create_linklist(struct pqueue* &pqx,struct linklist* &pqStart,bool* &imark,bool* &idone,int desngb,int numpart);
|
29
|
+
void initialize_linklist(struct linklist* pqStart,bool* imark,int iStart,int desngb,int numpart);
|
30
|
+
float density_general(float xyz[ND],struct NODE *nodes1, int desngbA, struct pqueue* pqxA, struct linklist* pqStartA, bool *idoneA,bool *imarkA, int desngbB, struct pqueue* pqxB, struct linklist* pqStartB, bool *idoneB,bool *imarkB);
|
31
|
+
void print_list(struct linklist *pq1,int size1);
|
32
|
+
float ngb_treedensity_bruteforce(float xyz[ND], int parttype,int desngb, struct pqueue* pqxA, struct linklist* pqStartA);
|
33
|
+
|
34
|
+
|
35
|
+
|
Binary file
|
@@ -0,0 +1,186 @@
|
|
1
|
+
/* Numerical recipies Shapiro, Teukolsky */
|
2
|
+
|
3
|
+
#include <stdio.h>
|
4
|
+
#include <stddef.h>
|
5
|
+
#include <stdlib.h>
|
6
|
+
#include <math.h>
|
7
|
+
#include "nr.h"
|
8
|
+
|
9
|
+
#define NR_END 1
|
10
|
+
#define FREE_ARG char*
|
11
|
+
|
12
|
+
|
13
|
+
void nrerror(char error_text[])
|
14
|
+
/* Numerical Recipes standard error handler */
|
15
|
+
{
|
16
|
+
fprintf(stderr,"Numerical Recipes run-time error...\n");
|
17
|
+
fprintf(stderr,"%s\n",error_text);
|
18
|
+
fprintf(stderr,"...now exiting to system...\n");
|
19
|
+
exit(1);
|
20
|
+
}
|
21
|
+
|
22
|
+
float *fvector(long nl, long nh)
|
23
|
+
/* allocate a float vector with subscript range v[nl..nh] */
|
24
|
+
{
|
25
|
+
float *v;
|
26
|
+
|
27
|
+
v=(float *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(float)));
|
28
|
+
if (!v) nrerror("allocation failure in vector()");
|
29
|
+
return v-nl+NR_END;
|
30
|
+
}
|
31
|
+
|
32
|
+
int *ivector(long nl, long nh)
|
33
|
+
/* allocate an int vector with subscript range v[nl..nh] */
|
34
|
+
{
|
35
|
+
int *v;
|
36
|
+
|
37
|
+
v=(int *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(int)));
|
38
|
+
if (!v) nrerror("allocation failure in ivector()");
|
39
|
+
return v-nl+NR_END;
|
40
|
+
}
|
41
|
+
|
42
|
+
|
43
|
+
float **matrix(long nrl, long nrh, long ncl, long nch)
|
44
|
+
/* allocate a float matrix with subscript range m[nrl..nrh][ncl..nch] */
|
45
|
+
{
|
46
|
+
long i, nrow=nrh-nrl+1,ncol=nch-ncl+1;
|
47
|
+
float **m;
|
48
|
+
|
49
|
+
|
50
|
+
/* allocate pointers to rows */
|
51
|
+
m=(float **) malloc((size_t)((nrow+NR_END)*sizeof(float*)));
|
52
|
+
if (!m) nrerror("allocation failure 1 in matrix()");
|
53
|
+
m += NR_END;
|
54
|
+
m -= nrl;
|
55
|
+
|
56
|
+
/* allocate rows and set pointers to them */
|
57
|
+
m[nrl]=(float *) malloc((size_t)((nrow*ncol+NR_END)*sizeof(float)));
|
58
|
+
if (!m[nrl]) nrerror("allocation failure 2 in matrix()");
|
59
|
+
m[nrl] += NR_END;
|
60
|
+
m[nrl] -= ncl;
|
61
|
+
|
62
|
+
for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol;
|
63
|
+
|
64
|
+
/* return pointer to array of pointers to rows */
|
65
|
+
return m;
|
66
|
+
}
|
67
|
+
|
68
|
+
|
69
|
+
void free_fvector(float *v, long nl, long nh)
|
70
|
+
/* free a float vector allocated with vector() */
|
71
|
+
{
|
72
|
+
|
73
|
+
free((FREE_ARG) (v+nl-NR_END));
|
74
|
+
}
|
75
|
+
|
76
|
+
void free_ivector(int *v, long nl, long nh)
|
77
|
+
/* free an int vector allocated with ivector() */
|
78
|
+
{
|
79
|
+
|
80
|
+
free((FREE_ARG) (v+nl-NR_END));
|
81
|
+
}
|
82
|
+
|
83
|
+
|
84
|
+
void free_matrix(float **m, long nrl, long nrh, long ncl, long nch)
|
85
|
+
/* free a float matrix allocated by matrix() */
|
86
|
+
{
|
87
|
+
|
88
|
+
free((FREE_ARG) (m[nrl]+ncl-NR_END));
|
89
|
+
free((FREE_ARG) (m+nrl-NR_END));
|
90
|
+
}
|
91
|
+
|
92
|
+
|
93
|
+
void free_imatrix(int **m, long nrl, long nrh, long ncl, long nch)
|
94
|
+
/* free an int matrix allocated by imatrix() */
|
95
|
+
{
|
96
|
+
|
97
|
+
free((FREE_ARG) (m[nrl]+ncl-NR_END));
|
98
|
+
free((FREE_ARG) (m+nrl-NR_END));
|
99
|
+
}
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
#define ROTATE(a,i,j,k,l) g=a[i][j];h=a[k][l];a[i][j]=g-s*(h+g*tau);\
|
104
|
+
a[k][l]=h+s*(g-h*tau);
|
105
|
+
|
106
|
+
void jacobi(float **a, int n, float d[], float **v, int *nrot)
|
107
|
+
{
|
108
|
+
int j,iq,ip,i;
|
109
|
+
float tresh,theta,tau,t,sm,s,h,g,c,*b,*z;
|
110
|
+
|
111
|
+
b=fvector(1,n);
|
112
|
+
z=fvector(1,n);
|
113
|
+
for (ip=1;ip<=n;ip++) {
|
114
|
+
for (iq=1;iq<=n;iq++) v[ip][iq]=0.0;
|
115
|
+
v[ip][ip]=1.0;
|
116
|
+
}
|
117
|
+
for (ip=1;ip<=n;ip++) {
|
118
|
+
b[ip]=d[ip]=a[ip][ip];
|
119
|
+
z[ip]=0.0;
|
120
|
+
}
|
121
|
+
*nrot=0;
|
122
|
+
for (i=1;i<=50;i++) {
|
123
|
+
sm=0.0;
|
124
|
+
for (ip=1;ip<=n-1;ip++) {
|
125
|
+
for (iq=ip+1;iq<=n;iq++)
|
126
|
+
sm += fabs(a[ip][iq]);
|
127
|
+
}
|
128
|
+
if (sm == 0.0) {
|
129
|
+
free_fvector(z,1,n);
|
130
|
+
free_fvector(b,1,n);
|
131
|
+
return;
|
132
|
+
}
|
133
|
+
if (i < 4)
|
134
|
+
tresh=0.2*sm/(n*n);
|
135
|
+
else
|
136
|
+
tresh=0.0;
|
137
|
+
for (ip=1;ip<=n-1;ip++) {
|
138
|
+
for (iq=ip+1;iq<=n;iq++) {
|
139
|
+
g=100.0*fabs(a[ip][iq]);
|
140
|
+
if (i > 4 && (float)(fabs(d[ip])+g) == (float)fabs(d[ip])
|
141
|
+
&& (float)(fabs(d[iq])+g) == (float)fabs(d[iq]))
|
142
|
+
a[ip][iq]=0.0;
|
143
|
+
else if (fabs(a[ip][iq]) > tresh) {
|
144
|
+
h=d[iq]-d[ip];
|
145
|
+
if ((float)(fabs(h)+g) == (float)fabs(h))
|
146
|
+
t=(a[ip][iq])/h;
|
147
|
+
else {
|
148
|
+
theta=0.5*h/(a[ip][iq]);
|
149
|
+
t=1.0/(fabs(theta)+sqrt(1.0+theta*theta));
|
150
|
+
if (theta < 0.0) t = -t;
|
151
|
+
}
|
152
|
+
c=1.0/sqrt(1+t*t);
|
153
|
+
s=t*c;
|
154
|
+
tau=s/(1.0+c);
|
155
|
+
h=t*a[ip][iq];
|
156
|
+
z[ip] -= h;
|
157
|
+
z[iq] += h;
|
158
|
+
d[ip] -= h;
|
159
|
+
d[iq] += h;
|
160
|
+
a[ip][iq]=0.0;
|
161
|
+
for (j=1;j<=ip-1;j++) {
|
162
|
+
ROTATE(a,j,ip,j,iq)
|
163
|
+
}
|
164
|
+
for (j=ip+1;j<=iq-1;j++) {
|
165
|
+
ROTATE(a,ip,j,j,iq)
|
166
|
+
}
|
167
|
+
for (j=iq+1;j<=n;j++) {
|
168
|
+
ROTATE(a,ip,j,iq,j)
|
169
|
+
}
|
170
|
+
for (j=1;j<=n;j++) {
|
171
|
+
ROTATE(v,j,ip,j,iq)
|
172
|
+
}
|
173
|
+
++(*nrot);
|
174
|
+
}
|
175
|
+
}
|
176
|
+
}
|
177
|
+
for (ip=1;ip<=n;ip++) {
|
178
|
+
b[ip] += z[ip];
|
179
|
+
d[ip]=b[ip];
|
180
|
+
z[ip]=0.0;
|
181
|
+
}
|
182
|
+
}
|
183
|
+
nrerror("Too many iterations in routine jacobi");
|
184
|
+
}
|
185
|
+
#undef ROTATE
|
186
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/* Numerical recipies Shapiro, Teukolsky */
|
2
|
+
void nrerror(char error_text[]);
|
3
|
+
float *fvector(long nl, long nh);
|
4
|
+
void free_fvector(float *v, long nl, long nh);
|
5
|
+
float **matrix(long nrl, long nrh, long ncl, long nch);
|
6
|
+
void jacobi(float **a, int n, float d[], float **v, int *nrot);
|
7
|
+
void free_matrix(float **m, long nrl, long nrh, long ncl, long nch);
|
8
|
+
int *ivector(long nl, long nh);
|
9
|
+
void free_ivector(int *v, long nl, long nh);
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
|
Binary file
|
@@ -0,0 +1,22 @@
|
|
1
|
+
void allocate_memory(void);
|
2
|
+
void begrun(void);
|
3
|
+
void free_memory(void);
|
4
|
+
void init(void);
|
5
|
+
void read_ic0(char *fname);
|
6
|
+
void read_ic1(char *fname);
|
7
|
+
void read_ic2(char *fname);
|
8
|
+
void read_parameter_file(char *fname);
|
9
|
+
void savepositions(void );
|
10
|
+
void savepositions_ioformat2(void);
|
11
|
+
void savepositions_ioformat1(void);
|
12
|
+
void savepositions_ioformat0(void);
|
13
|
+
void set_sph_kernel(int TypeOfKernel, int dim);
|
14
|
+
void density_par(void);
|
15
|
+
size_t my_fwrite1(void *ptr,int* pattern,size_t nmemb,int flag_swap,FILE *stream);
|
16
|
+
size_t my_fread1(void *ptr, int *pattern, size_t nmemb,int flag_swap,FILE *stream);
|
17
|
+
void SwapEndian(void* addr, int* pattern);
|
18
|
+
template <class type> void order_particles(type* P,int *Id,int Nmax, int reverse);
|
19
|
+
void read_typelist(char *fname,vector<int> &npart, struct particle_data P[]);
|
20
|
+
void read_periodic_lengths(char *fname,double boxh[ND]);
|
21
|
+
|
22
|
+
|
@@ -0,0 +1,434 @@
|
|
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<fstream>
|
8
|
+
#include "functions.h"
|
9
|
+
|
10
|
+
|
11
|
+
/* This function reads initial conditions that are in the default file format
|
12
|
+
* of Gadget or in ASCII format x[i] y[i] z[i].
|
13
|
+
*/
|
14
|
+
/* Read GADGET format file */
|
15
|
+
void read_ic1(char *fname)
|
16
|
+
{
|
17
|
+
#define SKIP my_fread1(&blklen,patterns,1,All.flag_swap,fd);
|
18
|
+
FILE *fd;
|
19
|
+
int i,k,massflag,count;
|
20
|
+
float dummy[3];
|
21
|
+
int pc,type ;
|
22
|
+
int patternd[]={4,3,0},patterns[]={4,1,0},patternh[]={4,6,8,8,4,10,8,4,4,3,4,21,0};
|
23
|
+
int4byte intdummy, blklen;
|
24
|
+
All.flag_swap=0;
|
25
|
+
|
26
|
+
|
27
|
+
if((ND!=3)&&(ND!=6))
|
28
|
+
endrunm("\nFor Gadget format file number of dimensions should be 3 or 6\n");
|
29
|
+
|
30
|
+
|
31
|
+
if((fd=fopen(fname,"r")))
|
32
|
+
{
|
33
|
+
fprintf(stdout,"Reading GADGET format file: %s \n",fname); fflush(stdout);
|
34
|
+
|
35
|
+
SKIP;
|
36
|
+
if(blklen!=256)
|
37
|
+
{
|
38
|
+
All.flag_swap=1;
|
39
|
+
SwapEndian(&blklen,patterns);
|
40
|
+
if(blklen!=256)
|
41
|
+
{
|
42
|
+
printf("incorrect header format (2)\n");
|
43
|
+
endrun(889);
|
44
|
+
}
|
45
|
+
}
|
46
|
+
|
47
|
+
my_fread1(&header1,patternh,1,All.flag_swap,fd);
|
48
|
+
|
49
|
+
|
50
|
+
SKIP;
|
51
|
+
if(blklen!=256)
|
52
|
+
{
|
53
|
+
printf("incorrect header format (2)\n");
|
54
|
+
endrun(889);
|
55
|
+
}
|
56
|
+
|
57
|
+
// All.BoxSize=header1.BoxSize;
|
58
|
+
for(i=0, massflag=0;i<6;i++)
|
59
|
+
{
|
60
|
+
if(header1.mass[i]==0 && header1.npart[i]>0)
|
61
|
+
massflag=1;
|
62
|
+
}
|
63
|
+
|
64
|
+
|
65
|
+
for(i=0,NumPart=0;i<6;i++)
|
66
|
+
NumPart+=header1.npart[i];
|
67
|
+
|
68
|
+
All.MaxPart = NumPart; // sets the maximum number of particles
|
69
|
+
|
70
|
+
allocate_memory();
|
71
|
+
|
72
|
+
SKIP;
|
73
|
+
for(i=1;i<=NumPart;i++)
|
74
|
+
{
|
75
|
+
my_fread1(&dummy[0],patternd,1,All.flag_swap,fd);
|
76
|
+
for(k=0;k<3;k++)
|
77
|
+
P[i].Pos[k]=dummy[k];
|
78
|
+
}
|
79
|
+
SKIP;
|
80
|
+
|
81
|
+
|
82
|
+
SKIP;
|
83
|
+
for(i=1;i<=NumPart;i++)
|
84
|
+
{
|
85
|
+
my_fread1(&dummy[0],patternd,1,All.flag_swap,fd);
|
86
|
+
#ifdef DIM3
|
87
|
+
for(k=0;k<3;k++)
|
88
|
+
P[i].Vel[k]=dummy[k];
|
89
|
+
#else
|
90
|
+
if(ND>3)
|
91
|
+
for(k=0;k<(ND-3);k++)
|
92
|
+
P[i].Pos[k+3]=dummy[k];
|
93
|
+
#endif
|
94
|
+
}
|
95
|
+
SKIP;
|
96
|
+
|
97
|
+
|
98
|
+
SKIP;
|
99
|
+
for(i=1;i<=NumPart;i++)
|
100
|
+
{
|
101
|
+
my_fread1(&intdummy, patterns, 1,All.flag_swap, fd);
|
102
|
+
P[i].ID= intdummy;
|
103
|
+
}
|
104
|
+
SKIP;
|
105
|
+
|
106
|
+
|
107
|
+
if(massflag)
|
108
|
+
SKIP;
|
109
|
+
for(type=0, count=1; type<6; type++)
|
110
|
+
{
|
111
|
+
if(header1.mass[type]==0 && header1.npart[type]>0)
|
112
|
+
{
|
113
|
+
k=count;
|
114
|
+
for(i=1;i<=header1.npart[type];i++)
|
115
|
+
{
|
116
|
+
my_fread1(&dummy[0], patterns, 1,All.flag_swap, fd);
|
117
|
+
P[count++].Mass=dummy[0];
|
118
|
+
|
119
|
+
}
|
120
|
+
|
121
|
+
}
|
122
|
+
else
|
123
|
+
{
|
124
|
+
for(i=1;i<=header1.npart[type];i++)
|
125
|
+
{
|
126
|
+
P[count++].Mass= header1.mass[type];
|
127
|
+
}
|
128
|
+
}
|
129
|
+
}
|
130
|
+
if(massflag)
|
131
|
+
SKIP;
|
132
|
+
|
133
|
+
fclose(fd);
|
134
|
+
fprintf(stdout,"....done with reading.\n"); fflush(stdout);
|
135
|
+
|
136
|
+
|
137
|
+
npart.clear();
|
138
|
+
npartc.clear();
|
139
|
+
for(i=0,k=0; i<6; i++)
|
140
|
+
{
|
141
|
+
npart.push_back(header1.npart[i]);
|
142
|
+
npartc.push_back(k);
|
143
|
+
k+=npart[i];
|
144
|
+
}
|
145
|
+
/* set the particle types */
|
146
|
+
for(type=0, pc=1; type<6; type++)
|
147
|
+
for(i=0; i<npart[type]; i++)
|
148
|
+
P[pc++].Type = type;
|
149
|
+
|
150
|
+
|
151
|
+
}
|
152
|
+
else
|
153
|
+
{
|
154
|
+
fprintf(stdout,"File %s not found.\n", fname);
|
155
|
+
endrun(7);
|
156
|
+
}
|
157
|
+
|
158
|
+
for(i=0; i<6; i++)
|
159
|
+
if(header1.npart[i]>0) cout<<"Type = "<<i<<" Particles = "<<header1.npart[i]<<endl;
|
160
|
+
|
161
|
+
fprintf(stdout,"Total particles = %d\n", NumPart);
|
162
|
+
|
163
|
+
#undef SKIP
|
164
|
+
|
165
|
+
}
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
/* Read ASCII format file */
|
178
|
+
void read_ic0(char *fname)
|
179
|
+
{
|
180
|
+
#define SKIP my_fread(&blklen,sizeof(int4byte),1,fd);
|
181
|
+
// FILE *fd;
|
182
|
+
int i,k,m=0;
|
183
|
+
float temp;
|
184
|
+
int pc,type ;
|
185
|
+
|
186
|
+
// double u_init;
|
187
|
+
// ofstream fd (fname);
|
188
|
+
|
189
|
+
|
190
|
+
ifstream fd;
|
191
|
+
fd.open(fname);
|
192
|
+
if (fd.is_open())
|
193
|
+
{
|
194
|
+
fprintf(stdout,"Reading ASCII format file: %s \n",fname); fflush(stdout);
|
195
|
+
m=0;
|
196
|
+
while(fd>>temp) m++;
|
197
|
+
if((m%ND)==0)
|
198
|
+
cout<<"Read "<<m<<" records"<<endl;
|
199
|
+
else
|
200
|
+
{
|
201
|
+
cout<<"File format incorrect expecting "<<m%ND<<" more records"<<endl;
|
202
|
+
endrun(10);
|
203
|
+
}
|
204
|
+
fd.close();
|
205
|
+
}
|
206
|
+
else
|
207
|
+
{
|
208
|
+
fprintf(stdout,"File %s not found.\n", fname);
|
209
|
+
endrun(7);
|
210
|
+
}
|
211
|
+
|
212
|
+
NumPart=m/ND;
|
213
|
+
All.MaxPart = NumPart; // sets the maximum number of particles
|
214
|
+
|
215
|
+
for(i=0;i<6;i++)
|
216
|
+
{
|
217
|
+
header1.npart[i]=0;
|
218
|
+
header1.npartTotal[i]=0;
|
219
|
+
header1.mass[i]=0;
|
220
|
+
}
|
221
|
+
header1.npart[1]=NumPart;
|
222
|
+
header1.mass[1]=1.0;
|
223
|
+
header1.npartTotal[1]=NumPart;
|
224
|
+
|
225
|
+
|
226
|
+
allocate_memory();
|
227
|
+
|
228
|
+
|
229
|
+
/* reading data */
|
230
|
+
ifstream fd1;
|
231
|
+
fd1.open(fname);
|
232
|
+
if (fd1.is_open())
|
233
|
+
{
|
234
|
+
for(i=1; i<=NumPart; i++) /* start-up initialization */
|
235
|
+
{
|
236
|
+
P[i].ID=i;
|
237
|
+
for(k=0;k<ND;k++)
|
238
|
+
if(!(fd1>>P[i].Pos[k]))
|
239
|
+
{
|
240
|
+
cout<<" file reading problem terminatiing"<<i<<" "<<k<<endl;
|
241
|
+
// endrun(10);
|
242
|
+
}
|
243
|
+
}
|
244
|
+
fd1.close();
|
245
|
+
}
|
246
|
+
|
247
|
+
for(i=1; i<=NumPart; i++) /* start-up initialization */
|
248
|
+
P[i].Mass=1.0;
|
249
|
+
/* set the particle types */
|
250
|
+
npart.clear();
|
251
|
+
npartc.clear();
|
252
|
+
for(i=0,k=0; i<6; i++)
|
253
|
+
{
|
254
|
+
npart.push_back(header1.npart[i]);
|
255
|
+
npartc.push_back(k);
|
256
|
+
k+=npart[i];
|
257
|
+
}
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
for(type=0, pc=1; type<6; type++)
|
262
|
+
for(i=0; i<header1.npart[type]; i++)
|
263
|
+
P[pc++].Type = type;
|
264
|
+
|
265
|
+
|
266
|
+
for(i=0; i<6; i++)
|
267
|
+
if(header1.npart[i]>0) cout<<"Type = "<<i<<" Particles = "<<header1.npart[i]<<endl;
|
268
|
+
|
269
|
+
fprintf(stdout,"Total particles = %d\n", NumPart);
|
270
|
+
|
271
|
+
#undef SKIP
|
272
|
+
}
|
273
|
+
|
274
|
+
/* write a new reading routine */
|
275
|
+
void read_ic2(char *fname)
|
276
|
+
{
|
277
|
+
|
278
|
+
int i,k,type,pc;
|
279
|
+
ifstream fd;
|
280
|
+
fd.open(fname);
|
281
|
+
if (fd.is_open())
|
282
|
+
{
|
283
|
+
fprintf(stdout,"Reading --- format file: %s \n",fname); fflush(stdout);
|
284
|
+
// read here
|
285
|
+
|
286
|
+
fd.close();
|
287
|
+
}
|
288
|
+
else
|
289
|
+
cout<<"Error opening file"<<endl;
|
290
|
+
|
291
|
+
cout<<"Write your input routine here"<<endl;
|
292
|
+
endrun(10);
|
293
|
+
|
294
|
+
//-------------------------------------
|
295
|
+
/* SPECIFY TOTAL NUMBER OF PARTICLES*/
|
296
|
+
NumPart=1;
|
297
|
+
//-------------------------------------
|
298
|
+
|
299
|
+
/* leave this unchanged */
|
300
|
+
All.MaxPart = NumPart;
|
301
|
+
for(i=0;i<6;i++)
|
302
|
+
{
|
303
|
+
header1.npart[i]=0;
|
304
|
+
header1.npartTotal[i]=0;
|
305
|
+
header1.mass[i]=0;
|
306
|
+
}
|
307
|
+
header1.npart[1]=NumPart;
|
308
|
+
header1.npartTotal[1]=NumPart;
|
309
|
+
allocate_memory();
|
310
|
+
|
311
|
+
//-------------------------------------
|
312
|
+
/* READ THE DATA HERE AND ASSIGN IT TO P[i].Pos */
|
313
|
+
for(i=1; i<=NumPart; i++)
|
314
|
+
for(k=0;k<ND;k++)
|
315
|
+
P[i].Pos[k]=1.0;
|
316
|
+
for(i=1; i<=NumPart; i++)
|
317
|
+
{
|
318
|
+
P[i].ID=i;
|
319
|
+
P[i].Mass=1.0;
|
320
|
+
}
|
321
|
+
//-------------------------------------
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
npart.clear();
|
326
|
+
npartc.clear();
|
327
|
+
for(i=0,k=0; i<6; i++)
|
328
|
+
{
|
329
|
+
npart.push_back(header1.npart[i]);
|
330
|
+
npartc.push_back(k);
|
331
|
+
k+=npart[i];
|
332
|
+
}
|
333
|
+
|
334
|
+
|
335
|
+
|
336
|
+
/* set the particle types */
|
337
|
+
for(type=0, pc=1; type<6; type++)
|
338
|
+
for(i=0; i<header1.npart[type]; i++)
|
339
|
+
P[pc++].Type = type;
|
340
|
+
|
341
|
+
for(i=0; i<6; i++)
|
342
|
+
if(header1.npart[i]>0) cout<<"Type = "<<i<<" Particles = "<<header1.npart[i]<<endl;
|
343
|
+
fprintf(stdout,"Total particles = %d\n", NumPart);
|
344
|
+
|
345
|
+
|
346
|
+
|
347
|
+
}
|
348
|
+
|
349
|
+
|
350
|
+
|
351
|
+
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
/* Read typelist file */
|
356
|
+
void read_typelist(char *fname,vector<int> &npart, struct particle_data P[])
|
357
|
+
{
|
358
|
+
// FILE *fd;
|
359
|
+
int i,k=0;
|
360
|
+
// unsigned int j;
|
361
|
+
int temp;
|
362
|
+
int pc,type ;
|
363
|
+
|
364
|
+
ifstream fd;
|
365
|
+
fd.open(fname);
|
366
|
+
if (fd.is_open())
|
367
|
+
{
|
368
|
+
npart.clear();
|
369
|
+
npartc.clear();
|
370
|
+
fprintf(stdout,"Reading TypeList file: %s \n",fname); fflush(stdout);
|
371
|
+
while(fd>>temp)
|
372
|
+
{
|
373
|
+
npart.push_back(temp);
|
374
|
+
npartc.push_back(k);
|
375
|
+
k+=temp;
|
376
|
+
}
|
377
|
+
fd.close();
|
378
|
+
cout<<"Total No of particle types= "<<npart.size()<<" and Total Particles "<<k<<endl;
|
379
|
+
}
|
380
|
+
else
|
381
|
+
{
|
382
|
+
cout<<"Error opening typelist file"<<endl;
|
383
|
+
fprintf(stdout,"%s \n",fname); fflush(stdout);
|
384
|
+
endrun(1);
|
385
|
+
}
|
386
|
+
|
387
|
+
// if(k!=NumPart)
|
388
|
+
|
389
|
+
for(type=0, pc=1; type<int(npart.size()); type++)
|
390
|
+
for(i=0; i<npart[type]; i++)
|
391
|
+
P[pc++].Type = type;
|
392
|
+
|
393
|
+
}
|
394
|
+
|
395
|
+
|
396
|
+
|
397
|
+
/* Read periodic lengths file */
|
398
|
+
void read_periodic_lengths(char *fname,double boxh[ND])
|
399
|
+
{
|
400
|
+
// FILE *fd;
|
401
|
+
int k=0;
|
402
|
+
// unsigned int j;
|
403
|
+
float temp;
|
404
|
+
|
405
|
+
ifstream fd;
|
406
|
+
fd.open(fname);
|
407
|
+
if (fd.is_open())
|
408
|
+
{
|
409
|
+
fprintf(stdout,"Reading periodic lengths file: %s \n",fname); fflush(stdout);
|
410
|
+
|
411
|
+
for(k=0;k<ND;k++)
|
412
|
+
{
|
413
|
+
if(fd>>temp)
|
414
|
+
{
|
415
|
+
boxh[k]=temp/2.0;
|
416
|
+
}
|
417
|
+
else
|
418
|
+
{
|
419
|
+
cout<<"Error reading periodic lengths "<<endl;
|
420
|
+
cout<<"Read "<<k<<" out of "<<ND<<" records"<<endl;
|
421
|
+
endrun(1);
|
422
|
+
}
|
423
|
+
|
424
|
+
}
|
425
|
+
fd.close();
|
426
|
+
}
|
427
|
+
else
|
428
|
+
{
|
429
|
+
cout<<"periodic_lengths.txt file not found"<<endl;
|
430
|
+
cout<<"should be in the curent directory"<<endl;
|
431
|
+
endrun(1);
|
432
|
+
}
|
433
|
+
}
|
434
|
+
|
Binary file
|