A compact numerical exercise: the one-dimensional heat equation solved with an explicit finite-difference stencil, once serially and once with OpenMP, from the same code.
Written for a university assignment; kept public as a small, readable example of parallelising a stencil loop.
What it does
- Solves the heat equation on a line of
nxpoints, starting from a hot spot in the middle. - Ships
solve_serialandsolve_parallelbehind the same header and call signature, so the two implementations differ only in how the loops are scheduled. - The parallel version spreads both the update and the write-back across threads with
#pragma omp parallel for. - A plain Makefile builds
bin/heat_solver; Devbox pins the compiler and OpenMP runtime.
Build and run
devbox shell # optional
make
./bin/heat_solver
Without Devbox, any C++ compiler with OpenMP support works.
Layout
include/heat_solver.h interface
src/heat_solver.cpp serial and parallel solvers
src/main.cpp driver
Makefile
devbox.json
Scope
No dependencies beyond the compiler and OpenMP, no input formats and no solver options — the project exists to show the shape of a parallel stencil update, not to be a production PDE solver.