Vous êtes sur la page 1sur 8

Stable Fluids

Jos Stam

Alias wavefront

Abstract
Building animation tools for uid-like motions is an important and challenging problem with many applications in computer graphics. The use of physics-based models for uid ow can greatly assist in creating such tools. Physical models, unlike key frame or procedural based techniques, permit an animator to almost effortlessly create interesting, swirling uid-like behaviors. Also, the interaction of ows with objects and virtual forces is handled elegantly. Until recently, it was believed that physical uid models were too expensive to allow real-time interaction. This was largely due to the fact that previous models used unstable schemes to solve the physical equations governing a uid. In this paper, for the rst time, we propose an unconditionally stable model which still produces complex uid-like ows. As well, our method is very easy to implement. The stability of our model allows us to take larger time steps and therefore achieve faster simulations. We have used our model in conjuction with advecting solid textures to create many uid-like animations interactively in two- and three-dimensions. CR Categories: I.3.7 [Computer Graphics]: Three-Dimensional Graphics and RealismAnimation Keywords: animation of uids, Navier-Stokes, stable solvers, implicit elliptic PDE solvers, interactive modeling, gaseous phenomena, advected textures

1 Introduction
One of the most intriguing problems in computer graphics is the simulation of uid-like behavior. A good uid solver is of great importance in many different areas. In the special effects industry there is a high demand to convincingly mimic the appearance and behavior of uids such as smoke, water and re. Paint programs can also benet from uid solvers to emulate traditional techniques such as watercolor and oil paint. Texture synthesis is another possible application. Indeed, many textures result from uid-like processes, such as erosion. The modeling and simulation of uids is, of course, also of prime importance in most scientic disciplines and in engineering. Fluid mechanics is used as the standard mathematical framework on which these simulations are based. There is a consensus among scientists that the Navier-Stokes equations are a very good model for uid ow. Thousands of books and

Alias wavefront, 1218 Third Ave, 8th Floor, Seattle, WA 98101, U.S.A. jstam@aw.sgi.com

articles have been published in various areas on how to compute these equations numerically. Which solver to use in practice depends largely on the problem at hand and on the computing power available. Most engineering tasks require that the simulation provide accurate bounds on the physical quantities involved to answer questions related to safety, performance, etc. The visual appearance (shape) of the ow is of secondary importance in these applications. In computer graphics, on the other hand, the shape and the behavior of the uid are of primary interest, while physical accuracy is secondary or in some cases irrelevant. Fluid solvers, for computer graphics, should ideally provide a user with a tool that enables her to achieve uid-like effects in real-time. These factors are more important than strict physical accuracy, which would require too much computational power. In fact, most previous models in computer graphics were driven by visual appearance and not by physical accuracy. Early ow models were built from simple primitives. Various combinations of these primitives allowed the animation of particles systems [15, 17] or simple geometries such as leaves [23]. The complexity of the ows was greatly improved with the introduction of random turbulences [16, 20]. These turbulences are mass conserving and, therefore, automatically exhibit rotational motion. Also the turbulence is periodic in space and time, which is ideal for motion texture mapping [19]. Flows built up from a superposition of ow primitives all have the disadvantage that they do not respond dynamically to user-applied external forces. Dynamical models of uids based on the Navier-Stokes equations were rst implemented in two-dimensions. Both Yaeger and Upson and Gamito et al. used a vortex method coupled with a Poisson solver to create two-dimensional animations of uids [24, 8]. Later, Chen et al. animated water surfaces from the pressure term given by a twodimensional simulation of the Navier-Stokes equations [2]. Their method unlike ours is both limited to two-dimensions and is unstable. Kass and Miller linearize the shallow water equations to simulate liquids [12]. The simplications do not, however, capture the interesting rotational motions characteristic of uids. More recently, Foster and Metaxas clearly show the advantages of using the full three-dimensional Navier-Stokes equations in creating uid-like animations [7]. Many effects which are hard to key frame manually such as swirling motion and ows past objects are obtained automatically. Their algorithm is based mainly on the work of Harlow and Welch in computational uid dynamics, which dates back to 1965 [11]. Since then many other techniques which Foster and Metaxas could have used have been developed. However, their model has the advantage of being simple to code, since it is based on a nite differencing of the Navier-Stokes equations and an explicit time solver. Similar solvers and their source code are also available from the book of Griebel et al. [9]. The main problem with explicit solvers is that the numerical scheme can become unstable for large time-steps. Instability leads to numerical simulations that blow-up and therefore have to be restarted with a smaller time-step. The instability of these explicit algorithms sets serious limits on speed and interactivity. Ideally, a user should be able to interact in real-time with a uid solver without having to worry about possible blow ups. In this paper, for the rst time, we propose a stable algorithm that solves the full Navier-Stokes equations. Our algorithm is very

easy to implement and allows a user to interact in real-time with three-dimensional uids on a graphics workstation. We achieve this by using time-steps much larger than the ones used by Foster and Metaxas. To obtain a stable solver we depart from Foster and Metaxas method of solution. Instead of their explicit Eulerian schemes, we use both Lagrangian and implicit methods to solve the Navier-Stokes equations. Our method cannot be found in the computational uids literature, since it is custom made for computer graphics applications. The model would not be accurate enough for most engineering applications. Indeed, it suffers from too much numerical dissipation, i.e., the ow tends to dampen too rapidly as compared to actual experiments. In a computer graphical application, on the other hand, this is not so bad, especially in an interactive system where the ow is kept alive by an animator applying external forces. In fact, a ow which does not dampen at all might be too chaotic and difcult to control. As our results demonstrate we are able to produce nice swirling ows despite the numerical dissipation. In this paper we apply our ows mainly to the simulation of gaseous-like phenomena. We employ our solver to update both the ow and the motion of densities within the ow. To further increase the complexity of our animations we advect texture coordinates along with the density [13]. In this manner we are able to synthesize highly detailed wispy gaseous ows even with low resolution grids. We believe that the combination of physics-based uid solvers and solid textures is the most promising method of achieving highly complex ows in computer graphics. The next section presents the Navier-Stokes equations and the derivation which leads to our method of solution. That section contains all the fundamental ideas and techniques needed to obtain a stable uids solver. Since it relies on sophisticated mathematical techniques, it is written in a mathematical physics jargon which should be familiar to most computer graphics researchers working in physics-based modeling. The application oriented reader who wishes only to implement our solver can skip Section 2 entirely and go straight to Section 3. There we describe our implementation of the solver, providing sufcient information to code our technique. Section 4 is devoted to several applications that demonstrate the power of our new solver. Finally, in Section 5 we conclude and discuss future research. To keep this within the connes of a short paper, we have decided not to include a tutorial-type section on uid dynamics, since there are many excellent textbooks which provide the necessary background and intuition. Readers who do not have a background in uid dynamics and who wish to fully understand the method in this paper should therefore consult such a text. Mathematically inclined readers may wish to start with the excellent book by Chorin and Marsden [3]. Readers with an engineering bent on the other hand can consult the didactic book by Abbott [1]. Also, Foster and Metaxas paper does a good job of introducing the concepts from uid dynamics to the computer graphics community.

time , then the evolution of these quantities over time is given by the Navier-Stokes equations [3]:

compact version of the Navier-Stokes equations. Eq. 2 is a vector equation for the three (two in two-dimensions) components of the velocity eld. The denotes a dot product between vecis the vector of spatial partial derivators, while the symbol tives. More precisely, in two-dimensions and in three-dimensions. We have also used . The Navier-Stokes equations the shorthand notation are obtained by imposing that the uid conserves both mass (Eq. 1) and momentum (Eq. 2). We refer the reader to any standard text on uid mechanics for the actual derivation. These equations also have to be supplemented with boundary conditions. In this paper we will consider two types of boundary conditions which are useful in practical applications: periodic boundary conditions and xed boundary conditions. In the case of periodic boundaries the uid is dened on an -dimensional torus ( ). In this case there are no walls, just a uid which wraps around. Although such uids are not encountered in practice, they are very useful in creating evolving texture maps. Also, these boundary conditions lead to a very elegant implementation that uses the fast Fourier transform as shown below. The second type of boundary condition that we consider is when the uid lies in some bounded domain . In that case, the boundary conditions are given by a function dened on the boundary of the domain. See Foster and Metaxas work for a good discussion of these boundary conditions in the case of a hot uid [7]. In any case, the boundary conditions should be such that the normal component of the velocity eld is zero at the boundary; no matter should traverse walls. The pressure and the velocity elds which appear in the NavierStokes equations are in fact related. A single equation for the velocity can be obtained by combining Eq. 1 and Eq. 2. We briey outline the steps that lead to that equation, since it is fundamental to our algorithm. We follow Chorin and Marsdens treatment of the subject (p. 36ff, [3]). A mathematical result, known as the Helmholtz-Hodge Decomposition, states that any vector eld can uniquely be decomposed into the form:

"$# % (1) & 0 1 " "87 # " &  () '  ' 2 4365 3@9A (2) where 5 is the kinematic viscosity of the uid, 2 is its density and 9 is an external force. Some readers might be unfamiliar with this # " &DC0&  &DC0&  " E &DC0&  &DC0&  &DC0" &" 7 B  "E#F" G

!

G$IHQP

&R

TS R

Stable Navier-Stokes

2.1 Basic Equations


In this section we present the Navier-Stokes equations along with the manipulations that lead to our stable solver. A uid whose density and temperature are nearly constant is described by a velocity eld and a pressure eld . These quantities generally vary both in space and in time and depend on the boundaries surrounding the uid. We will denote the spatial coordinate by , which for twoand three-dimensional uids is dimensional uids is equal to . We have decided not to specialize our results for a particular dimension. All results are thus valid for both twodimensional and three-dimensional ows unless stated otherwise. Given that the velocity and the pressure are known for some initial

 

" W UV "X # 3 4 (3) W where has zero divergence: Y and is a scalar eld. Any vector eld is the sum of a mass conserving eld and a gradient eld. This result allows us to dene an operator ` which projects any vector eld U onto its divergence free part a`bU . The operator is" in fact dened implicitly by multiplying both sides of Eq. 3 by : "$# UV "87QWdc (4) W This is a Poisson equation for the scalar eld with the Neumann & boundary condition e0f i on R . A solution to this equation is h e g used to compute the projection : !`bUVpUq' "4Wdc
If we apply this projection operator on both sides of Eq. 2 we obtain a single equation for the velocity:

& # "  365 "87 3t9huv &  !`$rs') 0 (5) " wi . This is where we have used the fact that ` and ` our fundamental equation from which we will develop a stable uid

solver.

u .u =0 w 4 w 0
Figure 1: One simulation step of our solver is composed of steps. The rst three steps may take the eld out of the space of divergent free elds. The last projection step ensures that the eld is divergent free after the entire simulation step.

w1

w2

w3

is the spacing of their computational grid. Therefore, for small separations and/or large velocities, very small time steps have to be taken. On the other hand, we use a totally different approach which results in an unconditionally stable solver. No matter how big the time step is, our simulations will never blow up. Our method is based on a technique to solve partial differential equations known as the method of characteristics. Since this method is of crucial importance in obtaining our stable solver, we provide all the mathematical details in Appendix A. The method, however, can be understood intuitively. At each time step all the uid particles are moved by the velocity of the uid itself. , Therefore, to obtain the velocity at a point at the new time we backtrace the point through the velocity eld over a time . This denes a path corresponding to a partial streamline of the velocity eld. The new velocity at the point is then set to the velocity that the particle, now at , had at its previous ago: location a time

C T T , where SR )HPQSR U

)

)

x p(x,s) p(x,t) 0 s t

U 7 TpU0)0 T ')s c

T3W0

 3) UV) F

Figure 2: To solve for the advection part, we trace each point of the eld backward in time. The new velocity at is therefore the velocity that the particle had a time ago at the old location .

T ')

)

2.2 Method of Solution

Eq. 5 is solved from an initial state by marching through time with a time step . Let us assume that the eld has been resolved at a time and that we wish to compute the eld at a later time . We resolve Eq. 5 over the time span in four steps. We start from the solution of the previous time step and then sequentially resolve each term on the right hand side of Eq. 5, followed by a projection onto the divergent free elds. The general procedure is illustrated in Figure 1. The steps are:

 3)

)

TsA

Figure 2 illustrates the above. This method has several advantages. Most importantly it is unconditionally stable. Indeed, from the above equation we observe that the maximum value of the new eld is never larger than the largest value of the previous eld. Secondly, the method is very easy to implement. All that is required in practice is a particle tracer and a linear interpolator (see next Section). This method is therefore both stable and simple to implement, two highly desirable properties of any computer graphics uid solver. We employed a similar scheme to move densities through user-dened velocity elds [19]. Versions of the method of characteristics were also used by other researchers. The application was either employed in visualizing ow elds [13, 18] or improving the rendering of gas simulations [21, 5]. Our application of the technique is fundamentally different, since we use it to update the velocity eld, which previous researchers did not dynamically animate. The third step solves for the effect of viscosity and is equivalent to a diffusion equation:

U v T s

)

& U 7 "87 c &  !5 U 7

steps. We now explain how each step is computed in more detail. The easiest term to solve is the addition of the external force . If we assume that the force does not vary considerably during the time step, then

FE$# & 54 D !#"% #  $#&   #  2"%13$# &54  7 "% 8@$# 9&A ! % " ! # ! 7 U  '(' U0)0  '6' U  '6' UCBA  '(' UCGF  c The solution at time 3)  is then given by the last velocity eld: T 3H) pUCF G  . A simulation is obtained by iterating these

This is a standard equation for which many numerical procedures have been developed. The most straightforward way of solving this and then to do equation is to discretize the diffusion operator an explicit time step as Foster and Metaxas did [7]. However, this method is unstable when the viscosity is large. We prefer, therefore, to use an implicit method:

"7

U0) TpU  3I) 9T s

is a good approximation of the effect of the force on the eld over the time step . In an interactive system this is a good approximation, since forces are only applied at the beginning of each time step. The next step accounts for the effect of advection (or convection) of the uid on itself. A disturbance somewhere in the uid propagates according to the expression . This term makes the Navier-Stokes equations non-linear. Foster and Metaxas resolved this component using nite differencing. Their method is stable only when the time step is sufciently small such that

)

where is the identity operator. When the diffusion operator is discretized, this leads to a sparse linear system for the unknown eld . Solving such a system can be done efciently, however (see below). The fourth step involves the projection step, which makes the resulting eld divergence free. As pointed out in the previous subsection this involves the resolution of the Poisson problem dened by Eq. 4:

X UB C

rYX 't5() "87 u UCBF TpU 7 Q

"87QW $ " #C UB

UCG pUCB ' "4Wdc

# "  ') 

The projection step, therefore, requires a good Poisson solver. Foster and Metaxas solved a similar equation using a relaxation scheme. Relaxation schemes, though, have poor convergence and usually require many iterations. Foster and Metaxas reported that they obtained good results even after a very small number of relaxation steps. However, since we are using a different method to resolve for the advection step, we must use a more accurate method.

Indeed, the method of characteristics is more precise when the eld is close to divergent free. More importantly from a visual point of view, the projection step forces the elds to have vortices which result in more swirling-like motions. For these reasons we have used a more accurate solver for the projection step. The Poisson equation, when spatially discretized, becomes a sparse linear system. Therefore, both the projection and the viscosity steps involve the solution of a large sparse system of equations. Multigrid methods, for example, can solve sparse linear systems in linear time [10]. Since our advection solver is also linear in time, the complexity of our proposed algorithm is of complexity . Foster and Metaxas solver has the same complexity. This performance is theoretically optimal since for a complicated uid, any algorithm has to consult at least each cell of the computational grid.

8 

Figure 3: The values of the discretized elds are dened at the center of the grid cells.

uid and a texture coordinate. The evolution of this scalar eld is conveniently described by an advection diffusion type equation:

2.3 Periodic Boundaries and the FFT


When we consider a domain with periodic boundary conditions, our algorithm takes a particularly simple form. The periodicity allows us to transform the velocity into the Fourier domain:

&

# " b3 8 " 7 ' b3 &  $' h


8 8 @9BA DCEA68 GFHA

T s '6' s c " In the Fourier domain the gradient operator is equivalent to 1 the multiplication by , where v ' . Consequently, both the diffusion step and the projection step are much simpler to solve.

where 9BA is a diffusion constant, C"A is a dissipation rate and FIA is a source term. This equation is very similar in form to the NavierStokes equation. Indeed, it includes an advection term, a diffusion term and a force term FHA . All these terms can be resolved exactly in the same way as the velocity of the uid. The dissipation term not present in the Navier-Stokes equation is solved as follows over a time-step:

Indeed the diffusion operator and the projection operators in the Fourier domain are

16 3 1 5()#  7 `bUB'6' ` U  U ' 7 U  T T . The operator ` projects the vector U  onto the where plane which is normal to the wave number . The Fourier transform
      

X ' 5() " 7 '6'

1 3I)  T 3I)T T s c


CEA P8 8

of the velocity of a divergent free eld is therefore always perpendicular to its wavenumbers. The diffusion can be interpreted as a low pass lter whose decay is proportional to both the time step and the viscosity. These simple results demonstrate the power of the Fourier transform. Indeed, we are able to completely transcribe our solver in only a couple of lines. All that is required is a particle tracer and a fast Fourier transform (FFT). FourierStep( , add force: advect: transform: diffuse: project: transform:

Similar equations were used by Stam and Fiume to simulate re and other gaseous phenomena [21]. However, their velocity elds were not computed dynamically. We hope that the material in this section has convinced the reader that our stable solver is indeed based on the full Navier-Stokes equations. Also, we have pointed to the numerical techniques which should be used at each step of our solver. We now proceed to describe the implementation of our model in more detail.

Our Solver

3.1 Setup
Our implementation handles both the motion of uids and the propagation by the uid of any number of substances like mass-density, temperature or texture coordinates. Each quantity is dened on either a two-dimensional (NDIM=2) or three-dimensional (NDIM=3) grid, depending on the application. The grid is dened by its physical dimensions: origin O[NDIM] and length L[NDIM] of each side, and by its number of cells N[NDIM] in each coordinate. This in turn determines the size of each voxel D[i]=L[i]/N[i]. The denition of the grid is an input to our program which is specied by the animator. The velocity eld is dened at the center of each cell as shown in Figure 3. Notice that previous researchers, e.g., [7], dened the velocity at the boundaries of the cells. We prefer the cell-centered grid since it is more straightforward to implement. We allocate two grids for each component of the velocity: U0[NDIM] and U1[NDIM]. At each time step of our simulation one grid corresponds to the solution obtained in the previous step. We store the new solution in the second grid. After each step, the grids are swapped. We also allocate two grids to hold a scalar eld corresponding to a substance transported by the ow. Although our implementation can handle any number of substances, for the sake of clarity we present only the algorithm for one eld in this section. This scalar quantity is stored in the grids S0 and S1. The speed of interactivity is controlled by a single time step dt, which can be as large as the animator wishes, since our algorithm is stable.

UCG , ) ): U U0 )vpU 3I 7 U U 7  pU0)0 ) U T 7 9 ') UCBF T U 7  C 1 365() 7  UG `C C UB ) UG C UG C


!""#%$  '&  ( !""#0) $1 &

Since the Fourier transform is of complexity 32 4657 , this method is theoretically slightly more expensive than a method of solution relying on multi-grid solvers. However, this method is very easy to implement. We have used this algorithm to generate the liquid textures of Section 4.

2.4 Moving Substances through the Fluid


A non-reactive substance which is injected into the uid will be advected by it while diffusing at the same time. Common examples of this phenomenon include the patterns created by milk stirred in coffee or the smoke rising from a cigarette. Let 8 be any scalar quantity which is moved through the uid. Examples of this quantity include the density of dust, smoke or cloud droplets, the temperature of a

The physical properties of the uid are a function of its viscosity visc alone. By varying the viscosity, an animator can simulate a wide range of substances ranging from glue-like matter to highly turbulent ows. The properties of the substance are modeled by a diffusion constant kS and a dissipation rate aS. Along with these parameters, the animator also must specify the values of these elds on the boundary of the grid. There are basically two types: periodic or xed. The boundary conditions can be of a different type for each coordinate. When periodic boundary conditions are chosen, the uid wraps around. This means that a piece of uid which leaves the grid on one side reenters the grid on the opposite side. In the case of xed boundaries, the value of each physical quantity must be specied at the boundary of the grid. The simplest method is to set the eld to zero at the boundary. We refer the reader to Foster and Metaxas paper for an excellent description of different boundary conditions and their resulting effects [7]. In the results section we describe the boundary conditions chosen for each animation. For the special case when the boundary conditions are periodic in each coordinate, a very elegant solver based on the fast Fourier transform can be employed. This algorithm is described in Section 2.3. We do not repeat it here since the solver in this section is more general and can handle both types of boundary conditions. The uid is set into motion by applying external forces to it. We have written an animation system in which an animator with a mouse can apply directional forces to the uid. The forces can also be a function of other substances in the uid. For example, a temperature eld moving through the uid can produce buoyant and turbulent forces. In our system we allow the user to create all sorts of dependencies between the various elds, some of which are described in the results section of this paper. We do not describe our animation system in great detail since its functionality should be evident from the examples of the next section. Instead we focus on our simulator, which takes the forces and parameters set by the animator as an input.

for(i=0;i<NDIM;i++) addForce ( U0[i], F[i], dt ); for(i=0;i<NDIM;i++) Transport ( U1[i], U0[i], U0, dt ); for(i=0;i<NDIM;i++) Diffuse ( U0[i], U1[i], visc, dt ); Project ( U1, U0, dt );

The general structure of the scalar eld solver is very similar to the above. It involves four steps: add the source, transport the eld by the velocity, diffuse and nally dissipate the eld. The scalar eld solver shares some of the routines called by the velocity solver: Sstep ( S1, S0, k, a, U, source, dt ) addForce ( S0, source, dt ); Transport ( S1, S0, U, dt ); Diffuse ( S0, S1, k, dt ); Dissipate ( S1, S0, a, dt );

The addForce routine adds the force eld multiplied by the time step to each value of the eld. The dissipation routine Dissipate divides each element of the rst array by 1+dt*a and stores it in the new array. The Transport routine is a key step in our simulation. It accounts for the movement of the substance due to the velocity eld. More importantly it is used to resolve the nonlinearity of the Navier-Stokes equations. The general structure of this routine (in three-dimensions) is Transport ( S1, S0, U, dt ) for each cell (i,j,k) do X = O+(i+0.5,j+0.5,k+0.5)*D; TraceParticle ( X, U, -dt, X0 ); S1[i,j,k] = LinInterp ( X0, S0 ); end

3.2 The Simulator


Once we worked out the mathematics underlying the Navier-Stokes equations in Section 2, our implementation became straightforward. We wish to emphasize that the theoretical developments of Section 2 are in no way gratuitous but are immensely useful in coding compact solvers. In particular, casting the problem into a mathematical setting has allowed us to take advantage of the large body of work done in the numerical analysis of partial differential equations. We have written the solver as a separate library of routines that are called by the interactive animation system. The entire library consists of only roughly 500 lines of C code. The two main routines of this library update either the velocity eld Vstep or a scalar eld Sstep over a given time step. We assume that the external force is given by an array of vectors F[NDIM] and that the source is given by an array Ssource for the scalar eld. The general structure of our simulator looks like while ( simulating ) $ /* handle display and user interaction */ /* get forces F and sources Ssource from the UI */ Swap(U1,U0); Swap(S1,S0); Vstep ( U1, U0, visc, F, dt ); Sstep ( S1, S0, kS, aS, U1, Ssource, dt );
&

The velocity solver is composed of four steps: the forces are added to the eld, the eld is advected by itself, the eld diffuses due to viscous friction within the uid, and in the nal step the velocity is forced to conserve mass. The general structure of this routine is: Vstep ( U1, U0, visc, F, dt )

The routine TraceParticle traces a path starting at X through the eld U over a time -dt. The endpoint of this path is the new point X0. We use both a simple second order Runge-Kutta (RK2) method for the particle trace [14] and an adaptive particle tracer, which subsamples the time step only in regions of high velocity gradients, such as near object boundaries. The routine LinInterp linearly interpolates the value of the scalar eld S at the location X0. We note that we did not use a higher order interpolation, since this might lead to instabilities due to the oscillations and overshoots inherent in such interpolants. On the other hand, higher order spline approximants may be used, though these tend to smooth out the resulting ows. To solve for the diffusion (Diffuse) and to perform the projection (Project) we need a sparse linear solver SolveLin. The best theoretical choice is the multi-grid algorithm [10]. However, we used a solver from the FISHPAK library since it was very easy to incorporate into our code and gave good results [22]1 . In practice, it turned out to be faster than our implementation of the multi-grid algorithm. In Appendix B, we show exactly how these routines are used to perform both the Diffuse step and the Project step. These routines are ideal for domains with no internal boundaries. When complex boundaries or objects are within the ow, one can either use a sophisticated multi-grid solver or a good relaxation routine [9]. In any case, our simulator can easily accomodate new solvers.
1 FISHPAK

is available from http://www.netlib.org.

Results

Acknowledgments
I would like to thank Marcus Grote for his informed input on uid dynamics and for pointing me to reference [3]. Thanks to Duncan Brinsmead for his constructive criticisms all along. Thanks also to Pamela Jackson for carefully proofreading the paper and to Brad Clarkson for his help with creating the videos.

Our Navier-Stokes solver can be used in many applications requiring uid-like motions. We have implemented both the two- and the three-dimensional solvers in an interactive modeler that allows a user to interact with the uids in real-time. The motion is modeled by either adding density into the uid or by applying forces. The evolution of the velocity and the density is then computed using our solver. To further increase the visual complexity of the ows, we add textural detail to the density. By moving the texture coordinates using the scalar solver as well, we achieve highly detailed ows. To compensate for the high distortions that the texture maps undergo, we use three sets of texture coordinates which are periodically reset to their initial (unperturbed) values. At every moment the resulting texture map is the superposition of these three texture maps. This idea was rst suggested by Max et al. [13]. Figure 4.(a) shows a sequence of frames from an animation where the user interacts with one of our liquid textures. The gure on the backcover of the SIGGRAPH proceedings is another frame ). of a similar sequence with a larger grid size ( Figures 4.(b) through 4.(g) show frames from various animations that we generated using our three-dimensional solver. In each case the animations were created by allowing the animator to place density and apply forces in real-time. The gases are volume rendered using the three-dimensional hardware texture mapping capabilities of our SGI Octane workstation. We also added a single pass that computes self-shadowing effects from a directional light source in a xed position. It should be evident that the quality of the renderings could be further improved using more sophisticated rendering to with hardware or software. Our grid sizes ranged from frame rates fast enough to monitor the animations while being able to control their behavior. In most of these animations we added a noise term which is proportional to the amount of density (the factor of proportionality being a user dened parameter). This produced nice billowing motions in some of our animations. In Figures 4.(d)-(e) we used a fractal texture map, while in Figure 4.(g) we used a texture map consisting of evenly spaced lines. All of our animations were created on an SGI Octane workstation with a R10K processor and 192 Mbytes of memory.

A Method of Characteristics
The method of characteristics can be used to solve advection equations of the type

& T s &  $'  #0" T s


8

 8

TA Q
8

1F7

P B F

! sAp c  sT s  sQ s be the value of the eld along the Now let sT characteristic passing through the point at  $ . The variation of this quantity over time can be computed using the chain rule of differentiation: & #0" c  &  3 8! This shows that the value of the scalar does not vary along the streamlines. In particular, we have s sAv  . Therefore, the initial eld and the characteristics entirely dene the solution to the advection problem. The eld for a given time  and location is computed by rst tracing the location back in time along the characteristic to get the point , and then evaluating the

 8 8

where 8 is a scalar eld, is a steady vector eld and 8 is the eld at time . Let denote the characteristics of the vector eld which ow through the point at :

vY

s

initial eld at that point:


8

Conclusions

sQ sT  c We use this method to solve the advection equation over a time interval   3 ) for the uid. In this case, w T s and is any of the components of the uids velocity at time  .
8



The motivation of this paper was to create a general software system that allows an animator to design uid-like motions in real time. Our initial intention was to base our system on Foster and Metaxas work. However, the instabilities inherent in their method forced us to develop a new algorithm. Our solver has the property of being unconditionally stable and it can handle a wide variety of uids in both two- and three-dimensions. The results that accompany this paper clearly demonstrate that our solver is powerful enough to allow an animator to achieve many uid-like effects. We therefore believe that our solver is a substantial improvement over previous work in this area. The work presented here does not, however, discredit previous, more visually oriented models. In particular, we believe that the combination of our uid solvers with solid textures, for example, may be a promising area of future research [4]. Our uid solvers can be used to generate the overall motion, while the solid texture can add additional detail for higher quality animations. Also we have not addressed the problem of simulating uids with free boundaries, such as water [6]. This problem is considerably more difcult, since the geometry of the boundary evolves dynamically over time. We hope, however, that our stable solvers may be applied to this problem as well. Also, we wish to extend our solver to nite element boundary-tted meshes. We are currently investigating such extensions.

B FISHPAK Routines
The linear solver POIS3D from FISHPAK is designed to solve a general system of nite difference equations of the type: K1*(S[i-1,j,k]-2*S[i,j,k]+S[i+1,j,k]) + K2*(S[i,j-1,k]-2*S[i,j,k]+S[i,j+1,k]) + A[k]*S[i,j,k-1]+B[k]*S[i,j,k]+ . For the diffusion solver, the values of the constants on the left hand side are: K1 = K2 = A[k] B[k] -dt*k/(D[0]*D[0]), -dt*k/(D[1]*D[1]), = C[k] = -dt*k/(D[2]*D[2]) and = 1+2*dt*k/(D[2]*D[2]),

while the right hand side is equal to the grid containing the previous solution: F=S0. In the projection step these constants are equal to K1 = 1/(D[0]*D[0]), K2 = 1/(D[1]*D[1]), A[k] = C[k] = 1/(D[2]*D[2]) and B[k] = -2/(D[2]*D[2]),

while the right hand side is equal to the divergence of the velocity eld: F[i,j,k] = 0.5*((U[i+1,j,k]-U[i-1,j,k])/D[0]+ (U[i,j+1,k]-U[i,j-1,k])/D[1]+ (U[i,j,k+1]-U[i,j,k-1])/D[2]). The gradient of the solution is then subtracted from the previous solution: U1[0][i,j,k] = U0[0][i,j,k] 0.5*(S[i+1,j,k]-S[i-1,j,k])/D[0], U1[1][i,j,k] = U0[1][i,j,k] 0.5*(S[i,j+1,k]-S[i,j-1,k])/D[1], U1[2][i,j,k] = U0[2][i,j,k] 0.5*(S[i,j,k+1]-S[i,j,k-1])/D[2]. The FISHPAK routine is also able to handle different types of boundary conditions, both periodic and xed.

[12] M. Kass and G. Miller. Rapid, Stable Fluid Dynamics for Computer Graphics. ACM Computer Graphics (SIGGRAPH 90), 24(4):4957, August 1990. [13] N. Max, R. Craws, and D. Williams. Visualizing Wind Velocities by Advecting Cloud Textures. In Proceedings of Visualization 92, pages 179183, Los Alamitos CA, October 1992. IEEE CS Press. [14] W. H. Press, B. P. Flannery, S. A. Teukolsky, and W. T. Vetterling. Numerical Recipes in C. The Art of Scientic Computing. Cambridge University Press, Cambridge, 1988. [15] W. T. Reeves. Particle Systems. A Technique for Modeling a Class of Fuzzy Objects. ACM Computer Graphics (SIGGRAPH 83), 17(3):359376, July 1983. [16] M. Shinya and A. Fournier. Stochastic Motion - Motion Under the Inuence of Wind. In Proceedings of Eurographics 92, pages 119128, September 1992. [17] K. Sims. Particle Animation and Rendering Using Data Parallel Computation. ACM Computer Graphics (SIGGRAPH 90), 24(4):405413, August 1990. [18] K. Sims. Choreographed Image Flow. The Journal Of Visualization And Computer Animation, 3:3143, 1992. [19] J. Stam. A General Animation Framework for Gaseous Phenomena. ERCIM Research Report, R047, January 1997. http://www.ercim.org/publications/technical reports/047-abstract.html. [20] J. Stam and E. Fiume. Turbulent Wind Fields for Gaseous Phenomena. In Proceedings of SIGGRAPH 93, pages 369 376. Addison-Wesley Publishing Company, August 1993. [21] J. Stam and E. Fiume. Depicting Fire and Other Gaseous Phenomena Using Diffusion Processes. In Proceedings of SIGGRAPH 95, pages 129136. Addison-Wesley Publishing Company, August 1995. [22] P. N. Swarztrauber and R. A. Sweet. Efcient Fortran Subprograms for the Solution of Separable Elliptic Partial Differential Equations. ACM Transactions on Mathematical Software, 5(3):352364, September 1979. [23] J. Wejchert and D. Haumann. Animation Aerodynamics. ACM Computer Graphics (SIGGRAPH 91), 25(4):1922, July 1991. [24] L. Yaeger and C. Upson. Combining Physical and Visual Simulation. Creation of the Planet Jupiter for the Film 2010. ACM Computer Graphics (SIGGRAPH 86), 20(4):8593, August 1986.

References
[1] M. B. Abbott. Computational Fluid Dynamics: An Introduction for Engineers. Wiley, New York, 1989. [2] J. X. Chen, N. da Vittoria Lobo, C. E. Hughes, and J. M. Moshell. Real-Time Fluid Simulation in a Dynamic Virtual Environment. IEEE Computer Graphics and Applications, pages 5261, May-June 1997. [3] A. J. Chorin and J. E. Marsden. A Mathematical Introduction to Fluid Mechanics. Springer-Verlag. Texts in Applied Mathematics 4. Second Edition., New York, 1990. [4] D. Ebert, K. Musgrave, D. Peachy, K. Perlin, and S. Worley. Texturing and Modeling: A Procedural Approach. AP Professional, 1994. [5] D. S. Ebert, W. E. Carlson, and R. E. Parent. Solid Spaces and Inverse Particle Systems for Controlling the Animation of Gases and Fluids. The Visual Computer, 10:471483, 1994. [6] N. Foster and D. Metaxas. Realistic Animation of Liquids. Graphical Models and Image Processing, 58(5):471 483, 1996. [7] N. Foster and D. Metaxas. Modeling the Motion of a Hot, Turbulent Gas. In Computer Graphics Proceedings, Annual Conference Series, 1997, pages 181188, August 1997. [8] M. N. Gamito, P. F. Lopes, and M. R. Gomes. Twodimensional Simulation of Gaseous Phenomena Using Vortex Particles. In Proceedings of the 6th Eurographics Workshop on Computer Animation and Simulation, pages 315. Springer-Verlag, 1995. [9] M. Griebel, T. Dornseifer, and T. Neunhoeffer. Numerical Simulation in Fluid Dynamics: A Practical Introduction. SIAM, Philadelphia, 1998. [10] W. Hackbusch. Multi-grid Methods and Applications. Springer Verlag, Berlin, 1985. [11] F. H. Harlow and J. E. Welch. Numerical Calculation of Time-Dependent Viscous Incompressible Flow of Fluid with Free Surface. The Physics of Fluids, 8:21822189, December 1965.

(a)

(b)

(c)

(d)

(e)

(b) (f) (g)

Figure 4: Snapshots from our interactive uid solver.

Vous aimerez peut-être aussi