- This project models the 1D wave equation using MPI (Message Passing Interface) for parallel computation.
- The main goal is to demonstrate how distributed-memory parallelism can be used to solve partial differential equations (PDEs) like the wave equation efficiently.
- The software is currently being refactored into Modern and modular form.
- The parallel strategy used is Domain Decomposition.
- The problem (global domain) is decomposed into sub-domains (smaller processes). "Workers" in the sub-domains perform the calculations and then communicate the results with the master (global domain). This link provides a basic example behind the Master/Slave concept.
- Each process updates its section of the domain independently but must exchange "ghost" cell data to compute spatial derivatives.
- Reduces the memory usage per process.
- Enables concurrent computations.
- Minimises idle time by overlapping computatiion and communication.
-
The Wave Equation takes the form:
Utt = c^2*Uxx -
Uttis the 2nd time derivative of thedisplacement field. -
Uxxis the 2nd spacial derivative of thedisplacement field. -
The 1D version of the Wave Equation is:
d^2 u/dt^2 - c^2 * d^2 u/dx^2 = 0 c is the speed of the wave, u is the displacement (field), t is time and x is the spatial component of the wave. space-interval: [x1, x2] time-interval: [t1, t2] Initial Conditions u(x,t1) = u_t1(x); u(x,0) = g(x,t=0) = sin(2*pi*(x-c*t)) u(x,t1) = ut_t1(x); dudt(x,0) = h(x,t=0) = -2*pi*c*cos(2*pi*(x-c*t)) -
Boundary (Dirichlet) conditions:
u(x1,t) = u_x1(t); u(0,t) = u0(t) = sin(2*pi*(0-c*t)) u(x2,t) = u_x2(t); u(1,t) = u1(t) = sin(2*pi*(1-c*t)) -
Discretized version of the wave equation:
uxx = (u(x+dx,t) - 2u(x,t) + u(x-dx,t))/dx^2 utt = (u(x,t+dt) - 2u(x,t) + u(x,t-dt))/dt^2 -
After some algebra and simplification, we end up with the final finite difference equation:
u(i,n+1) = -u(i,n-1) + 2u(i,n) + CFL^2(u(i+1,n) - 2u(i,n) + u(i-1,n)),
where n represents the nodes in the time direction and i represents the nodes in the spacial direction.
-
In the last equation, the term
CFLwas introduced. This represents theCourant–Friedrichs–Lewy condition. -
It takes the form:
CFL = c*dt/dx,
where c is the wave speed, dx the spacial step and dt the time step.
-
This condition ensures that every node in the discretized mesh is calculated.
-
The value of
CFLneeds to be in range:0.5 < CFL < 1 -
If we have:
CFL > 1,
then nodes will be missed and the solution will not be smooth and becomes unstable leading to errors.
- Operating Systems:
Ubuntu 20.04. - Compiler:
mpicc. MPICCsoMPIcan be used.- Text Editor. Any can be used. E.g.
Visual Studio Code,Vim,Emacs,geditetc.
MPIcan be downloaded here or at the command line using Ubuntu's package manager:
$ sudo apt-get install mpich
- A smaller version of the software can be found in the
testsdirectory for unit testing purposes. - No results are produced, only the functions
update()andcollect(), which are tested. - The software was tested on
2 processors.
$ make test$ mpirun -np 2 ./test- Once happy, clean up the directory. I.e. get rid of the binary file and the
.ofiles. $ make clean
- TODO: New instructions to be added once the new software has been developed.
- TODO: new results to be generate; a
Pythonscript which plots thecomputed u(x)and theu_exact(x)values for processor numbers;1,2,3 & 4.