GithubHelp home page GithubHelp logo

nikolausrauch / 2d-fluids Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 2.38 MB

Proof of concept implementations of different fluid dynamic solvers in C++

License: MIT License

CMake 4.91% C 0.18% C++ 94.91%
2d-fluid cpp position-based-fluids simulation smooth-particle-hydrodynamics computer-graphics fluid-dynamics fluid-simulation fluids

2d-fluids's Introduction


This repository contains proof-of-concept C++ implementations of different fluid dynamics solvers in 2D.
The goal is to provide minimalistic and straightforward implementations, emphasizing ease of understanding.
I decided to keep simulation code mostly independent (single file), which means that routines are at times duplicated (e.g. SPH density estimation, eos, boundary particles, ...).

Features

  • Methods
    • WCSPH: Weakly Compressible SPH
    • PCISPH: Predictive-Corrective Incompressible SPH [Solenthaler 2009]
    • PBF: Position Based Fluid [Macklin 2013]
    • PF: Projective Fluids
    • IISPH: Implicit Incompressible SPH [Ihmsen 2013]
    • DFSPH: Divergence-Free SPH
    • FLIP: Fluid Particle in Cell
    • Stable-Fluid: Eulerian based Fluid
  • Utility
    • 2D-Viewer with OpenGL2 and ImGui/ImPlot (standalone repo)
    • Minimal Performance Monitoring
    • Hash-Grid Nearest Neighbor Search
    • Uniform-Grid Nearest Neighbor Search
    • Minimalistic Generic Scene Description

image

Minimal Example

Scene setup is independent of the used simulator. An instance of Scene provides an interface to construct geometry (Box, Circle) that can either be a boundary or fluid body (currently no dynamic boundaries).
The simulator (WCSPH, PCISPH, PBF, IISPH) initializes its data (e.g. fluid and ghost particles) from the description via void Simulation::create(const Scene&).

/* scene description */
Scene desc;

/*left, right, bottom boundary*/
desc.add(Scene::Box{ {-5.00f, -3.50f}, { 5.00f, -3.25f}, Scene::eType::BOUNDARY });
desc.add(Scene::Box{ {-5.00f, -3.25f}, {-4.75f,  8.00f}, Scene::eType::BOUNDARY });
desc.add(Scene::Box{ { 4.75f, -3.25f}, { 5.00f,  8.00f}, Scene::eType::BOUNDARY });

/* fluid */
desc.add(Scene::Box{ {-4.72f, -3.23f}, { 4.73f,  0.00f}, Scene::eType::FLUID_BODY });
desc.add(Scene::Circle{ {0.0f, 3.5f}, 0.75f, Scene::eType::FLUID_BODY});

/* simulation handler (Implicit Incompressible SPH) */
IISPH simulation;
simulation.timeStep = 1.0 / 240.0f;
simulation.stepPerFrame = 1;

/* load scene (initialize fluid and boundary particles) */
simulation.create(scene);

/* solve dynamics -> time += stepPerFrame*timeStep */
simulation.update();

iisph_example

iisph_waterdrop.mp4

๐Ÿ“š Useful Resources

Eurographics Tutorial - Koschier et al. 2019
SPH Fluids in Computer Graphics - Ihmsen et al. 2014
Fluid Engine Development - Doyub Kim
SPlisHSPlasH - Jan Bender

2d-fluids's People

Contributors

nikolausrauch avatar

Stargazers

 avatar  avatar

Watchers

 avatar

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.