1 | /****************************************************************************/ |
---|
2 | /* TREEDEFS.H: include file for hierarchical force calculation routines. */ |
---|
3 | /* These definitions are needed for treeload.c and treegrav.c, but this */ |
---|
4 | /* file does not provide definitions for other parts of the N-body code. */ |
---|
5 | /* Copyright (c) 1999 by Joshua E. Barnes, Tokyo, JAPAN. */ |
---|
6 | /****************************************************************************/ |
---|
7 | |
---|
8 | #ifndef _treedefs_h |
---|
9 | #define _treedefs_h |
---|
10 | |
---|
11 | /* |
---|
12 | * NODE: data common to BODY and CELL structures. |
---|
13 | */ |
---|
14 | |
---|
15 | typedef struct _node { |
---|
16 | short type; /* code for node type */ |
---|
17 | bool update; /* status in force calc */ |
---|
18 | real mass; /* total mass of node */ |
---|
19 | vector pos; /* position of node */ |
---|
20 | struct _node *next; /* link to next force calc */ |
---|
21 | } node, *nodeptr; |
---|
22 | |
---|
23 | #define Type(x) (((nodeptr) (x))->type) |
---|
24 | #define Update(x) (((nodeptr) (x))->update) |
---|
25 | #define Mass(x) (((nodeptr) (x))->mass) |
---|
26 | #define Pos(x) (((nodeptr) (x))->pos) |
---|
27 | #define Next(x) (((nodeptr) (x))->next) |
---|
28 | |
---|
29 | #define BODY 01 /* type code for bodies */ |
---|
30 | #define CELL 02 /* type code for cells */ |
---|
31 | |
---|
32 | /* |
---|
33 | * BODY: data structure used to represent particles. |
---|
34 | */ |
---|
35 | |
---|
36 | typedef struct { |
---|
37 | node bodynode; /* data common to all nodes */ |
---|
38 | vector vel; /* velocity of body */ |
---|
39 | vector acc; /* acceleration of body */ |
---|
40 | real phi; /* potential at body */ |
---|
41 | } body, *bodyptr; |
---|
42 | |
---|
43 | #define Vel(x) (((bodyptr) (x))->vel) |
---|
44 | #define Acc(x) (((bodyptr) (x))->acc) |
---|
45 | #define Phi(x) (((bodyptr) (x))->phi) |
---|
46 | |
---|
47 | /* |
---|
48 | * CELL: structure used to represent internal nodes of tree. |
---|
49 | */ |
---|
50 | |
---|
51 | #define NSUB (1 << NDIM) /* subcells per cell */ |
---|
52 | |
---|
53 | typedef struct { |
---|
54 | node cellnode; /* data common to all nodes */ |
---|
55 | #if !defined(QUICKSCAN) |
---|
56 | real rcrit2; /* critical c-of-m radius^2 */ |
---|
57 | #endif |
---|
58 | nodeptr more; /* link to first descendent */ |
---|
59 | union { |
---|
60 | nodeptr subp[NSUB]; /* descendents of cell */ |
---|
61 | matrix quad; /* quad. moment of cell */ |
---|
62 | } sorq; |
---|
63 | } cell, *cellptr; |
---|
64 | |
---|
65 | #if !defined(QUICKSCAN) |
---|
66 | #define Rcrit2(x) (((cellptr) (x))->rcrit2) |
---|
67 | #endif |
---|
68 | |
---|
69 | #define More(x) (((cellptr) (x))->more) |
---|
70 | #define Subp(x) (((cellptr) (x))->sorq.subp) |
---|
71 | #define Quad(x) (((cellptr) (x))->sorq.quad) |
---|
72 | |
---|
73 | /* |
---|
74 | * GLOBAL: pseudo-keyword for storage class. |
---|
75 | */ |
---|
76 | |
---|
77 | #if !defined(global) |
---|
78 | # define global extern |
---|
79 | #endif |
---|
80 | |
---|
81 | /* |
---|
82 | * Parameters for tree construction and force calculation. |
---|
83 | */ |
---|
84 | |
---|
85 | #if !defined(QUICKSCAN) |
---|
86 | global real theta; /* force accuracy parameter */ |
---|
87 | #endif |
---|
88 | |
---|
89 | global string options; /* various option keywords */ |
---|
90 | |
---|
91 | global bool usequad; /* use quadrupole corrections */ |
---|
92 | |
---|
93 | global real eps; /* density smoothing parameter */ |
---|
94 | |
---|
95 | global double einit; |
---|
96 | |
---|
97 | |
---|
98 | /* |
---|
99 | * Tree construction. |
---|
100 | */ |
---|
101 | |
---|
102 | void maketree(bodyptr, int); /* construct tree structure */ |
---|
103 | |
---|
104 | global cellptr root; /* pointer to root cell */ |
---|
105 | global real rsize; /* side-length of root cell */ |
---|
106 | global int ncell; /* count of cells in tree */ |
---|
107 | global int tdepth; /* count of levels in tree */ |
---|
108 | global real cputree; /* CPU time to build tree */ |
---|
109 | |
---|
110 | /* |
---|
111 | * Force calculation. |
---|
112 | */ |
---|
113 | |
---|
114 | void gravcalc(void); /* update force on bodies */ |
---|
115 | |
---|
116 | global int actmax; /* maximum length of active list */ |
---|
117 | global int nbbcalc; /* total body-body interactions */ |
---|
118 | global int nbccalc; /* total body-cell interactions */ |
---|
119 | global real cpuforce; /* CPU time for force calc */ |
---|
120 | |
---|
121 | #endif /* ! _treedefs_h */ |
---|