Convert Figma logo to code with AI

doyubkim logofluid-engine-dev

Fluid simulation engine for computer graphics applications

1,880
264
1,880
60

Top Related Projects

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.

SPlisHSPlasH is an open-source library for the physically-based simulation of fluids.

High performance physically based renderer in C++11

Mitsuba 2: A Retargetable Forward and Inverse Renderer

Quick Overview

The doyubkim/fluid-engine-dev repository is a comprehensive open-source project that provides a fluid simulation engine for computer graphics applications. It is designed to be a flexible and efficient framework for simulating various fluid phenomena, such as water, smoke, and fire.

Pros

  • Flexible and Extensible: The project is designed with modularity in mind, allowing users to easily extend and customize the engine to fit their specific needs.
  • High-Performance: The engine utilizes advanced numerical methods and parallelization techniques to achieve high-performance fluid simulations.
  • Comprehensive Documentation: The project's documentation is thorough and well-organized, making it easier for developers to understand and use the engine.
  • Active Development: The project is actively maintained and regularly updated, ensuring that it stays up-to-date with the latest advancements in fluid simulation research.

Cons

  • Steep Learning Curve: The complexity of the engine and the underlying fluid simulation algorithms may present a steep learning curve for some users, especially those new to the field.
  • Limited Visualization Tools: While the engine provides a solid foundation for fluid simulation, the project does not include comprehensive visualization tools, which may require users to integrate third-party libraries or develop their own visualization solutions.
  • Limited Support for Specific Fluid Phenomena: The engine may not be optimized for certain specialized fluid phenomena, such as highly viscous fluids or complex surface interactions.
  • Dependency on External Libraries: The engine relies on several external libraries, which may introduce additional complexity in terms of installation and configuration.

Code Examples

Here are a few code examples demonstrating the usage of the doyubkim/fluid-engine-dev library:

// Initialize the fluid simulation
FLuidSolver3Ptr solver = std::make_shared<FLuidSolver3>();
solver->SetDimensions(Vector3D(1.0, 1.0, 1.0));
solver->SetGridResolution(Vector3I(64, 64, 64));

// Add a source to the simulation
solver->AddSource(Vector3D(0.5, 0.5, 0.5), 1.0);

// Advance the simulation
for (int i = 0; i < 100; ++i) {
    solver->Update(0.01);
}

This code initializes a 3D fluid simulation, adds a source to the simulation, and advances the simulation for 100 time steps.

// Set up the boundary conditions
FLuidBoundaryConditionData3 boundaryData;
boundaryData.IsWall[0] = true;
boundaryData.IsWall[1] = true;
boundaryData.IsWall[2] = true;
solver->SetBoundaryCondition(boundaryData);

This code sets up the boundary conditions for the fluid simulation, marking all three dimensions as solid walls.

// Visualize the simulation
FLuidVisualizer3Ptr visualizer = std::make_shared<FLuidVisualizer3>(solver);
visualizer->Render();

This code creates a fluid visualizer and renders the current state of the fluid simulation.

Getting Started

To get started with the doyubkim/fluid-engine-dev project, follow these steps:

  1. Clone the repository:

    git clone https://github.com/doyubkim/fluid-engine-dev.git
    
  2. Install the required dependencies, which may include:

    • CMake
    • C++ compiler (e.g., GCC, Clang, or MSVC)
    • Optional dependencies: OpenGL, GLFW, or other visualization libraries
  3. Navigate to the project directory and create a build directory:

    cd fluid-engine-dev
    mkdir build
    cd build
    
  4. Configure the project using CMake:

    cmake ..
    
  5. Build the project:

    cmake --build .
    
  6. Run the example applications or integrate the library into your own project.

For more detailed instructions, please refer to the project's README and the [documentation](https://github.com/doyub

Competitor Comparisons

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.

Pros of Blender-FLIP-Fluids

  • Integration with Blender: Blender-FLIP-Fluids is a plugin that seamlessly integrates with the Blender 3D modeling and animation software, allowing for a more streamlined and user-friendly workflow.
  • Visualization and Rendering: The plugin provides advanced visualization and rendering capabilities, enabling users to create high-quality fluid simulations and animations within the Blender environment.
  • Accessibility: Blender-FLIP-Fluids is a free and open-source project, making it accessible to a wider range of users, including hobbyists and independent creators.

Cons of Blender-FLIP-Fluids

  • Limited Customization: As a plugin, Blender-FLIP-Fluids may have less flexibility and customization options compared to a standalone fluid simulation engine like fluid-engine-dev.
  • Performance Limitations: The performance of Blender-FLIP-Fluids may be constrained by the overall performance of the Blender software, which can be a concern for large-scale or complex fluid simulations.
  • Dependency on Blender: Blender-FLIP-Fluids is tightly coupled with the Blender software, which means that users are required to have Blender installed and configured correctly to use the plugin.

Code Comparison

Here's a brief code comparison between the two projects:

Blender-FLIP-Fluids (Python):

import bpy
import flip_fluids_addon.base_types.flip_fluid_module as fluid_module

class FlipFluidsDomainObject(fluid_module.Base):
    bl_idname = "flip_fluid_domain"
    bl_label = "FLIP Fluid Domain"

    def __init__(self, obj):
        fluid_module.Base.__init__(self, obj)
        self.mesh_object = obj

fluid-engine-dev (C++):

class GridFluidSolver3 : public FluidSolver3 {
public:
    GridFluidSolver3(
        const Size3& resolution,
        const Vector3D& gridSpacing,
        const Vector3D& gridOrigin);

    void solve(double timeIntervalInSeconds) override;
    void computeVelocity(double timeIntervalInSeconds) override;
    void computeDensity(double timeIntervalInSeconds) override;
    // ...
};

SPlisHSPlasH is an open-source library for the physically-based simulation of fluids.

Pros of SPlisHSPlasH

  • SPlisHSPlasH is a well-established and widely-used library for fluid simulation, with a large community and extensive documentation.
  • The library provides a wide range of features, including support for different fluid models, collision detection, and rendering.
  • SPlisHSPlasH is actively maintained and regularly updated, ensuring its continued relevance and reliability.

Cons of SPlisHSPlasH

  • The codebase of SPlisHSPlasH can be more complex and harder to navigate compared to Fluid Engine Dev, which may make it more challenging for newcomers to contribute or extend the library.
  • SPlisHSPlasH may have a steeper learning curve, as it requires a deeper understanding of fluid simulation techniques and concepts.
  • The library's focus on a wide range of features may result in a larger codebase and potentially slower performance compared to a more specialized library like Fluid Engine Dev.

Code Comparison

Here's a brief comparison of the code structure between the two repositories:

Fluid Engine Dev (doyubkim/fluid-engine-dev):

class FluidSolver3 {
public:
    virtual void Update(double timeIntervalInSeconds) = 0;
    virtual void SetBoundaryCondition(const Surface3Ptr& boundary) = 0;
    virtual void AddParticle(const Vector3D& position) = 0;
    // ...
};

SPlisHSPlasH (InteractiveComputerGraphics/SPlisHSPlasH):

class SPHKernelBase {
public:
    virtual Real W(const Vector3r& r, Real h) const = 0;
    virtual Vector3r gradW(const Vector3r& r, Real h) const = 0;
    virtual Real laplacianW(const Vector3r& r, Real h) const = 0;
    // ...
};

The key difference is that Fluid Engine Dev focuses on a more high-level API for fluid simulation, while SPlisHSPlasH provides a more low-level, modular approach with a focus on different fluid simulation techniques and kernels.

High performance physically based renderer in C++11

Pros of Tungsten

  • Tungsten is a physically-based renderer, which means it aims to accurately simulate the behavior of light in the real world, resulting in highly realistic and visually stunning images.
  • Tungsten supports a wide range of advanced rendering features, such as path tracing, photon mapping, and volumetric effects, making it a powerful tool for creating complex and detailed scenes.
  • Tungsten is highly customizable and extensible, allowing users to write their own plugins and integrate it into their own projects.

Cons of Tungsten

  • Tungsten has a steeper learning curve compared to Fluid Engine Dev, as it requires a deeper understanding of rendering concepts and techniques.
  • Tungsten is primarily focused on rendering, and does not provide the same level of support for other aspects of game development, such as physics simulation or user interface.
  • Tungsten is a relatively niche project, with a smaller community and fewer resources available compared to more mainstream game engines or rendering libraries.

Code Comparison

Fluid Engine Dev:

void AddSphereToScene(const Vector3D& center, double radius, const Vector3D& color) {
    auto sphere = std::make_unique<Sphere>(center, radius);
    sphere->SetColor(color);
    m_scene.AddShape(std::move(sphere));
}

Tungsten:

std::shared_ptr<Primitive> createSphere(const Vec3f& center, float radius, const Spectrum& color) {
    auto sphere = std::make_shared<Sphere>(center, radius);
    sphere->setEmission(color);
    return sphere;
}

Both code snippets demonstrate the creation of a sphere object, but the Tungsten version uses a more generic Primitive interface, while the Fluid Engine Dev version uses a specific Sphere class. The Tungsten version also uses a Spectrum object to represent color, while Fluid Engine Dev uses a Vector3D.

Mitsuba 2: A Retargetable Forward and Inverse Renderer

Pros of Mitsuba2

  • Mitsuba2 is a highly flexible and extensible rendering framework, allowing for the implementation of a wide range of rendering algorithms and techniques.
  • The project has a strong focus on physically-based rendering, making it well-suited for applications that require accurate and realistic lighting simulations.
  • Mitsuba2 supports a wide range of material models and has a modular design, making it easy to integrate with other software and libraries.

Cons of Mitsuba2

  • Mitsuba2 has a steeper learning curve compared to Fluid Engine Dev, as it is a more complex and feature-rich project.
  • The project's documentation, while comprehensive, can be challenging to navigate for newcomers.
  • Mitsuba2 may have a higher computational overhead compared to Fluid Engine Dev, depending on the specific use case and hardware requirements.

Code Comparison

Fluid Engine Dev (doyubkim/fluid-engine-dev):

void AddForce(const Vector3D<double>& force) {
    m_forces += force;
}

void Update(double timeIntervalInSeconds) {
    m_velocity += (m_forces / m_mass) * timeIntervalInSeconds;
    m_position += m_velocity * timeIntervalInSeconds;
    m_forces = Vector3D<double>();
}

Mitsuba2 (mitsuba-renderer/mitsuba2):

def sample_bsdf(self, si, sample1, sample2, active=True):
    """Sample the BSDF"""
    wi, pdf = self.sample(si, sample1, sample2)
    bsdf_val = self.eval(si, wi)
    return wi, bsdf_val, pdf

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

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