Fluid simulation engine for computer graphics applications

Overview

Fluid Engine Dev - Jet

License Windows Windows-MinGW Ubuntu macOS codecov

Jet framework is a fluid simulation engine SDK for computer graphics applications that was created by Doyub Kim as part of the book, "Fluid Engine Development". The code is built on C++11 and can be compiled with most of the commonly available compilers such as g++, clang++, or Microsoft Visual Studio. Jet currently supports macOS (10.10 or later), Ubuntu (14.04 or later), and Windows (Visual Studio 2015 or later). Other untested platforms that support C++11 also should be able to build Jet. The framework also provides Python API for faster prototyping.

The latest code is always available from the main branch. Since the code evolves over time, the latest from the main branch could be somewhat different from the code in the book. To find the version that is consistent with the book, check out the branch book-1st-edition.

Key Features

  • Basic math and geometry operations and data structures
  • Spatial query accelerators
  • SPH and PCISPH fluid simulators
  • Stable fluids-based smoke simulator
  • Level set-based liquid simulator
  • PIC, FLIP, and APIC fluid simulators
  • Upwind, ENO, and FMM level set solvers
  • Jacobi, Gauss-Seidel, SOR, MG, CG, ICCG, and MGPCG linear system solvers
  • Spherical, SPH, Zhu & Bridson, and Anisotropic kernel for points-to-surface converter
  • Converters between signed distance function and triangular mesh
  • C++ and Python API
  • Intel TBB, OpenMP, and C++11 multi-threading backends

Every simulator has both 2-D and 3-D implementations.

Quick Start

You will need CMake to build the code. If you're using Windows, you need Visual Studio 2015 or 2017 in addition to CMake.

First, clone the code:

git clone https://github.com/doyubkim/fluid-engine-dev.git --recursive
cd fluid-engine-dev

Python API

Build and install the package by running

pip install -U .

Now run some examples, such as:

python src/examples/python_examples/smoke_example01.py

C++ API

For macOS or Linux:

mkdir build && cd build && cmake .. && make

For Windows:

mkdir build
cd build
cmake .. -G"Visual Studio 14 2015 Win64"
MSBuild jet.sln /p:Configuration=Release

Now run some examples, such as:

bin/hybrid_liquid_sim

Docker

docker pull doyubkim/fluid-engine-dev:latest

Now run some examples, such as:

docker run -it doyubkim/fluid-engine-dev
[inside docker container]
/app/build/bin/hybrid_liquid_sim

More Instructions of Building the Code

To learn how to build, test, and install the SDK, please check out INSTALL.md.

Documentations

All the documentations for the framework can be found from the project website including the API reference.

Examples

Here are some of the example simulations generated using Jet framework. Corresponding example codes can be found under src/examples. All images are rendered using Mitsuba renderer and the Mitsuba scene files can be found from the demo repository. Find out more demos from the project website.

FLIP Simulation Example

FLIP Example

PIC Simulation Example

PIC Example

Level Set Example with Different Viscosity

Level Set Example

Smoke Simulation with Different Advection Methods

Cubic-smoke Example Linear-smoke Example

Point-to-Surface Examples

Point-to-Surface Example

Top-left: spherical, top-right: SPH blobby, bottom-left: Zhu and Bridson's method, and bottom-right: Anisotropic kernel

Developers

This repository is created and maintained by Doyub Kim (@doyubkim). Chris Ohk (@utilForever) is a co-developer of the framework since v1.3. Many other contributors also helped improving the codebase including Jefferson Amstutz (@jeffamstutz) who helped integrating Intel TBB and OpenMP backends.

License

Jet is under the MIT license. For more information, check out LICENSE.md. Jet also utilizes other open source codes. Checkout 3RD_PARTY.md for more details.

I am making my contributions/submissions to this project solely in my personal capacity and am not conveying any rights to any intellectual property of any third parties.

Acknowledgement

We would like to thank JetBrains for their support and allowing us to use their products for developing Jet Framework.

JetBrains

Comments
  • Moving particle emitter problems

    Moving particle emitter problems

    I have found that if I move the Surface3 for a particle emitter (used in FLIP or PIC) then the particles don't get emitted.

    I have tracked this down to the region BoundingBox calculated in VolumeParticleEmitter3::emit(...)

    Specifically this code here

    BoundingBox3D region = _bounds; if (_implicitSurface->isBounded()) { BoundingBox3D surfaceBBox = _implicitSurface->boundingBox(); region.lowerCorner = max(region.lowerCorner, surfaceBBox.lowerCorner); region.upperCorner = min(region.upperCorner, surfaceBBox.upperCorner); }

    Since my moving emitter is an implicit surface created from a Sphere this code runs. It then calculates the lowerCorner of my box to be greater than the upperCorner.

    This means that in the forEachPoint method

    _pointsGen->forEachPoint(...)

    It can't loop over the points in the box because lower.x > upper.x. Which means that this

    double boxWidth = boundingBox.width();

    Produces a negative number, so no points are emitted.

    bug p1 
    opened by kentbarber 25
  •  Fix issue with anisotropic surface reconstruction

    Fix issue with anisotropic surface reconstruction

    This revision fixes Issue #130 which was caused by the singular value clamping (taking max instead of absmax). It also includes VSCode setting fix which was outdated.

    opened by doyubkim 16
  • [Questions] LevelSetLiquidSolver3

    [Questions] LevelSetLiquidSolver3

    In the PIC solver, particles act as a fluid. And what is the liquid in the solver LevelSetLiquidSolver3? How can I save fluid data (positions, velocities, forces) in a LevelSet solver? And how can you create a mesh, based on the LevelSet solver?

    question 
    opened by PavelBlend 15
  • Fix default params for ImplicitTriangleMesh3

    Fix default params for ImplicitTriangleMesh3

    This revision includes:

    • Consistent default parameters for ImplicitTriangleMesh3 between C++ and Python APIs
    • Python APIC example fix (margin=0 should not be used). This issue was reported in issue #191
    opened by doyubkim 15
  • Add ImplicitTriangleMesh3 and marchingCubes to Python API

    Add ImplicitTriangleMesh3 and marchingCubes to Python API

    This revision adds/fixes Python API for ImplicitTriangleMesh3 and marchingCubes. It also adds new Python example, apic_example03.py, to demonstrate new/fixed features.

    opened by doyubkim 13
  • Animating parameters

    Animating parameters

    Is it possible to animate during the simulation? For example, enable the oneShot parameter at the emitter, and then after 10 frames turn it off. Or change the position of the collider. Or change the initial velocity at the emitter.

    p1 api 
    opened by PavelBlend 12
  • Support HPX multiple tasking system

    Support HPX multiple tasking system

    I'll add HPX multiple tasking system such as Intel TBB and OpenMP. HPX is the C++ Standard Library for Parallelism and Concurrency(https://github.com/STEllAR-GROUP/hpx).

    feature p1 
    opened by utilForever 10
  • The second derivative of poly6 kernel function.

    The second derivative of poly6 kernel function.

    Hello, douyubkim. I just discoverd the following problems. It is about the second derivative of poly6 kernel function. In your code:

    inline double SphStdKernel3::secondDerivative(double distance) const {
        if (distance * distance >= h2) {
            return 0.0;
        } else {
            double x = distance * distance / h2;
            return 945.0 / (32.0 * kPiD * h5) * (1 - x) * (3 * x - 1);
        }
    }
    

    But I calculated it by hands for serveral times and wrote a different version:

    inline double SphStdKernel3::secondDerivative(double distance) const {
        if (distance * distance >= h2) {
            return 0.0;
        } else {
            double x = distance * distance / h2;
            return 945.0 / (32.0 * kPiD * h5) * (1 - x) * (5 * x - 1);
        }
    }
    

    It's just 3 should be replaced with 5 in that equation. I know it was missing from any test because we just use the second derivative of spiky kernel function instead of poly6 kernel function.

    Meanwhile, there is also a small mistake on Page 133 of your book. It's about formula (2.9), the equation of state. I check out the paper (Becker M, Teschner M. Weakly compressible SPH for free surface flows[C]//Proceedings of the 2007 ACM SIGGRAPH/Eurographics symposium on Computer animation. Eurographics Association, 2007: 209-217.) and find that you just put the gamma exponent in the wrong place. The code shown in the book is right.

    Thanks.

    bug p0 
    opened by ZeusYang 10
  • Project is not compiled in Release mode

    Project is not compiled in Release mode

    I have a Visual Studio 2017 Community. In Release mode, the project refuses to compile. Not enough memory. I have 8 GB Windows 7 64 bit.

    In Debug mode, the compilation is successful.

    opened by PavelBlend 10
  • "anisotropic_points_to_implicit3" problem

    Hi, It's me (#109) again :smile_cat: . I find a problem with anisotropic point to implicit3.

    What problem:

    Here is a screenshot: Image of hole It seems not correct for a dambreak at frame 0.

    How:

    I just run a sph dambreak demo similar to sph_sim example 3, and here is the .pos file at frame 0 that I got. frame_000000.pos

    And then, I tried to reconstruct the surface using the anisotropic kernel.

    ./particles2obj -i frame_000000.pos -o frame_000000.obj -r 300,200,150 -g 0.01,0.01,0.01 -k 0.036
    

    (kernal radius:0.036, resolution is 300 200 150, and the gridspacing is 0.01, 0.01, 0.01. sph example 3's domain is 3,2,1.5, so I think it is reasonable)

    My goal is to get a surface as tight as possible to render. My sph particle radius is 0.02(and the kernel radius is 1.8 * radius) as default, so I chose 0.036 as reconstruction kernel radius. I'm not sure if it is appropriate. Finally, I get the .obj as the screenshot shows.

    My opinion:

    I looked into the source code and the original paper

    I find that the code is a little bit different from what the paper describes. The main difference is in equation 15. Instead of using the magic number k_s = 1400, the code uses std::pow(relV, 1.0 / 3.0) at line 152 in "anisotropic_points_to_implicit3.cpp"

    I do not understand why the code uses "pow 1/3", but I tried to use the magic number 1400 in the same way as the paper, and the problem is gone! Here is the screenshot using k_s = 1400. Image of nohole (Sorry for the light spot in the middle. It is the UI of Blender)

    I've not tested the 2D version of the anisotropic kernel, maybe it suffers from the same problem.

    That's all I found... I hope I describe the problem clearly. I will maintain the picture and the .pos file till this issue is closed.

    bug p0 
    opened by Immocat 10
  • Mitsuba renderings

    Mitsuba renderings

    The Mitsuba renderings in the examples video and the book look great. Is it possible to add the Mitsuba project files and possibly scripts that were used to create these images? Unfortunately I only see the volume export for smoke simulations in the source code.

    opened by danielwinkler 9
  • Incorrect formula for collider boundary conditions (Equation 3.18 in the book)

    Incorrect formula for collider boundary conditions (Equation 3.18 in the book)

    Equation 3.18 takes the relative fluid-collider velocity for boundary projection. This does not seem correct. Consider the simple case of of verctical wall (normal_collider=(1,0) uv_collider = (0,1) and uv_liquid_boundary=(0,0). Relative velocity then is uv_rel = (0,-1) and the forumla in the book projects this to the wall which gives boundary_constrained = (0,-1)
    This does not seem physically plausible, because the uncontrained velocity was (0,0) and is "suddeny accelerated" to (0,-1). So I think we must take the liquid velocity and replace its boundary-normal component by the boundar-normal-component of the collider. (Using relative velocity is important in other contexts such as friction forces, but should not be taken here IMO)

    P.S.: It would be really useful to always give some source from the literature for such kind of formula, as Prof. Bridsen does in his book about fluid simulation development)

    Projecting this
    The formula in the book would project the relative velocity , i.e. .-1 which

    While relative velocity is necessary for drag forces,

    opened by zx-82 0
  • About the local method in the surface_to_implicit

    About the local method in the surface_to_implicit

    According to my understanding, the otherPoint in the function SurfaceToImplicit2::closestNormalLocal is a point described by local coordinates. while the code use _surface->closestNormal(otherPoint), which treats this otherPoint as a point in the world coordinate system, perform a localization and then calculate the normal

    opened by LILKOTYO 1
  • No known features for CXX compiler

    No known features for CXX compiler "Clang"

    Fluid Engine can throw a error that prevent me from a successful build on my environment (MacOS big sur, clang 11, cmake 3.19.6)

    adding this line in the root CMakeLists.txt may help! (I put this line under the cmake_minimum_required(...) line)

    cmake_policy(SET CMP0025 NEW)
    

    a subtle fix advice, best regards!

    build investigate 
    opened by Xayah-Hina 5
  • Some unit tests failure on 32-bit system

    Some unit tests failure on 32-bit system

    When I work MinGW build on 32-bit system, I saw that some unit tests are fail. We need to fix related code.

    [----------] Global test environment tear-down
    [==========] 793 tests from 166 test suites ran. (3277 ms total)
    [  PASSED  ] 781 tests.
    [  FAILED  ] 12 tests, listed below:
    [  FAILED  ] VolumeParticleEmitter2.Emit
    [  FAILED  ] Vector.BasicGetters
    [  FAILED  ] TriangleMesh3.ClosestIntersection
    [  FAILED  ] Timer.Basics
    [  FAILED  ] SurfaceToImplicit3.ClosestIntersection
    [  FAILED  ] SurfaceToImplicit2.ClosestIntersection
    [  FAILED  ] SurfaceSet3.ClosestIntersection
    [  FAILED  ] SurfaceSet2.ClosestIntersection
    [  FAILED  ] MathUtils.MonotonicCatmullRom
    [  FAILED  ] ImplicitSurfaceSet3.ClosestIntersection
    [  FAILED  ] ImplicitSurfaceSet2.ClosestIntersection
    [  FAILED  ] Pcg.Solve
    
    bug test p1 
    opened by utilForever 0
  • How to implement the xyz to mesh generation to another code for fluid simulation?

    How to implement the xyz to mesh generation to another code for fluid simulation?

    I am running a fluidics simulation in a robotics platform and I am currently pausing the simulation every few steps to mesh the fluid particles. Is there a way I could use the xyz to obj capabilities of fluid engine dev so I will not have to run the partciles2obj examples each timestep?

    Currently, I use system to run the examples from the terminal. Can I do it without this extra I/O? It would be amazing if there was a way.

    question 
    opened by uljadberdica1000 1
Releases(v1.3.3)
  • v1.3.3(Mar 10, 2019)

  • v1.3.2(Dec 5, 2018)

  • v1.3.1(Oct 7, 2018)

  • v1.3.0(Aug 26, 2018)

    This release includes:

    • Support for multi-tasking systems including Intel TBB, OpenMP, and native C++11 thread backends.
    • Depreciate winix and libobj dependencies and adopt Clara and tinyobj
    • Python 3 compatibility fix
    • Code coverage with CI
    • Build issue fix for latest compilers
    • Other minor fixes
    Source code(tar.gz)
    Source code(zip)
  • v1.2.2(Dec 28, 2017)

    This patch release includes some major bug fixes:

    • Fix smoke density not getting diffused (#135)
    • Assert fix (#136)
    • Fix for race condition when updating collider (#137)
    • Fix correct function for MG (#139 and #140)
    Source code(tar.gz)
    Source code(zip)
  • v1.2.1(Dec 8, 2017)

    This patch release includes:

    • Docker build
    • Compressed linear system solver for non-MG solvers
    • Anisotropic surface reconstruction bug fix
    • Other minor fixes
    Source code(tar.gz)
    Source code(zip)
  • v1.2.0(Sep 4, 2017)

    This release includes:

    • Generic k-d tree implementation
    • Point-to-surface converters including spherical, SPH, Zhu & Bridson, and anisotropic kernel method
    • Bug fixes
    Source code(tar.gz)
    Source code(zip)
  • v1.1.0(Jul 2, 2017)

  • v1.1.0-rc1(May 15, 2017)

  • v1.0.6(May 1, 2017)

    This release includes:

    • Vector and matrix expression template (experimental)
    • Statically/dynamically-sided dense vector/matrices
    • Compressed sparse row matrix
    • Bug fix on boundary handling for grid fractional (variational) pressure solver
    • Minor fix on Frame/PhysicsAnimation
    • Minor typo fixes
    Source code(tar.gz)
    Source code(zip)
  • v1.0.5(Apr 12, 2017)

    This release includes:

    • Spatial query (nearest neighbor search and intersection test) interface
    • Bounding Volume Hierarchy (BVH) for 2D and 3D
    • Octree and quadtree
    • Cumulative bug fixes
    Source code(tar.gz)
    Source code(zip)
  • v1.0.4(Mar 26, 2017)

    This release includes:

    • Improved CustomImplicitSurface2 and 3
    • Newly introduced ImplicitTriangleMesh3
    • Fixed bugs from APIC solvers and Transform2 and 3 classes
    • Migrated from cpplint to clang-format
    • Migrated from SCons to CMake
    Source code(tar.gz)
    Source code(zip)
  • v1.0.3(Jan 27, 2017)

    This release includes the Affine Particle-in-Cell implementation based on Jiang et al. SIGGRAPH 2015 paper. It also contains the FLIP-PIC blending.

    Source code(tar.gz)
    Source code(zip)
  • v1.0.2(Jan 22, 2017)

  • v1.0.1(Jan 20, 2017)

  • v1.0.0(Dec 30, 2016)

    This is the first official release of Jet framework.

    The update since the previous release candidate is mainly on refining the API and stabilization, especially on the moving colliders and surface transform.

    This version matches the contents of the book (with minor differences) and will be branched out to book-1st-edition to keep the code in sync with the first edition of the book.

    Source code(tar.gz)
    Source code(zip)
  • v1.0.0-rc2(Dec 21, 2016)

  • v1.0.0-rc1(Dec 13, 2016)

  • v0.4.0(Dec 4, 2016)

  • v0.3.0(Nov 28, 2016)

  • v0.2.0(Jun 15, 2016)

  • v0.1.0(Jun 6, 2016)

    This release contains the first draft of the code from the book "Fluid Engine Development". This is still a pre-release, since more tests, documentations, examples, and API refinements will happen in next couple of months.

    Source code(tar.gz)
    Source code(zip)
Owner
Doyub Kim
Software Engineer
Doyub Kim
Offline fluid simulation solver adopted from https://github.com/doyubkim/fluid-engine-dev.

FluidEngine This is a fluid simulation engine for computer graphics applications. I adopt it from Doyub Kim's fluid-engine-dev. It's built on C++11 an

YangWC 55 Oct 26, 2022
CSC404: Computer Graphics [CG] & CSL402: Computer Graphics Lab [CG Lab]

COMPUTER-GRAPHICS-AND-COMPUTER-GRAPHICS-LAB CSC404: CG & CSL402: CG LAB [SEMESTER IV] Syllabus CG - Reference Books THE WALL MEGA SATISH - AUTHOR CG C

AMEY THAKUR 7 Apr 28, 2022
CMake modules for common applications related to computer graphics

cgcmake CMake modules for common applications related to computer graphics Sample Usage Maya Project |-- CMakeLists.txt |-- cgcmake |-- modules

Chad Vernon 115 Dec 5, 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
AWS Ambit Scenario Designer for Unreal Engine 4 (Ambit) is a suite of tools to streamline content creation at scale for autonomous vehicle and robotics simulation applications.

AWS Ambit Scenario Designer for Unreal Engine 4 Welcome to AWS Ambit Scenario Designer for Unreal Engine 4 (Ambit), a suite of tools to streamline 3D

AWS Samples 77 Jan 2, 2023
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
A cheap,simple,Ongeki controller Use Keyboard Simulation and Mouse Simulation to controller the ongeki game. Using Pro-micro control.

N.A.G.E.K.I. A cheap,simple,Ongeki controller Use Keyboard Simulation and Mouse Simulation to controller the ongeki game. Using Pro-micro control. 中文版

NanaNana 39 Dec 8, 2022
A cheap,simple,Ongeki controller Use Keyboard Simulation and Mouse Simulation to controller the ongeki game. Using Pro-micro control.

N.A.G.E.K.I. PLEASE CHECK Main Project A cheap,simple,Ongeki controller Use Keyboard Simulation and Mouse Simulation to controller the ongeki game. Us

NanaNana 11 Dec 30, 2021
PLP Project Programming Language | Programming for projects and computer science and research on computer and programming.

PLPv2b PLP Project Programming Language Programming Language for projects and computer science and research on computer and programming. What is PLP L

PLP Language 5 Aug 20, 2022
OpenGL Template Engine - a C++ OpenGL graphics engine which aimed to be a simple startup template for 3D OpenGL projects.

OpenGL Template Engine is a C++ OpenGL graphics engine which aimed to be a simple startup template for 3D OpenGL projects. This is the template I personally use for my own projects and provides me with the general OpenGL 3D render setup with model import and UI.

Marcus Nesse Madland 2 May 16, 2022
F Graphics Library (FGL) is a small graphics C++ portable library for LCD displays on embedded systems

F Graphics Library (FGL) Full documentation: fgl.docsforge.com (By Filipe Chagas) F Graphics Library is a C++ library that I created for use in embedd

Filipe Chagas 9 Oct 31, 2022
GraphicsFuzz provides tools for automatically finding and simplifying bugs in graphics drivers, specifically graphics shader compilers.

GraphicsFuzz GraphicsFuzz is a set of tools for testing shader compilers GraphicsFuzz provides tools for automatically finding and simplifying bugs in

Google 516 Dec 15, 2022
Visualization Library is a C++ middleware for high-performance 2D and 3D graphics applications based on OpenGL 1.x-4.x supporting Windows, Linux and Mac OS X.

Visualization Library 2.2 Gallery About Visualization Library is a C++ middleware for high-performance 2D and 3D graphics applications based on the in

Michele 313 Nov 8, 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 28 Dec 14, 2022
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 3 Oct 28, 2022
Simple, single-file fluid solvers for learning purposes

Incremental fluids The purpose of this project is to provide simple, easy to understand fluid solver implementations in C++, together with code docume

Benedikt Bitterli 561 Dec 19, 2022
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.4k Dec 22, 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