Thu, 4 Mar 2010
By Thomas ten Cate
Last week, I wrote to my fluid dynamics professor for advice on the free surface fluid simulation. It was a positive surprise to see that I had run into exactly the same problems as he had in his research. I must have been doing something right then!
You might recall that one of the problems was “flotsam and jetsam”: loose droplets of water detaching from the main body, and remaining suspended in the air. An effective solution to this problem turns out to be to “stamp” the fluid surface. For each cell on the surface, we determine the approximate surface orientation (horizontal or vertical, with the water above or below). Suppose that for a particular cell the surface is mostly horizontal, and the water is below. Then we take a column of three cells around this cell, and move all fluid in these three cells downward as much as possible. The screenshots below show the difference after the breaking wave has mostly come to rest:
Another problem was fluid loss: because cells cannot be filled with fluid for more than 100%, all values above that were set to 100%. Over time, these small differences added up, resulting in slow evaporation of all the water in the simulation. As I wrote before, there seems to be no simple fix. This new algorithm performs much better in that respect, reducing fluid loss to a mere 0.1% after tens of seconds, which is quite acceptable.
There were many other small improvements to the code, that I implemented based on the FORTRAN code that my professor kindly sent me. If I learned anything about free-surface flows, it is that there are a great many subtleties. It doesn’t seem so hard from the outside; you won’t appreciate all the intricacies until you dive in and write the code.