Skip to content

tunabrain/gpu-fluid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fluid

OpenGL GPU Fluid Solver

This project implements a 2D fluid solver completely on the GPU using OpenGL 4.3.

The solver features a marker-and-cell grid, vorticity confinement, fluid implicit particle, 3rd order Runge-Kutta advection, a conjugate gradient solver with incomplete Poisson preconditioner, and a heat diffusion/buoyancy model.

Videos rendered with this code:

Compilation

Compilation requires freeglut and a recent version of GLEW. The makefile in the repository should work on Windows (tested with MinGW) and Linux.

Usage

A recent GPU with fresh drivers is necessary to run this application. Support for OpenGL 4.3 core profile is required. Tested on a GTX480.

When run, the program will open a graphics window and display a preview of the current simulation progress. If the macro RECORD_FRAMES in Main.cpp is set, the program will save out the individual frames as pngs using lodepng.

Note that the window resolution is independent of the fluid resolution; they are controlled individually using the constants GWidth/GHeight for the graphics window and FWidth/FHeight for the fluid grid resolution in Main.cpp. This is to allow for fluid resolutions much larger than the screen resolution. Frames will always be saved at the fluid resolution.

Code

Main.cpp controls the application setup and invokes the fluid solver. Fluid.cpp, along with all the shader files, performs all of the fluid related work. All the remaining files are utilities to deal with OpenGL.

Scene setup and inflows are controlled in Fluid::initScene and at the end of Fluid::update. These can be modified to get more interesting looking simulations.

About

High performance OpenGL fluid solver in C++

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published