/* SolarSim.h */ #include #include #include #include #include #include #if __INTEL_COMPILER #include #endif #define _SINGLE_PRECISION_ //#define _DOUBLE_PRECISION_ #if defined _DOUBLE_PRECISION_ typedef double real; #elif defined _SINGLE_PRECISION_ typedef float real; #else #error "Must have either _DOUBLE_PRECISION_ or _SINGLE_PRECISION_ defined." #endif /* simulation constants */ #define G 6.6743E-11 // m^3 kg^-1 s^-2 typedef struct vector { real x, y, z; real unused; } vector; typedef struct state { int particles; vector * positions; vector * velocities; vector * accelerations; real * masses; } TState, *AState; /* declared in "io.c" */ void read_initial( AState state, const char *filename ); void rand_data( AState state, int nParticles ); int connect_to_server( char * servername, int portno, int protocol ); void send_state( int sock, AState state ); void write_state( int fd, AState state ); /* declared in "compute.c" */ inline void compute_acc( vector *rv1, vector *rv2, vector *vv1, vector *vv2, vector *av1, vector *av2, real m1, real m2 ); inline void update_pos_vel( vector *rv, vector *vv, vector *av, long DT ); inline void v_init( vector *v, real x, real y, real z );