![]() |
|
MercuryDPM can run simulations in parallel using MPI. The algorithm uses a simple domain decomposition, splitting the domain into \(n_x \times n_y \times n_z\) subdomains and running each subdomain on a separate processor.
To run simulations in parallel, you need to define all particles in setupInitialConditions and you need to define the domain size in main(). Generally, you should structure your driver code as follows:
To run your simulation in parallel, you need to compile the code with MPI. Use cmake and turn the flag MercuryDPM_USE_MPI to ON. You can do this either by loading cmake-gui and changing the use USE_MPI flag to ON; or, alternatively you do it on the command line:
You also need to tell your program about the decomposition it should use. To split your domain setNumberOfDomains into \(n_x \times n_y \times n_z\), add the following command in your main function, before solve():
Now compile your code, and run it with mpirun. Make sure you use the correct number of processors ( \(n=n_x \cdot n_y \cdot n_z\)) needed for the domain decomposition:
For an example of an MPI-ready code, see Drivers/ParallelDrum/testDrum.cpp.