My Fluid Simulation (SPH) Sample (1) – Rigid body model + N-S model

I keep a strong interest for fluid simulation (specifically water simulation) and this is my first implementation for SPH (Smoothed Particle Hydrodynamics).

This post is the first part of the whole application – SPH framework.

1) Rigid Body model

Rigid body model indicates that all particles, scene walls and barriers are not  elastic – it will repel other rigid objects away when they hit it. Navier-Stokes equation will be directly applied on rigid particles, just like the real world situation : molecules cannot converge.

Collisions with walls/barriers

There are no repulsion forces. Only velocity is ‘reflected’ by the hit point normal, as light ray reflection. This works well.

Collisions with other particles

The physical model among particles is from GPU Gem 3 Chapter 29:
http://http.developer.nvidia.com/GPUGems3/gpugems3_ch29.html

But how to get a proper spring coefficients and damping coefficients is not easy, and inappropriate configuration could make your particles crazy or sluggish.

(Rookie Hint - [Collision Detection] : |currPos – wall| < epsilon is not the correct solution that suffers from precision problem in ANY case bcz. you can never predict particle velocities. The right solution is to judge whether the predicted position in next frame is beyond the wall or not)

2) Navier-Stokes model

The basic idea is still from [Muller 2003] as mentioned before. Interestingly this paper doesn’t mention SPH is based on rigid particles and this may bring confusions to SPH beginners as me.
I refered to the following link for the maths part.
http://www.rchoetzlein.com/eng/graphics/fluids.htm

3) Grid Acceleration

I split the whole scene space by about 10*10*10 grid cells, and only particles in neighboring grid cells (27 cells) are considered when calculating pressure/viscosity kernels. This improves the performance by about 100% when particles number is about 700 on CPU.


[Screenshots]

Let me show you a sequence of screenshots here:

fl_0 fl_1 fl_2 fl_3 fl_4 fl_5 fl_6 fl_7 fl_8

You can see the splashing when particles hit the ball barrier and they are ‘flowing’ on the ground – see the small waves! I think it will look much better when we have more particles like 50000.

There are total 1600 particles with FPS averaged at about 1.3 fps – I haven’t done ANY code optimizations yet.

Yes the following work is:
- Fluid surface reconstruction (it is even harder man…)
- GPU acceleration

Just wait for me…

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值