Skip to content
Redirecting to exemplar docs...

RECODE-SPH-SOLVER-2D-NS

C++ Boost Python

sph_simulation
SPH simulation

Description

In this project we present a numerical code in C++ which solves the two-dimensional Navier-Stokes equations using the smoothed-particle hydrodynamics (SPH) approach. The focus lies in the implementation (and documentation) of good C++ practices and the development of skills related to efficient, robust, extensible and readable scientific code. The learning process regarding this project can be twofold:

1) The student can study the material provided in the main branch of the present repository. It is independent of all the other branches and can be used as a standalone educational resource. In this the implemented SPH methodology is explained as well as the structure of the source code and the post-processing scripts.

2) The student can start by studying progressively the branches v0 - v5 in order to experience the process which was followed in order to improve and optimize the herein code. Several comments have been added for each individual version in the corresponding branch to highlight the improvements which were implemented compared to its ancestors.

Learning Outcomes

  • I/O (input/output)
  • OOP (object-oriented programming)
  • C++ containers
  • Performance and memory optimization tools and skills
Task Time
Reading 15 hours
Practicing 10 hours

Requirements

Academic

  • Experience with basic programming concepts (for loops, functions, reading and writing files etc.).

  • Some experience with C++ (familiarity with pointers, C++ classes and the use of external libraries).

  • Basic understanding of numerical analysis concepts (time marching, temporal integration etc.)

System

For manual installation of the program and its dependencies, you will need the following:

  • Python 3.11 installed
  • A C++ toolchain along with the necessary development libraries:
    • build-essential
    • libboost-program-options-dev,
    • clang-format
    • cmake.

You will also need to install the required Python packages by running the command

  • "pip install -r requirements.txt."

If you haven't already, set up the pre-commit hook by executing the

  • "pre-commit install" command.

Following these steps manually will establish the environment necessary for the program to run successfully. Alternatively, to streamline the process, consider using the provided Dockerfile to create a Docker image and deploy the program in a containerized environment, or you can simply use the github codespaces functionality by following the instructions provided in the section GitHub Codespaces.

Getting Started

To better comprehend this exemplar, it's recommended to follow the outlined procedure by sequentially reviewing the chapters. The suggested workflow ensures a step-by-step understanding, beginning with the foundational SPH algorithm elucidated in the code (Smoothed-Particle Hydrodynamics (SPH)-Adaptive timestep), followed by an exploration of its implementation aspects (Code overview - Efficient programming). Once you've grasped the code intricacies, it's time to put it into action. In the sections Code execution - Profiling you will learn how to run the code, assess its performance and post process the data it generates. Depending on your learning preference, you may opt for a reversed approach, initiating with code execution and subsequently delving under the hood to explore the C++ code. It works both ways!

For additional study and practice, delve into Clang format, Building with Cmake and Exercises. These sections offer deeper insights into the project's good practices and provide opportunities to enhance your coding skills.

Project Structure

.
├── docs
│   ├── index.md
│   ├── 1.SPH.md
│   ├── 2.Code_Overview.md
│   ├── 3.IO_Overview.md
│   ├── 4.OOP_Concepts.md
│   ├── 5.STL.md
│   ├── 6.Efficient_Programming.md
│   ├── 7.Neighbour_Search.md
│   ├── 8.Adaptive_Timestep.md
│   ├── 9.Code_Execution.md
│   ├── 10.GH_Codespaces.md
│   ├── 11.Profiling.md
│   ├── 12.Post_Analysis.md
│   ├── A1.ClangFormat.md
│   ├── A2.CMake.md
│   └── B1.Exercises.md
├── exec
│   ├── build
│   └── input
│       ├── case.txt
│       ├── constants.txt
│       ├── domain.txt
│       ├── ic-block-drop.txt
│       ├── ic-droplet.txt
│       ├── ic-one-particles.txt
│       ├── ic-two-particles.txt
│       ├── ic-three-particles.txt
│       └── ic-four-particles.txt
├── notebooks
├── post
│   ├── plot_energies.ipynb
│   ├── plot_energies.py
│   ├── simulation_animation.ipynb
│   ├── simulation_animation.py
│   ├── visualise_particles.ipynb
│   └── visualise_particles.py
└── src
    ├── CMakeLists.txt
    ├── fluid.cpp
    ├── fluid.h
    ├── initial_conditions.cpp
    ├── initial_conditions.h
    ├── main_prog_funcs.h
    ├── particles.cpp
    ├── particles.h
    ├── SPH-main.cpp
    ├── sph_solver.cpp
    └── sph_solver.h
cmcooling
Chris Cooling
ChrisPetalotis
Christos Petalotis
kmichali
Katerina Michalickova
dc2917
Dan Cummins
ByronAV
Vyron Avramidis
Vasilis421
Vasileios Christou
geoefsta
George Efstathiou
ge420
George Efstathiou

License

This project is licensed under the BSD-3-Clause license