Load Balancing: Particle Exercise with multiple types of particles
This exercise is an extension of Random Migrating Particles. You will use your code from the previous exercise and extend it to do load balancing and visualization using LiveViz. Previously the particles moved randomly. There was no prominent load imbalance between chare array elements. Now we will create load imbalance between chares by coloring the particles, moving them at different speeds, and changing their initial distribution.
- The particles will have three colors: blue, red, and green. To represent this, you need to add a variable to the Particle object.
- To make particles move at different speeds, add a constant speed factor to the perturb function depending on the color of the objects. Change the range of blue particles to half, red particles will have the full range (so they will move faster), and green particles will move at one-quarter speed.
- You are also required to change the initial distribution of the particles depending on the color. In the beginning green particles will be distributed to the right upper triangle, blue particles will be on the left lower triangle of the cell, and red particles will be in the middle square. Chare array elements having red particles will have 2*particlesPerCell number of particles per cell and the rest of the chare array elements will have particlesPerCell number of elements where particlesPerCell is a command line argument.
- This will result in chares along the diagonal generating both green and blue particles in their bounding box. Thus, they will have 2*particlesPerCell. Additionally, chares along the diagonal inside the red box will generate red particles in addition to the green and blue chares. In total they will have 4 * particlesPerCell (1 (for Green) + 1 (for Blue) + 2 (for Red) * particlesPerCell). The other chares in the red box not on the diagonal will generate both red and green or blue particles. Their total will be 3 * particlesPerCell (2 (Red) + 1 (Green or Blue) * particlesPerCell).