Realistic Fluid Simulation
Members - Reputation: 104
Posted 18 April 2012 - 12:04 PM
I'm new to this forum, but I thought this might be the right place to ask for advice. I'm trying to create a realistic, physically correct (looking) smoke effect in 2D. For more than a week now, I've been experimenting with different approaches in the fluid dynamics field.
I successfully implemented an Eulerian fixed-grid algorithm (based on this and this article) and it works as expected.
(The cells are not smoothed for debugging purposes).
However I just can't figure out how to implement boundary conditions for rigid bodies in the simulation. Being able to simulate realistic airflow around a ball and turbulences behind a moving object is why I started working on this in the first place. I spent hours googling and reading through countless articles and papers, but all of them just say that you have to account for boundary conditions when setting up the velocity equations or apply a poststep fix, but they never go into details.
I'm also starting to think that a grid based method is not the best for simulating airflow around arbitrary placed and shaped objects, because you would have to use a very high resolution grid to get rid of artifacts. Correct me if I'm wrong.
I also investigated vortex based methods, where you use an array of vortex particles (vortons) to represent the airflow. The vortons aren't fixed, because they are affected by the velocity field they create. So they move around and change their angular velocities. It's a bit more complicated then a fixed velocity grid method, but the real problems only arise once I want to add rigid bodies to the simulation.
Let's say I just calculated the velocity field for the current frame from all the vortons in my simulation and it turns out to be a very simple one:
Now I want to account for the orange ball in this flow. Wether the ball is stationary and the air is moving past it, or the ball is moving to the left in a non-moving field doesn't really matter. In some articles they suggest adding auxiliary vortons somewhere along the surface of the body to redirect the airflow and satisfy the boundary conditions. But I couldn't yet figure out where and what kind of vortons have to be added.
In the above case we could determine the ambient air velocity VA at a point P on the ball surface and place a vorton alongside a line normal to the airflow. Then we specify a vorticity (angular velocity) of the vorton, so that the velocity it creates equals VV = -VA at P. This way all velocity at P is canceled and the boundary conditions are satisfied at P. The problem is, that there are two possible ways to place the vorton (to the right or to the left of the airflow vector). Placing the vorton on the other side also means we have to reverse it's vorticity. How to we find out where to place the vorton? We could use the angle between the normal vector at P and the airflow to separate the vortons into clockwise and counter-clockwise vortons. This would result in something like this (blue: clockwise vorton, red: counter-clockwise vorton):
This looks like to could work, but I'm not sure. What do you think? The air infront of the ball is pushed away, and it sucks in some air behind it. However in the case of a rectangle it won't work:
Using the surface normals to categorize the vortons into CW and CCW ones will result in a row of vortons all turning in the same direction. Instinctively I would categorize them like this:
This looks more like what one would expect (although I'm really not sure), but how could this be implemented? One could use the distance from the edges, but that sounds more like a hack then something stable.
Or maybe I'm completely on the wrong track and there is a better way to do all of this? Any hint, advice or useful link would be very appreciated. Thanks for reading.
Crossbones+ - Reputation: 2485
Posted 18 April 2012 - 10:32 PM
1. A repelling force from the surface, e.g. you either zero out the component of the vector in the direction of the surface normal, or you take the component in the direction of the surface normal and redirect it. The first option means wind slows when hitting the object. The second means it only changes direction. Perhaps a combination depending upon how blunt the impact is.
2. A force equalising air pressure. You don't want a complete vacuum behind your ball. It would tend to recombine in a cone-like manner behind the ball.
Members - Reputation: 104
Posted 19 April 2012 - 08:48 AM
Redirecting velocity vectors at the screen boundaries is how people usually implement a simulation where the smoke isn't supposed to leave the screen. This could probably be applied to objects in the simulation that are placed exactly on cell boundaries, but what if that not the case?
Imagine an upstream airflow in the above situation. At the rectangle's bottom edge, in which cells would I redirect the vectors? The ones that are completely outside (below) the rectangle, the ones on the edge or the ones inside? None of these seem to be a good idea, because either the smoke would be redirected early (making it look like the rectangle had some repellent force on it), or the smoke would go inside of the box. At least that's how I see it. This is what I meant, when I said that a way too high grid resolution would be needed to get rid of artifacts.
And once you add arbitrary polygons and rotations it really looks like a lost cause.
This is why I started investigating the vortex method. Even though you still have to calculate a velocity grid from all the vortons, you can place the vortons at any position, not just on the grid. This made me think I could get better results. But I'm still not any closer to a working prototype.
Members - Reputation: 501
Posted 10 May 2012 - 03:04 PM
To your specific problem, I think at least part of the trick is to not put the vortons on the actual boundary. Instead you offest the vortons a bit from the boundary, but set them up so that they still cancel out the velocity at the boundary surface. This helps eliminate potential singularities, as I understand it. For the case of velocity flow exactly perpendicular to a flat surface, your vortons would happen to be on the surface, but to the left or right of the point on the boundary you're trying to cancel out. For non perpendicular flows, the vorton will be a bit ahead of the surface, at a glancing angle to the point you're trying to cancel out velocity at. Importantly the actual position of these new vortons change based on the relative angle of the incoming flow and the surface.
I'm curious if it's possible to construct something like a vorton, but with surfaces instead of just points.
Like for a sphere, you construct something like a vorton, but instead of causing vorticity, it pushes velocity out in all directions uniformally. That, centered right on top of the sphere and tweaked so that velocity just ahead of the sphere is 0, and added to the background uniform flow, might produce a realistic flow pattern cheaply. I'm not sure exactly, I probably need to think it trough a bit more. At first glance it seems like it would violate some conservation laws, and it would probably only really make sense for a uniform background velocity field. The more chaotic the flow around the sphere, the more likely you'd need to use more than one primitive, no matter what your primitive is (vorton or something else).
Edited by Numsgil, 10 May 2012 - 03:28 PM.
Members - Reputation: 290
Posted 15 May 2012 - 03:11 PM
This guy does a pretty good airfoil simulation using SPH:
His uses ALOT of particles, and definitely isn't real time.
The thing with doing gasses with SPH is that you need to fill the entire domain with particles in order to see the types of fluid effects that you would expect. So in the beginning of the video it looks a little strange as the domain fills in.
Just something to consider
Edited by coderchris, 15 May 2012 - 03:14 PM.