Line | |
---|
1 | /* SolarSim.h */ |
---|
2 | #include <stdio.h> |
---|
3 | #include <stdlib.h> |
---|
4 | #include <string.h> |
---|
5 | #include <math.h> |
---|
6 | #include <fcntl.h> |
---|
7 | #include <omp.h> |
---|
8 | |
---|
9 | #if __INTEL_COMPILER |
---|
10 | #include <pmmintrin.h> |
---|
11 | #endif |
---|
12 | |
---|
13 | #define _SINGLE_PRECISION_ |
---|
14 | //#define _DOUBLE_PRECISION_ |
---|
15 | |
---|
16 | #if defined _DOUBLE_PRECISION_ |
---|
17 | typedef double real; |
---|
18 | #elif defined _SINGLE_PRECISION_ |
---|
19 | typedef float real; |
---|
20 | #else |
---|
21 | #error "Must have either _DOUBLE_PRECISION_ or _SINGLE_PRECISION_ defined." |
---|
22 | #endif |
---|
23 | |
---|
24 | /* simulation constants */ |
---|
25 | #define G 6.6743E-11 // m^3 kg^-1 s^-2 |
---|
26 | |
---|
27 | typedef struct vector { |
---|
28 | real x, y, z; |
---|
29 | real unused; |
---|
30 | } vector; |
---|
31 | |
---|
32 | typedef struct state { |
---|
33 | int particles; |
---|
34 | vector * positions; |
---|
35 | vector * velocities; |
---|
36 | vector * accelerations; |
---|
37 | real * masses; |
---|
38 | } TState, *AState; |
---|
39 | |
---|
40 | /* declared in "io.c" */ |
---|
41 | void read_initial( AState state, const char *filename ); |
---|
42 | void rand_data( AState state, int nParticles ); |
---|
43 | |
---|
44 | int connect_to_server( char * servername, int portno, int protocol ); |
---|
45 | |
---|
46 | void send_state( int sock, AState state ); |
---|
47 | |
---|
48 | void write_state( int fd, AState state ); |
---|
49 | |
---|
50 | /* declared in "compute.c" */ |
---|
51 | inline void compute_acc( vector *rv1, vector *rv2, vector *vv1, vector *vv2, vector *av1, vector *av2, real m1, real m2 ); |
---|
52 | |
---|
53 | inline void update_pos_vel( vector *rv, vector *vv, vector *av, long DT ); |
---|
54 | |
---|
55 | inline void v_init( vector *v, real x, real y, real z ); |
---|
56 | |
---|
Note: See
TracBrowser
for help on using the repository browser.