Parallel Programming - Work on pthreaded version
[matches/honours.git] / course / semester2 / pprog / assignment1 / single-thread / 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 SINGLE_THREADED
11
12 #define M_PI        3.14159265358979323846264338327950288   /* pi */
13 #define G 6.67428E-11
14 #define DELTA_T 0.05
15 #define DIMENSIONS 3
16 #define square(x) ((x)*(x))
17
18
19 /**
20  * Structure to represent a single Body
21  * @param mass - Mass of the body
22  * @param x - Position vector (array)
23  * @param v - Velocity vector (array)
24  * @param F - Net force vector (array)
25  */
26 typedef struct 
27 {
28
29         double mass;
30         double x[DIMENSIONS];
31         double v[DIMENSIONS];
32         double F[DIMENSIONS];
33
34 } Body;
35
36 /**
37  * Structure to store an array of bodies, along with the size of the array.
38  * The universe is represented in a single System. 
39  * @param N - Size of the array
40  * @param body - The array of bodies
41  */
42 typedef struct
43 {
44         unsigned N;
45         Body * body;
46
47 } System;
48
49 void Body_Print(Body * a); //Print body a
50 void Body_Force(Body * a, System * s); //Compute force on body a due to system of bodies s
51 void Body_Velocity(Body * a); //Compute velocity of body a
52 void Body_Position(Body * a); //Compute position of body a
53
54 void System_Init(System * s, char * fileName); //Initialise System (array of bodies) from a text file
55
56 void System_Compute(System * system); //Perform a single computation step for a System of bodies
57
58 void Universe_Cleanup();
59
60
61 extern System universe; // The main array of bodies; global variable.
62
63 #endif //_NBODY_H

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