6 * @author Sam Moore (205030628)
7 * @purpose N-Body simulator: declarations of simulation related parameters
15 #define M_PI 3.14159265358979323846264338327950288 /* pi */
19 #define square(x) ((x)*(x))
23 * Structure to represent a single Body
24 * @param mass - Mass of the body
25 * @param x - Position vector (array)
26 * @param v - Velocity vector (array)
27 * @param F - Net force vector (array)
40 * Structure to store an array of bodies, along with the size of the array.
41 * The universe is represented in a single System.
42 * @param N - Size of the array
43 * @param body - The array of bodies
52 void Body_Print(Body * a); //Print body a
53 void Body_Force(Body * a, System * s); //Compute force on body a due to system of bodies s
54 void Body_Velocity(Body * a); //Compute velocity of body a
55 void Body_Position(Body * a); //Compute position of body a
57 void System_Init(System * s, char * fileName); //Initialise System (array of bodies) from a text file
59 void System_Compute(System * system); //Perform a single computation step for a System of bodies
60 void Universe_Cleanup();
62 extern System universe; // The main array of bodies; global variable.
66 * Multithreading stuff below here
69 extern pthread_t compute_thread; // ID of the thread that runs Compute_Thread. Set in main()
70 void * Compute_Thread(void * system); //Thread - Continuously perform computations for a System of bodies
72 extern bool terminate; //Will be set to true by main thread to signal children to terminate. Child threads are responsible for checking.
73 extern pthread_mutex_t mutex_terminate; //Mutex around the "terminate" variable