我正在寻找一种算法,该算法将描述流体在高度图表面上传播时的瞬态行为。我在t = 0时的起始条件是:
我想要的是一种能够在t'= t + 1处计算流体高度矩阵F的新值的算法。在任何时候,我都可以通过v = a *(F(x,y) - H(x,y))来计算给定点处的流体体积。该算法的理想属性是:
我正在寻找的一个简单例子是:
该算法将描述在几个时间步长上在5x5矩阵上展开的流体“列”。最终算法将在所有位置以10/25的均匀高度稳定下来,但我真的对两者之间发生的事情感兴趣。
我试图搜索这种算法,但我能找到的只是描述流体内颗粒行为的方程式,这对于我的目的而言过于颗粒化。有没有人知道我可以参考这个问题的任何好的来源,或者可能满足我需要的现有算法。
答案 0 :(得分:5)
O is your starting fluid-column
o are diffusing columns
************************
X X X X X
X X X X X
X X O X X
X X X X X
X X X X X
************************
--Get the Laplacian of the heights of each neighbour and accumulate results
in a separate matrix
--Then apply the second matrix into first one to do synchronous diffusion
--go to Laplacian step again and again
************************
X X X X X
X X o X X
X o O o X
X X o X X
X X X X X
************************
************************
X X . X X
X . o . X
. o O o .
X . o . X
X X . X X
************************
************************
X X . X X
X o o o X
. o o o .
X o o o X
X X . X X
************************
************************
X X . X X
X o o o X
. o o o .
X o o o X
X X . X X
************************
************************
X . o . X
. o o o .
o o o o o
. o o o .
X . o . X
************************
************************
. . . . .
. o o o .
. o o o .
. o o o .
. . . . .
************************
************************
. . . . .
. . . . .
. . o . .
. . . . .
. . . . .
************************
************************
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
************************
sorry for very low height-resolution
Laplacian's place in diffusion
Diffusion's place in Navier-Stokes equations
简单算法(伪):
get a cell's value in a.
get neighbour cells' values in b(sum of them)
put b/4.0 in c(getting 4 cells' values)
add a to c
build a matrix with this algorithm
apply the matrix onto old one
goto step 1
更难的算法(伪):
apply discrete-Laplacian-operator on all neighbours(finite-differences thing)
put solution in c height-map
subtract or add c to/from starting height-map
goto step 1
Jos Stam's fluid-solver对于扩散部分也有类似的东西。