Skip to content
This repository has been archived by the owner on Jun 16, 2020. It is now read-only.
/ nbody Public archive

Barnes-Hut N-body simulation algorithm implementation

License

Notifications You must be signed in to change notification settings

masscry/nbody

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WARNING

Code has many issues, and almost no comments. It's usage may require some fixes to run on different machine.

nbody

Barnes-Hut N-body simulation algorithm implementation.

Requirements

  • OpenGL 3.3
  • OpenMP 2.0
  • freeglut
  • glew
  • glm

Brief introduction

This is implementation of classical Barnes-Hut N-body simulation algorithm.

All particles has mass of 1 kg, G constant increased for faster simulation.

Particles rendering uses point sprite technique. Shaders are used to change particle size according to distance from camera.

Sources

  • nbody.cpp - main entry point, OpenGL rendering related stuff, and overall management.
  • octree.hpp - octree implementation to be used in Barnes-Hut algorithm.
  • resources.inl - shader releated stuff.

Implementation details

  • Simulation processed with constant time step on each glutIdleFunc invocation. After each world update, screen redraw requested. (see nbody.cpp onIdle function)
  • No optimization techniques are used to ease octree building, because time to build it from scratch in negligible in comparison with time spent in ocleaf_t::GetForceOnPoint function - 99% of simulation time program sits in ocleaf_t::GetForceOnPoint.

Configuration flags

There are some configuration flags in program, which affects simulation and its presentation:

  • BRUTE_FORCE - when defined, simulation uses brute-force N^2 algorithm
  • DEBUG_OCTREE - when defined, octree leaves with particles inside are drawn.
  • WND_MODE - when defined, simulation runs in windowed mode, otherwise in fullscreen 1920x1080.
  • USE_CUDA - when defined uses CUDA to run simulation using brute-force N^2 algorithm

About

Barnes-Hut N-body simulation algorithm implementation

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published