forked from N-BodyShop/gasoline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
collision.h
196 lines (166 loc) · 5.01 KB
/
collision.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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
#ifndef COLLISION_HINCLUDED
#define COLLISION_HINCLUDED
#include "pkd.h" /* for PARTICLE struct */
#include "ssio.h" /* for SSDATA struct */
#ifdef COLLISIONS
#include "special.h"
#ifdef AGGS
#include "aggs.h" /* for Aggregate struct */
#endif
#ifdef RUBBLE_ZML
#include "rubble.h"
#endif
#define NORMAL 0 /* drift types */
#define KEPLER 1
FLOAT RADIUS(PARTICLE *p);
#define RADIUS(p) (2.0*(p)->fSoft) /* currently PARTICLE has no radius field;
to ensure all interactions are strictly
Newtonian, set the softening length to
be half the physical radius. */
int REJECT(PARTICLE *p);
#define REJECT(p) ((p)->dtCol < 0)
int COLLISION(double t);
#define COLLISION(t) ((t) < DBL_MAX)
unsigned int BIT(unsigned int n);
#define BIT(n) (1 << (n))
#define COLL_LOG_NONE 0
#define COLL_LOG_VERBOSE 1
#define COLL_LOG_TERSE 2
#define MISS 0
#define MERGE BIT(0)
#define BOUNCE BIT(1)
#define FRAG BIT(2)
#define BINARY_MERGE BIT(3)
#define MAX_NUM_FRAG 4
#ifdef SAND_PILE
#define MAX_NUM_WALLS 10
#ifdef TUMBLER
typedef struct {
double n[3]; /*unit normal to flat wall or axis of cylinder */
double ndotp; /*dot product of unit normal n and point p on wall */
double radius; /* radius of cylinder */
double omega; /*rotation rate of cylinder */
double dEpsN,dEpsT;
double hotParam; /*if nonzero, defines a permanent velocity of the wall
that sets a minimum energy for colliding particles */
int type; /*type = 0 for flat wall, = 1 for cylinder */
} WALL;
#else
typedef struct {
double x1,z1;
double x2,z2;
double dEpsN,dEpsT;
} WALL;
#endif
typedef struct {
int nWalls;
WALL wall[MAX_NUM_WALLS];
} WALLS;
#endif
enum {ConstEps,Frosty200,Frosty120,Compacted,Glancing}; /* bounce options */
enum {EscVel,MaxTrv}; /* slide options */
typedef struct {
int iOutcomes;
double dDensity;
double dBounceLimit;
int iBounceOption;
double dEpsN;
double dEpsT;
int iSlideOption;
double dSlideLimit;
double dSlideLimit2;
double dSlideEpsN;
double dSlideEpsT;
double dCollapseLimit;
double dCollapseEpsN;
double dCollapseEpsT;
double dCrushLimit;
double dCrushEpsN;
double dCrushEpsT;
int bFixCollapse;
#ifdef SAND_PILE
WALLS walls;
#endif
#ifdef RUBBLE_ZML
int iRubForcedOutcome;
int iRubColor;
double dRubbleMinFracMass;
int bDoRubbleKDKRestart;
DUST_BINS_PARAMS DB;
#endif
} COLLISION_PARAMS;
typedef struct {
int iPid;
int iOrder;
int iIndex;
int iOrgIdx;
} PARTICLE_ID;
typedef struct {
PARTICLE_ID id;
FLOAT fMass;
FLOAT fRadius;
FLOAT r[3];
FLOAT v[3];
FLOAT w[3];
FLOAT a[3];
FLOAT dt;
FLOAT fDummy;
int iRung;
int iColor;
int bTinyStep;
#ifdef AGGS
Aggregate agg;
#endif
int iPad; /* This is a cheat to make the code work on intel
64 bit machines */
} COLLIDER;
FLOAT SOFT(COLLIDER *c);
#define SOFT(c) (0.5*(c)->fRadius)
FLOAT SOFT_FROM_SSDATA(SSDATA *d);
#define SOFT_FROM_SSDATA(d) (0.5*(d)->radius) /* used in pkd.c */
#ifdef AGGS
int COLLIDER_IS_AGG(COLLIDER *c);
int COLLIDER_AGG_IDX(COLLIDER *c);
#define COLLIDER_IS_AGG(c) ((c)->id.iOrgIdx < 0)
#define COLLIDER_AGG_IDX(c) (-1 - (c)->id.iOrgIdx)
void pkdAggsDoCollision(PKD pkd,double dt,const COLLIDER *c1,const COLLIDER *c2,
int bPeriodic,const COLLISION_PARAMS *CP,int iAggNewIdx,
int *piOutcome,double *dT,COLLIDER *cOut,int *pnOut);
#endif /* AGGS */
void pkdNextCollision(PKD pkd, double *dtCol, int *iOrder1, int *iOrder2);
void pkdGetColliderInfo(PKD pkd, int iOrder, COLLIDER *c);
void PutColliderInfo(PKD pkd, const COLLIDER *c,int iOrder2,PARTICLE *p,
double dt);
void pkdDoCollision(PKD pkd, double dt, const COLLIDER *c1, const COLLIDER *c2,
int bPeriodic, int iTime0, double dBaseStep, double dTimeNow,
const COLLISION_PARAMS *CP, int *piOutcome,double *dT, COLLIDER *cOut,
int *pnOut);
void pkdResetColliders(PKD pkd, int iOrder1, int iOrder2);
double LastKickTime(int iRung, double dBaseStep, double dTimeNow);
void pkdSetBall(PKD pkd,double dDelta,double fac);
void pkdFindTightestBinary(PKD pkd,double *dBindEn,int *iOrder1,int *iOrder2,
int *n);
void SetMergerRung(const COLLIDER *c1,const COLLIDER *c2,COLLIDER *c,
double dBaseStep,double dTimeNow,int iTime0);
void MergerReorder(PKD pkd,const COLLIDER *pc1,const COLLIDER *pc2,const COLLIDER *c,
COLLIDER *cOut,double dt,const COLLISION_PARAMS *CP,
int bDiagInfo,const FLOAT fOffset[]
#ifdef RUBBLE_ZML
,double dMassInDust
#endif
#ifdef SLIDING_PATCH
,FLOAT fShear
#endif
,int bPeriodic);
void pkdMergeBinary(PKD pkd,const COLLIDER *c1,const COLLIDER *c2,COLLIDER *c,
int bPeriodic,double dBaseStep,double dTimeNow,int iTime0,
double dDensity,int *bool);
#ifdef SLIDING_PATCH
#define MAXLARGEMASS 25 /* Maximum number of particles to randomize */
#define MAXNEIGHBORS 250 /* Maximum neighbors surrounding a large
particle */
void pkdFindLargeMasses(PKD,double,double,double,double,PARTICLE *p,double *,int *);
void pkdGetNeighborParticles(PKD,double *,double,int,double,PARTICLE *p,double *,int *);
#endif
#endif /* COLLISIONS */
#endif