quote:Original post by TAX
As mentioned in a previous comment: Modelling explosions involve compressible CFD. But I feel anyway, that it might be worth to examine incompressible CFD for use with explosions. Anyways i think it is a good introduction to CFD.
Note that Jos' implementation is compressible; however, his method does not satisfy the Rankine-Hugoniot jump condition, which basically means you'll never see the shock front of the explosion. So-called "upwind" methods are required to capture shocks.
quote:Original post by TAX
1) Voxel representations are huge.
As far as i can see in Jos code each voxel only "communicates" with its neighbours. Therefore I think it would be usefull to compress the voxels and unpack subparts of it when working on it. Does it sound stupid? -And do anyone know any obvious methods for that.
This will possibly save you on memory, but it will absolutely kill you on time. Voxel already will be expensive since you have to update every cell in the voxel each time you update the physics (one or more times each frame?). The only way you're going to get voxel CFD to work in real-time on reasonable hardware is if you make the voxel grid extremely coarse. I'm talking perhaps on the order of 10x10x10 cells. And even that will be limiting your frame rate just due to calcs. Now, using the hybrid method that Jos presents, where your flow properties are carried by particles that are not constrained to the voxel boundaries, you can still get decent looking smoke/clouds (maybe or maybe not fire/explosions) using a coarse grid.
Also, I believe that there are two steps to Jos's method, one being a marching solution. This is the part that allows you to solve each cell update using just its neighbors. But the other part requires solving a system of equations, with as many equations as cells (10 x 10 x 10 = 1000 equations) for every update. I think Jos uses successive relaxation with Gauss-Siedel, but at one time he was going to try Conjugate Gradient. You could use Conjugate-Gradient or multigrid to solve those equations quite quickly, but coding these methods is tricky. And not conducive to only have part of the grid unpacked at once.
quote:Original post by TAX
I guess that my memory limit will be ~1MB. By avoiding floating point variables (Jos mentions in his paper that it is possible.) I can represent each voxel in ~16 bytes. That will allow a 3D voxel with a sidelenghth ~40.
Yes, floats should work well enough for Jos' method. They are not sufficient for more advanced CFD techniques.
But 40 x 40 x 40 = 64 thousand equations for the Poisson solve (see below) and that is prohibitive. No way in hell this will run even at 1 fps on current desktop hardware.
quote:Original post by TAX
I have thourght about working with a sort of tree dividing the voxelspace 8 times at each level. And only subdividing into small voxels at the outer edges of an explosion. Would it be possible? Has anyone done that?
That's a really clever idea! You could have sort of an octree CFD grid. Now, getting the physics of the CFD to work properly a the boundaries of the octree grid will be tricky, and frustrating to implement. But possible. (In the CFD world, there are the concept of multizonal and Chimera grids, which involves using multiple grids of different density to get more accurate results where you need them.)
http://www50.dt.navy.mil/reports/chimera/generation.html
quote:Original post by TAX
2) To make It work in a game, I also need a method to voxelize polygons fast. Perhaps a more simple model of the enviroment will be nescesary?
Yes, I think this would be helpful. Doesn't have to be just boxes, though. Cylinders, cones, things like that can be fast to voxelize.
quote:Original post by TAX
Jos code is implemented in pure C, which makes it a bit tricky to understand. It has taken me alot of time untill now to just unwrapping the code. Now I am stuck at the point in the code where it says that it solves a Poisson to maintain incompressibility?
I'll have to look at that statement. One of his basic flow properties is density, which if it changes means the flow is compressible. And density does change because that is how he drives his flow. So, I wonder what he meant by that. But....
...actually, the Poisson equation is a representation of the so-called "Continuity Equation" which is the equation of conservation of mass. So, that basically makes sure that total mass is constant across the flow field. (Even with density changing, unless you're doing nuclear reactions that convert mass to energy or letting mass leak out of a hole, the total mass inside the container must remain constant and that's what this equation deals with.)
quote:Original post by TAX
In the sourcecode provided by Jos Stam I am having trouble converting the function project() from 2D to 3D. How is that done?
Has anyone experience with this?
I finished all the coursework for a Ph.D in computational aerodynamics, and have experience with this. But that's a big question and I just don't have time to give you a satisfying answer here.
I will say that at some point Jos iterates through the horizontal and vertical cells of his grid, probably in a nested loop. (I haven't looked at his code so I can't say for sure.) This is one place where you'd have to add a third loop for the 3rd direction. The trickiest bit will be to update the Poisson solve. For 2D, the matrix of coefficients for the Poisson solve is a tridiagonal matrix, e.g., only the diagonal and two immediate off-diagonal terms have non-zero members. This means some handy optimizations can be done to the solver. For 3D, the Poisson coefficient matrix will be pentadiagonal, e.g., you'll have the three middle diagonals plus an additional diagonal on top and bottom. And the optimizations aren't really there. But, if Jos is using Conjugage Gradient or Gauss-Siedel with relaxation then he isn't using the tridiagonal optimized method anyway so at least on the solver side you are good. And you'd just have to figure out how to populate the additional 2 diagonals for the coefficient matrix.
Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.
[edited by - grhodes_at_work on October 16, 2003 1:06:24 PM]
[edited by - grhodes_at_work on October 16, 2003 1:06:36 PM]
[edited by - grhodes_at_work on October 16, 2003 1:08:17 PM]