Skip to content

JAChapmanII/barnes-hut

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is a threaded implementation of the Barnes-Hut algorithm, as it would need
to be implmented if I were in Analysis of Algorithms. Meant to give me
experience for when I try to do something similar (unless this works out to be
what I was thinking the fast multipole method was) in Universum Meum.

Compile:
	To compile, you will need the Qt library for threading support
	To compile without SFML GUI:
		make
	To compile with SFML GUI:
		make gui=yes

	To switch between GUI/non GUI versions you must
		make clean between them
	It is possible to run the GUI compiled version without opening any windows

Run:
	./bin/barnes-hut [filename] [tau] [arg4] [arg5]
	If you do not specify a file containing the initial particle descriptions,
	this program will prompt you to spceify the file on stdin. If you do not
	specify a tau value, 0.5 will be assumed.

	arg4 is a special arg that makes the program print the particle system after
	running the Barnes-Hut algorithm to stdout

	arg5 is a special arg that makes the program display the quadtree after
	running the Barnes-Hut algorithm if it was compiled with gui=yes

	When run this way, this program creates 4 worker threads to split up the work
	of applying the Barnes-Hut algorithm to particles in the system.

	-- THIS IS NOT SUGGESTED FOR END USERS --
	If any argument after tau is "-t", then the program will run a test of the
	root mean square error.
	Run this way, the program currently tries to divide the problem space
	and do it in chunks that are saved in between. Each calculation uses the
	multithreaded Barnes-Hut algorithm for speed.
	-- THIS IS NOT SUGGESTED FOR END USERS --

Input/output format:
	Input format should be a series of lines with three floats on each line. The
	first float will be used as the x, the next y, and the final will be mass.
	Technically, white space doesn't matter but it looks better ;)

	The output will be the same as the input, except on each line the
	instantaneous x and y forces will be appended

Warning:
	I haven't done much file IO, so don't run this on something you don't want to
	turn into a radioactive sheep-cheese. (it has been tested repeatedly, and it
	hasn't done this up to this point, still, don't run it on anything not in the
	right format)

License:
	GPL3, see COPYING

Notes:
	Pay attention to compiler warnings about using == and != on floating point
	values if you ever make something like this!

About

Implementation of the Barnes-Hut algorithm in C++

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages