Parallel Programming - Single threaded version done
[matches/honours.git] / course / semester2 / pprog / assignment1 / nbody.h
1 #ifndef _NBODY_H
2 #define _NBODY_H
3
4 /**
5  * @file nbody.h
6  * @author Sam Moore (205030628)
7  * @purpose N-Body simulator: declarations of simulation related parameters
8  */
9
10 #define M_PI        3.14159265358979323846264338327950288   /* pi */
11 #define G 6.67428E-11
12 #define DELTA_T 0.05
13 #define DIMENSIONS 3
14 #define square(x) ((x)*(x))
15
16
17 /**
18  * Structure to represent a single Body
19  * @param mass - Mass of the body
20  * @param x - Position vector (array)
21  * @param v - Velocity vector (array)
22  * @param F - Net force vector (array)
23  */
24 typedef struct 
25 {
26
27         double mass;
28         double x[DIMENSIONS];
29         double v[DIMENSIONS];
30         double F[DIMENSIONS];
31
32 } Body;
33
34 /**
35  * Structure to store an array of bodies, along with the size of the array.
36  * The universe is represented in a single System. 
37  * @param N - Size of the array
38  * @param body - The array of bodies
39  */
40 typedef struct
41 {
42         unsigned N;
43         Body * body;
44
45 } System;
46
47 void Body_Print(Body * a); //Print body a
48 void Body_Force(Body * a, System * s); //Compute force on body a due to system of bodies s
49 void Body_Velocity(Body * a); //Compute velocity of body a
50 void Body_Position(Body * a); //Compute position of body a
51
52 void System_Init(System * s, char * fileName); //Initialise System (array of bodies) from a text file
53
54 void System_Compute(System * system); //Perform a single computation step for a System of bodies
55
56 extern System universe; // The main array of bodies; global variable.
57
58 #endif //_NBODY_H

UCC git Repository :: git.ucc.asn.au