The objective of this coursework assignment is to write a parallel numerical code to solve the 2D shallow-water equations. These partial differential equations (PDE) can be used to model, for example, the propagation of tsunamis.
where
Finite difference method is adopted in order to numerically solve this problem. For spatial derivative terms, a 6th order central difference stencil was used, the algorithm is shown as below:
Similar expressions can be constructed for other derivatives. The PDE should be discretised on a periodic rectan-
gular grid of size
For the time-integration we will use 4th-order Runge-Kutta explicit scheme. This can be formulated as:
with
Rearrange Equations (1)-(3) to put all but the time derivative terms on the right-hand side. The function f
above is therefore used to evaluate the discrete approximation to these time derivatives by computing these right-
hand side terms in discrete form. The bulk of the operations are accounted for by the numerical approximations to
the derivatives. In this simulation, the user will be able to enter command line input (--choice) to choose whether to construct the spatial derivative terms using a
The simulation uses the following initial conditions:
where
Periodic boundary conditions should be used on all boundaries, so that waves which propagate out of one of the
boundaries re-enter on the opposite boundary. This means that, for example, with
The repository include a Makefile we make ease when compiling the program. It also incorporates parallelisation using openMP with highest level optimise -Wall -o3. A sample command line input is as such,
export OMP_NUM_THREAD=8 ./main --dt 0.1 --T 80 --Nx 100 --Ny --100 --ic 4 --choice 1
where export OMP_NUM_THREAD=8 sets the environment of the number of threads computing.