-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtipsy.h
138 lines (123 loc) · 2.82 KB
/
tipsy.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#ifndef TIPSY_INCLUDED
#define TIPSY_INCLUDED
#include <rpc/types.h>
#include <rpc/xdr.h>
#define TIPSY_TYPE_GAS 1
#define TIPSY_TYPE_DARK 2
#define TIPSY_TYPE_STAR 3
#define TIPSY_BLOCK 10000
/*
** Set DOUBLE_POS or DOUBLE_POS_VEL for double precision positions and
** velocities.
*/
//#define DOUBLE_POS
//#define DOUBLE_POS_VEL
struct gas_particle {
float mass;
#if defined(DOUBLE_POS) || defined(DOUBLE_POS_VEL)
double pos[3];
#else
float pos[3];
#endif
#ifdef DOUBLE_POS_VEL
double vel[3];
#else
float vel[3];
#endif
float rho;
float temp;
float hsmooth;
float metals;
float phi;
};
struct dark_particle {
float mass;
#if defined(DOUBLE_POS) || defined(DOUBLE_POS_VEL)
double pos[3];
#else
float pos[3];
#endif
#ifdef DOUBLE_POS_VEL
double vel[3];
#else
float vel[3];
#endif
float eps;
float phi;
};
struct star_particle {
float mass;
#if defined(DOUBLE_POS) || defined(DOUBLE_POS_VEL)
double pos[3];
#else
float pos[3];
#endif
#ifdef DOUBLE_POS_VEL
double vel[3];
#else
float vel[3];
#endif
float metals;
float tform;
float eps;
float phi;
};
struct base_particle {
float mass;
#if defined(DOUBLE_POS) || defined(DOUBLE_POS_VEL)
double pos[3];
#else
float pos[3];
#endif
#ifdef DOUBLE_POS_VEL
double vel[3];
#else
float vel[3];
#endif
};
struct dump {
double time;
unsigned nbodies;
unsigned ndim;
unsigned nsph;
unsigned ndark;
unsigned nstar;
};
typedef struct TipsyContext {
int bNative;
unsigned iCurr;
int iCurrType;
unsigned nRemain;
unsigned nBlock;
unsigned iBlock;
struct gas_particle gpCurr;
struct dark_particle dpCurr;
struct star_particle spCurr;
unsigned nMaxGas,nGas;
unsigned nMaxDark,nDark;
unsigned nMaxStar,nStar;
struct gas_particle *gp;
struct dark_particle *dp;
struct star_particle *sp;
FILE *fp;
XDR xdr;
struct dump head;
char *pchInFile;
} * TCTX;
int xdr_header(XDR *xdrs, struct dump *header);
int xdr_gas(XDR *xdrs,struct gas_particle *p);
int xdr_dark(XDR *xdrs,struct dark_particle *p);
int xdr_star(XDR *xdrs,struct star_particle *p);
void TipsyInitialize(TCTX *pctx,int bNative,char *pchInFile);
void TipsyFinish(TCTX ctx);
struct base_particle *pTipsyReadNative(TCTX ctx,int *piType,double *pdSoft);
struct base_particle *pTipsyRead(TCTX ctx,int *piType,double *pdSoft);
struct base_particle *pTipsyParticle(TCTX ctx,unsigned iIndex,int *piType,double *pdSoft);
void TipsyReadAll(TCTX ctx);
void TipsyAddGas(TCTX ctx,struct gas_particle *pGas);
void TipsyAddDark(TCTX ctx,struct dark_particle *pDark);
void TipsyAddStar(TCTX ctx,struct star_particle *pStar);
void TipsyWriteAll(TCTX ctx,double dTime,char *pchFileName);
unsigned iTipsyNumParticles(TCTX ctx);
double dTipsyTime(TCTX ctx);
#endif