Graphics Reference
In-Depth Information
some small number tol , so that we know the worst case of how compress-
ible our new velocity field could possibly be. The dimensions of tol are one
over time: O (1 / tol ) is a lower bound on how long it will take our inexact
velocity field to compress the fluid by some fraction. Thus tol probably
should be inversely proportional to the time length of our simulation. In
practice, this either doesn't vary a lot(afewsecondsformostshots)orwe
are doing interactive animation with a potentially infinite time length—
so in the end we just pick an arbitrary small fixed number for tol , like
10 6 s 1 .(Thes 1 is one over seconds: remember again that this quan-
tity has dimensions one over time.) Smaller tolerances will result in less
erroneous divergence but will take more iterations (and time) to compute,
so there's a clear trade-off in adjusting this number up or down. 2 This is
particularly important since typically most of the time in a fluid simulation
is spent in the pressure solver: this is the code that usually demands the
most optimizing and tuning.
Typically we will also want to guard against inexact floating-point arith-
metic causing the algorithm not to converge fully, so we stop at a certain
maximum number of iterations. Or, we may have a real-time constraint
that limits the number of iterations we can use. Setting this constraint is
another case of trade-offs: starting out your simulator with the value 100
is reasonable.
A final issue is what the initial guess for pressure should be. One nice
thing about PCG is that if we start with a good guess, we can get to an
acceptable solution much faster. In some circumstances, say when the fluid
has settled down and isn't changing much, the pressure from the last time
step is a very good guess for the next pressure: it won't change much either.
However, these situations usually can easily be solved from an initial guess
of all zeros also. In the more interesting cases (and really, why would you
be simulating fluids that are just sitting still?), the pressure can change
significantly from one time step to the next, or in fact may be defined
on different grid cells anyhow (e.g., as liquid moves from one grid cell to
another) and can't be used. Therefore we usually use the vector of all zeros
as the initial guess.
Pseudocode for the PCG algorithm is shown in Figure 4.5. Be aware
that this statement of PCG uses different symbols than most text books:
I've tried to avoid the use of letters like x and ρ that have other meanings
in the context of fluids.
2 However, one of the great features of PCG is that the rate of convergence tends to
accelerate the further along you go: reducing the tolerance may not slow things down
as much as you think.
Search WWH ::




Custom Search