examples/charm++/barnes-charm: renamed variable in prototype to avoid compiler confusion
[charm.git] / examples / charm++ / Molecular / common.h
1 /*
2  University of Illinois at Urbana-Champaign
3  Department of Computer Science
4  Parallel Programming Lab
5  2008
6 */
7
8 #ifndef __COMMON_H__
9 #define __COMMON_H__
10
11 #define DEFAULT_MASS 1
12 #define DEFAULT_DELTA 0.005
13 #define DEFAULT_PARTICLES 2000
14 #define DEFAULT_M 5
15 #define DEFAULT_N 5
16 #define DEFAULT_L 10
17 #define DEFAULT_RADIUS 5
18 #define DEFAULT_FINALSTEPCOUNT 10000
19 #define MAX_VELOCITY 30.0
20
21 // Class for keeping track of the properties for a particle
22 class Particle{
23         public:
24                 double mass;                                                    // mass of the particle
25                 double x;                                                                       // position in x axis
26                 double y;                                                                       // position in y axis
27                 double fx;                                                              // total forces on x axis
28                 double fy;                                                              // total forces on y axis
29                 double ax;                                                              // acceleration on x axis
30                 double ay;                                                              // acceleration on y axis
31                 double vx;                                                              // velocity on x axis
32                 double vy;                                                              // velocity on y axis
33
34     int id;
35         // Default constructor
36         Particle(){
37                 fx = fy = 0.0;
38         }
39
40                 // Function for pupping properties
41                 void pup(PUP::er &p) {
42                         p | mass;
43                         p | x;
44                         p | y;
45                         p | fx;
46                         p | fy;
47                         p | ax;
48                         p | ay;
49                         p | vx;
50                         p | vy;
51       p | id;
52                 }
53
54 };
55
56 class Color {
57 public:
58         unsigned char R, G, B;
59
60         /// Generate a unique color for each index from 0 to total-1
61         Color(int index){
62     int total = 8;
63                 if(index % total == 0){
64                         R = 255;
65                         G = 100;
66                         B = 100;
67                 } else if(index % total == 1){
68                         R = 100;
69                         G = 255;
70                         B = 100;
71                 } else if(index % total == 2){
72                         R = 100;
73                         G = 100;
74                         B = 255;
75                 } else if(index % total == 3){
76                         R = 100;
77                         G = 255;
78                         B = 255;
79                 } else if(index % total == 4){
80                         R = 100;
81                         G = 255;
82                         B = 255;
83                 } else if(index % total == 5){
84                         R = 255;
85                         G = 255;
86                         B = 100;
87                 } else if(index % total == 6){
88                         R = 255;
89                         G = 100;
90                         B = 255;
91                 } else {
92                         R = 170;
93                         G = 170;
94                         B = 170;
95                 }
96         }
97
98         
99 };
100
101 #endif