3
$\begingroup$

One more question about Jos Stam's GDC tutorial on stable fluids: in the advection step on page 8, the timestep for each dimension is implemented as dt * N, where N is the height or width of the grid. This corresponds to a position update:

$x_{prev} = x - \frac{\Delta t}{h} \cdot v_x$

where $h = 1/N$.

But why is $h$ involved in the backtracing of velocity? I thought the time evolution would just be given by $x = x_{prev} + \Delta t \cdot v_x$ without involving the grid size.

$\endgroup$

1 Answer 1

3
$\begingroup$

Stam's code is written in such a way that the coordinates of the cell centers correspond to integers. This way, the cell where a particle ends can be easily determined by rounding (e.g. i0 = (int)x;) Likewise the starting point of backtracking is simply given by (i,j) (see e.g. x = i - dt0 * u[IX(i,j)]). So the computational problem is scaled such it makes computation simpler / easier to understand.

$\endgroup$
1
  • $\begingroup$ Aha, of course. I forgot that the grid implicitly has unit length and height. $\endgroup$
    – jogloran
    Sep 27, 2021 at 17:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.