Repository for the project related to the "High Performance Scientific Computing in AeroSpace" course. The objective was to develop a high-performance solver for the incompressible Navier–Stokes equations, implemented in C++ using the finite differences method on a staggered mesh. To enhance computational efficiency, we employed a parallelization strategy combining MPI for velocity computations and a pressure solver that utilizes FFTW in conjunction with 2Decomp.
Compilation is handled by a Makefile that requires as dependencies:
- MPI
- FFTW3
We used mk modules by the MOX laboratory of Politecnico di Milano. You can find them here.
Then just run
makeThat will create the ./build directory with the executable.
To run the code you need to specify a path to a file with the inputs in the form of input file, where test case number is used to specify boundary conditions. Test 0 is reserved for error calculation, and can be run via:
cd build
mpirun -n X ./main ../input.in # Where X is number of processes Need to de-comment "#define ERROR" first and recompile
Test 1 & 2 represent a lid-driven cavity. More test can be implemented adding more boundary condition is the respective file following the schema, and creating an appropriate testN.in.
cd build
mpirun -n X ./main ../testN.inmake cleanComplications with 2 decomp compatibility lead to have only codes where every processor has the same number of points for pressure being able to run.
Outputs of simulation can be found in the results directory, where the .vtk files can be opened in paraview to show a plane dividing in half the domain for each direction, where you can see single velocity components, pressure or total velocity magnitude.
The test case 1 consists in a three-dimensional lid-driven cavity with Dirichlet boundary
conditions on all the 6 faces, where we fix the velocity on y axis to 1 and the other faces to 0. The result shown is a plane cutting the cube on z=0 of a simulation with 120x120x120
pressure points at 8 seconds.
Here we show the vortex created along the z plane in both velocity and pressure.
| Velocity | Pressure |
|---|---|
![]() |
![]() |
The test case 2 is a lid-driven where we have periodic boundaries in the z direction. The
result shown is a plane cutting the cube on z=0 of a simulation with 120x120x120 pressure
points at 20 seconds.
Here we show the vortex created along the z plane in both velocity and pressure.
| Velocity | Pressure |
|---|---|
![]() |
![]() |
Error has been measured on grids of increasing dimension and decreasing timestep with respect to CFL condition, results show convergence of grade 2 for velocity and around 1.5 for pressure:
| Velocity Convergence | Pressure Convergence |
|---|---|
![]() |
![]() |
Time scalability test were performed on an HPC cluster using up to 256 cores on a 320x320x320 grid:
| Strong Scalability | Speedup |
|---|---|
![]() |
![]() |
Additional documentation can be found in the doc directory.







