FDTD OpenMP is a project I built in order to practice HPC concepts and C design patterns. It's a C library for one-dimensional electromagnetic wave simulation using the finite-difference time-domain (FDTD) method, accelerated with OpenMP. It's the sister project of FDTD CUDA, which extends the simulation to two dimensions and adds GPU acceleration.
The simulation updates one electric field component (Ez) and one magnetic field component (Hy) on a Yee grid. Material properties control how waves propagate through different regions, and source callbacks introduce Gaussian pulses or sinusoidal waves. A perfectly matched layer (PML) absorbs outgoing waves at the edges of the grid, while a reflecting boundary lets them travel back through the simulation.
The same simulation can run with a serial kernel or an OpenMP kernel. The parallel version distributes the field updates among threads and synchronizes them between phases. One parallel region encloses all time steps, keeping the thread team active throughout the run. The benchmark program compares execution times across grid sizes and thread counts, with plots of throughput, speedup, and parallel efficiency.
The project includes a command-line simulation driver and Python plotting scripts. The grid state can be saved as CSV, plotted, or loaded to continue a simulation. For example, the following command runs a 200-cell grid for 200 steps using OpenMP, with a Gaussian pulse and a 20-cell absorbing layer at each end:
$ dist/bin/fdtd \ --set-width=200 \ --set-pml=20 \ --set-accel=openmp \ --add-pulse \ --run=200 \ simulation.csv