Coder Social home page Coder Social logo

adamsimpson / sph Goto Github PK

View Code? Open in Web Editor NEW
24.0 4.0 29.0 16.11 MB

Interactive parallel fluid dynamics

C 66.00% Makefile 4.25% Shell 0.86% C++ 14.38% Objective-C 0.29% C# 1.15% Python 1.12% HTML 0.56% JavaScript 0.42% CSS 0.26% Perl 3.17% GLSL 3.18% M4 3.39% Roff 0.97%

sph's Introduction

TinySPH

TinySPH is a parallel 2D Smoothed Particle Hydrodynamics(SPH) code, designed to run in real time on the Oak Ridge Leadership Computing Facility's "Tiny Titan" Raspberry Pi cluster. This application was designed to demonstrate distributed computing concepts and while it works best in a distributed environment it is possible to run on a shared memory system such as a single multicore processor. Although the code is designed for Tiny Titan it should, perhaps with some small build tweaks, compile and run on various flavors of Linux and OS X. The code makes use of MPI for distributed computing and requires at least two mpi processes(1 render, 1 compute).

If you find this code useful, find a bug, or use this code in an interesting way i'd love to hear about it, drop me a line at [email protected] and let me know!

Screenshot

The screenshot below shows TinySPH running on a four core MacBook Pro, running with 7 compute MPI processes and 1 MPI render process. The default rendering mode shows a reconstructed liquid surface.

alt text

With the surface reconstruction removed the underlying physics simulation can be better viewed, showing SPH's particle nature. The color of the particle indicates which processor core is responsable for it. TinySPH includes a simple number of particle based load balancing scheme.

alt text

Install

Several prerequisites are required before compiling the code. In a Linux environment, such as Raspian, these may be obtained using your distros package management system. On Macintosh it is recomended that Homebrew be used.

Macintosh

It is assumed that the XCode toolchain has been installed, this is freely available from Apple . Once Homebrew has been installed The following commands may be run in Terminal.app to setup the prerequisties.

$ brew install mpich
$ brew install homebrew/versions/glfw3
$ brew install glew
$ brew install freetype

Raspberry Pi

On the RaspberryPi the following packages must be installed, all of which are availble through apt-get. If you used the TinySetup scripts these should already be installed

$ sudo apt-get install mpich
$ sudo apt-get install libglew-dev

Compile and run

Once the prerequisites have been installed TitanSPH can be compiled and run.

Macintosh

To compile

$ make -f makefile_macos

To run on a 4 core single socket computer:

$ mpirun -n 4 ./bin/sph.out

Raspbery Pi

To Compile

$ make

To run on TinyTitan

$ make run

Controls

The input controls are set in GLFW_utils.c and EGL_utils.c for GLFW and Raspberry Pi platforms respectively. The Pi's controls are based upon using an XBox controller to handle input.

Although subject to change generally keys should operate as follows:

  • The esc key exists the simulation under macOS. On other platform esc toggles the exit menu, hover the oak leaf over the terminal image and press a to exit.

  • Arrow keys should change the paramaters in the top left of the screen

  • The mouse controlls the mover sphere

  • a,b,x,y are fluid parameter presets

  • on Mac [ ] controls the number of processes while on the Pi it is page up and page down.

  • l toggles between particle and liquid surface rendering methods

If the keyboard input for the RaspberyPi doesn't work you may need to correctly set /dev/input/event# in get_key_press() in egl_util.c

Code

If you wish the modify the code here are a few things to keep in mind

  • main() lives in fluid.c ~line 37
  • The main computation loop lives in fluid.c ~lines 236
  • Initial parameters are largely set in fluid.c starting ~line 78
  • The shaders directory contains OpenGL and OpenGL ES 2.0 shaders
  • files with suffix _gl control OpenGL rendering

Algorithm

The SPH algorithm is based upon the work of Clavet et al.. To run in real time on the Raspberry Pi a large timestep was neccessary as communication is extremely expensive. Several modifcations have been made to make the algorithm work on the RaspberryPi.

  • 2D was used instead of 3D.
  • The algorithm was parallelized, the prediction-relaxation algorithm does not have a trivial parallelization scheme.
  • The algorithm was completely symmetrized to reduce computation/hash cost.
  • Plasticity is not used.

sph's People

Contributors

adamsimpson avatar anthonydigirolamo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

sph's Issues

make run success but no visuals

I have tried to set p a 2 node rpi cluster. Followed the steps from TinyTitan to setup. Did the EGL and GLES links using ln command.

I am not having any errors but their is no visual of the SPH as shown in screenshots when i do 'make run'

Attaching a screenshot of the output. (i have also been waiting for something to come up for a long time tho, >20min
Capture
)

Error on RasPi3 B+ cluster

Dear developers,

I try to run your SPH in our RasPi3 B+ cluster. OS is the lastest Raspbian, version number is 9.4 (/etc/debian_version).

But when executing it, the following error occurs.

$ mpirun -np 2 ./bin/sph.out
compute rank: 0, num compute procs: 1
libEGL warning: DRI2: failed to authenticate
sph.out: egl_utils.c:171: init_ogl: Assertion state->surface != EGL_NO_SURFACE failed.

Do you know the cause of the error?

Thanks,

Colors not melting effectively

Dear SPH Consultant,

When compiling with PGI 14.2.0 using --colors-melt, I notice that the colors do not melt effectively. Please kindly consider rebuilding this with a corrected version of the color melting algorithm.

Just a suggestion.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.