Simple, single-file fluid solvers for learning purposes

Overview

Fluid

Incremental fluids

The purpose of this project is to provide simple, easy to understand fluid solver implementations in C++, together with code documentation, algorithm explanation and recommended reading. It is meant for people with beginner to intermediate knowledge of computational fluid dynamics looking for working reference implementations to run and study.

This project closely follows Robert Bridson's book, "Fluid Simulation for Computer Graphics", and implements a selection of the methods explained in the book. Ideally, you have a copy of the book sitting on your shelf, which will make it a lot easier to follow along with the code.

The solvers in this project come in a large variety, ranging from minimalistic to complex. All solvers are Eulerian in nature and run on a staggered Marker-and-Cell grid.

The different solvers are sorted into subfolders marked with a number and a short description. Each folder contains a small markdown file explaining the basic ideas behind the code and provides a list of recommended literature to read.

The number of the solver defines a progression - codes with higher number build on codes with lower number, either adding on features or replacing methods with better ones. The basic classes and concepts, however, always stay the same - ideally, you just start with the simplest solver and work your way through to understand and visually confirm the difference in simulation. Code is only explained once when it is introduced and not in any of the successing solvers to avoid clutter.

All solvers are single-file and require no external libraries apart from lodepng to save individual frames. Compilation should be straightforward on all platforms.

If you want, you can also check out a couple of videos rendered with code from this project (just ported to the GPU):

Issues
  • Regarding missing destructor in FluidSolver

    Regarding missing destructor in FluidSolver

    Hi, Just wanted to point out that there is a memory leak in the FluidSolver. The constructor allocates _d, _u, _v, _r and _p but there is no destructor that deallocates them. This is in 0-MatrixLess project thats where I have started at the moment. There should be a destructor for FluidSolver like so

    ~FluidSolver() { delete _d; delete _u; delete _v; delete [] _r; delete [] _p; }

    opened by mmmovania 1
  • Added Makefile

    Added Makefile

    Added a simple makefile. May be somewhat chaotic as I'm not too experienced with writing makefiles, but I structured it in a way that allows to somewhat easily add new "lessons" or whatever.

    opened by CounterPillow 0
  • Using a moving body , say setting the rotation on a paddle doesnt turn the paddle and then the solver doesnt converge.

    Using a moving body , say setting the rotation on a paddle doesnt turn the paddle and then the solver doesnt converge.

    I know this is old code , any chance you would fix this or advise me? I know the focus is on heat and its awesome..

    Thanks for what you made.. I think i found fast flip solvers, but the multidensity one seems perfect for my sky and volcano.

    I was thinking to apply drag to the immersed boundary , using a drag model like this viiscosity * ( 1/ vel *vel * the panel dot product).. ( flux in the travel direction)... the wikipedia drag model.. ideally the immersed boundary solve... or something that produces the drag. But if it moves gas about of the way on the front, and smoke bends around it ( that would be a pressure solve towards the cavity the object left by moving ...,equation , then push the fluid away from the normals of the immersed thing from the front. Or, i'd rather do it that way CBatty did. in variation methods.. ( or like the Cohen/Jeroen Molemaker paddle through smoke paper) . i have some of that Variational code, code, they posted 3 samples, all 2d.. ...

    i can put the link.. its on a big page on Variational methods.. it gives away 2d code for gas ( with 3 circles... with mods, I could move those.. and it pushes away the liquid.. with a one frame delay, it seems.. but the shape is nice, and it does not miss any of the fluid... I see code that mentions forward Eulear.. so i was hoping you know something about it.. ..

    I looked at the java port of your code on github, and I see he gave it some attention... a forward euler solve...anda different rotate method..

    https://github.com/noSoulApophis/incremental-fluids-java/

    my code is in c#.. i am open to any 2d methods that handle gas and heat and stratified dust.

    I would try the latest but can't use open GL shaders. for my project. thanks even if you dont want fix it.. but i hope so... or take out the velocity fields... it made me sad cos things always have a missing something... and i have been hunting 4 months. :) and .. the methods are so numerous... but CFD is a great field...

    opened by damian-666 0
Owner
Benedikt Bitterli
Benedikt Bitterli
A PIC/FLIP fluid simulation based on the methods found in Robert Bridson's "Fluid Simulation for Computer Graphics"

GridFluidSim3d This program is an implementation of a PIC/FLIP liquid fluid simulation written in C++11 based on methods described in Robert Bridson's

Ryan Guy 712 Jun 22, 2022
Header-only ordinary differential equation solvers in C++20.

ODE Header-only ordinary differential equation solvers in C++20. Example: Lorenz system #include <ode/ode.hpp> using method_type = ode::explicit_met

Virtual Reality & Immersive Visualization Group at RWTH Aachen University 3 Apr 25, 2022
🛠️ A simple ECS library made for learning purposes (header-only)

Met ECS A simple Entity Component System library made for learning purposes. It is header-only, so just have to copy the content of the src folder and

Guillaume Haerinck 15 Mar 26, 2022
RISCAL is a 32-bit reduced instruction-set computer (RISC) designed for learning and research purposes. It is named after my dog, Rascal.

RISCAL CPU RISCAL is a 32-bit custom instruction set architecture virtual machine. It is intended to be used for learning/research purposes. In a nuts

null 3 Dec 23, 2021
A simple, funky, horrible fluid simulator, made possible by OLC's Pixel Game Engine

flOwie A simple, funky, horrible fluid simulator, made possible by OLC's Pixel Game Engine! Not meant for usefulness. The big O is in the name because

null 1 Jan 21, 2022
PastaOS is a simple open-source kernel written from scratch for didactic purposes

What is PastaOS? ================ PastaOS is a simple open-source kernel written from scratch for didactic purposes. The main goal of this project i

Andrea Righi 10 Mar 30, 2022
Several single-file, cross-platform, public domain libraries for C/C++ that I use for learning / testing

HTC Several single-file, cross-platform, public domain libraries for C/C++ that I use for learning / testing (Not meant for production code). This is

Chris 8 Jun 28, 2022
A single file, single function, header to make notifications on the PS4 easier

Notifi Synopsis Adds a single function notifi(). It functions like printf however the first arg is the image to use (NULL and any invalid input should

Al Azif 7 Mar 24, 2022
Real-time 2D fluid simulator with lots of visualization options.

Fluid Simulator Building Start by cloning the program and all submodules using the following command: git clone --recursive https://github.com/linusmo

Linus Mossberg 26 Jun 20, 2022
fluid simulation

二维流体模拟demo 编译 g++ -O2 -fopenmp -o test test.cpp SPH结果 线程测试 测试平台Windows Intel(R)core(TM)[email protected] 物理线程6 逻辑线程12 加速比分析 加速比维持在6左右,在线程达到6(物理线程数量

null 1 Oct 22, 2021
OpenFOAM is a free, open source computational fluid dynamics (CFD) software package

acousticStreamingFoam About OpenFOAM OpenFOAM is a free, open source computational fluid dynamics (CFD) software package released by the OpenFOAM Foun

Bruno 1 Nov 2, 2021
The FLIP Fluids addon is a tool that helps you set up, run, and render high quality liquid fluid effects all within Blender, the free and open source 3D creation suite.

FLIP Fluids The FLIP Fluids addon is a tool that helps you set up, run, and render liquid simulation effects. Our custom built fluid engine is based a

Ryan Guy 1.3k Jun 28, 2022
Fluid simulation engine for computer graphics applications

Fluid Engine Dev - Jet Jet framework is a fluid simulation engine SDK for computer graphics applications that was created by Doyub Kim as part of the

Doyub Kim 1.4k Jun 27, 2022
Fluid Visualization - The code compilation is only tested on Arch Linux x86_64

Fluid Visualization The code compilation is only tested on Arch Linux x86_64, Linux kernel 5.15.13-arch1, with gcc 11.1.0, CMake 3.22.1, Xorg X server

krr 2 Jan 30, 2022
A collection of different Cellular Automata implementations for recreational purposes

A collection of different Cellular Automata implementations for recreational purposes

Tsoding 20 Jun 27, 2022
blackstar is a Polymorphic Keylogger written in C, for research purposes only

blackstar blackstar is a Polymorphic Keylogger written in C, for research purposes only. It is based on the whitecomet project. Introduction The goal

null 10 May 20, 2022
TiEtwAgent - PoC memory injection detection agent based on ETW, for offensive and defensive research purposes

TiEtwAgent - ETW-based process injection detection This project was created to research, build and test different memory injection detection use cases

Filip Olszak 135 Jun 17, 2022
Half-Life : Extended main branch for developing purposes

Half Life : Extended SDK Source Code of Half Life : Extended as a open source modbase for everyone publicly, make your own mod with alot of features e

Bacontsu 13 Jun 21, 2022
Budgie Screensaver is a fork of old gnome screensaver for purposes of providing an authentication prompt on wake.

budgie-screensaver Budgie Screensaver is a fork of gnome-screensaver intended for use with Budgie Desktop and is similar in purpose to other screensav

Buddies of Budgie 12 Jun 19, 2022