Skip to content

🌌 High-Performance N-Body Simulation with CUDA and Barnes-Hut Algorithm. 一个努力的,一个延续了近二百个文明的努力,为解决三体问题的努力,寻找太阳运行规律的努力。

License

Notifications You must be signed in to change notification settings

plumBinng/StellarSolver

 
 

Repository files navigation

StellarSolver: High-Performance N-Body Simulation with CUDA and Barnes-Hut Algorithm

Overview

StellarSolver is a comprehensive tool designed for simulating the n-body problem, utilizing the Barnes-Hut algorithm powered by CUDA. The project provides visualization through OpenGL, following Nvidia's CUDA toolkit examples. Currently, the visualization process is executed by the host, transferring data back at each time-step without utilizing CUDA-OpenGL interoperability due to system restrictions during development.

Prerequisites

StellarSolver necessitates the installation of Nvidia's CUDA toolkit on a system with a CUDA-capable device and a GCC compiler. The visualization component uses OpenGL, SFML, GLEW (OpenGL Extension Wrangler Library), and GLM (OpenGL Mathematics).

For CUDA installation, refer to the Nvidia CUDA download page and the CUDA Quick Start Guide. On Ubuntu, install SFML and GLEW by executing the following commands:

sudo apt-get install libsfml-dev
sudo apt-get install libglew-dev

GLM, a collection of header files, can be acquired here. Ensure to update the makefile INCLUDE variable to set the path to the GLM directory.

Compilation

To compile the code, execute the following commands:

make clean
make build

Execution

StellarSolver offers multiple command-line arguments for customization.

The standard execution of the Barnes-Hut algorithm with OpenGL visualization:

./app -barnes-hut -opengl

Execution with benchmark statistics for 500 iterations:

./app -barnes-hut -benchmark -iterations=500

Additional command-line options are detailed below:

  • -disk : Use a simple disk model (default).
  • -plummer : Use a Plummer model.
  • -colliding-disks : Use two colliding disks.
  • -opengl : Enable OpenGL visualization.
  • -benchmark : Output time statistics.
  • -debug : Run debug tests.
  • -iterations=<n> : Define the number of iterations (defaults to 50).
  • -gravity=<n> : Adjust the gravity parameter (defaults to 1.0).
  • -dampening=<n> : Adjust the velocity dampening parameter (defaults to 1.0).

Additional Notes

Ensure to manually match the 'numbodies' variable in main.cpp and the 'blockSize' variables in kernels.cu and particle_cuda.cu. For instance, if you set numbodies = 64*64 in main.cpp, also set blockSize = 64 in kernels.cu, and blockSize = 64, gridSize = 64 in particle_cuda.cu.

About

🌌 High-Performance N-Body Simulation with CUDA and Barnes-Hut Algorithm. 一个努力的,一个延续了近二百个文明的努力,为解决三体问题的努力,寻找太阳运行规律的努力。

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 68.0%
  • Cuda 29.6%
  • Makefile 1.8%
  • C 0.6%