Giter VIP home page Giter VIP logo

stablefluids's Introduction

StableFluids

basic real-time fluids with SIMD optimization direct implementation of Jos Stam's Stable Fluid algorithm

This project quite strictly reproduces the contents of the paper since it mainly served as a reference for evaluating other algorithms and implementation attempts. The only deviations are the additional vorticity confinement routines, eliminating the restriction to a square and evenly spaced base grid, and using Jacobi instead of Gauss-Seidel solver in order to benefit from SIMD instructions.

features

  • 2d and 3d versions
  • independent simulation space resolution and grid spacing per dimension
  • vorticity confinement
  • viscosity, diffusion and timestep parameter
  • variable solver iteration count with two extra parameters to manually balance the simulation even if the count is set too low
  • VVVV wrapper nodes

structure

  • unmanaged c/c++ fluid classes (must be unmanaged for SSE/AVX)
  • CLI wrapper classes for VVVV nodes (must be managed for VVVV)
  • a C# project to pull the NuGet packages required for VVVV

so while this is a C++/CLI Visual Studio project, StableFluid2d.cpp and StableFluid3d.cpp are set to build without Common Runtime Language support in release mode to enable AVX instructions.

###sidenote the structure and the code might look a bit funny because of reasons:

  • i usually write C#
  • first time seriously doing a c++ project from scratch
  • first time peaking into SIMD instructions
  • looking for a nice way combining VVVVs NET. plugininterface with optimized c++

while the datastructure looks like it could just benefit from automatic modern compiler optimizations when having the the floats nicely aligned, it's actually the border conditions, which break up the alignment and therefore require manual vectorization in a lot of the base routines.

stablefluids's People

Contributors

woeishi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

stablefluids's Issues

A few questions

Hello, I came across this, it looks just great, I was going to do exactly this myself for a physics video game project ive been working on forever, and this might save me a lot of time. Please forgive the issue report, I couldn't see any email address for you and i have a couple of questions if you have a minute.

But before i try to work with it, i'm wondering if you got this code working, I see no sample code or exe, maybe if you could upload your vvvv project or any tests? Also wondering if you did any benchmarking, is it just 3x faster or the promised 8-16x faster.

very promising, love what you did with the masks to avoid branching and something special with number iterations in case it's not converging exactly what i had planned.

I'm presuming you made this in managed c++ instead of C# because the Vector class in c# Numerics has reported issues with alignment mismatching making it slow to copy data back and forth to GPU, is it true? I am disappointed in 2020 its so difficult to write this code and that it can't just use + operators but you've done it the best way from my research. I have looked at BEPU physics engine for rigid bodies which makes a huge use of c# vector but has so much unmanaged code , illegible loops, and tricks for intrinsics it might has well be all c++.

, I'm shocked that JIT compilation doesn't give the compiler more opportunities for SIMD optimizing, since it can know that the hardware is and can then supply the best instructions at startup on the client's phone or pc.

My other plan was to pursue a compute shader.. but this will leave my gpu alone and maybe be easier to work with.

I am getting a warning based on the processor. "There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "SlimDX", "AMD64". This mismatch may cause runtime failure"

If you lost the VVVV code but you say that it works and is fast, i will go make some tests in C# through the interface.

thx

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.