Top Banner
On the simulation of fluids for computer graphics Ives Jos´ e de Albuquerque Macˆ edo J´ unior Advisor: Luiz Carlos Pacheco Rodrigues Velho Co-Advisor: Paulo Cezar Pinto Carvalho Rio de Janeiro November 2007
113

On the simulation of fluids for computer graphics - IMPA

Apr 23, 2023

Download

Documents

Khang Minh
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: On the simulation of fluids for computer graphics - IMPA

On the simulation of fluids

for computer graphics

Ives Jose de Albuquerque Macedo Junior

Advisor: Luiz Carlos Pacheco Rodrigues Velho

Co-Advisor: Paulo Cezar Pinto Carvalho

Rio de JaneiroNovember 2007

Page 2: On the simulation of fluids for computer graphics - IMPA

ii

Page 3: On the simulation of fluids for computer graphics - IMPA

Aos meus pais e as minhas irmas.

Page 4: On the simulation of fluids for computer graphics - IMPA

iv

Page 5: On the simulation of fluids for computer graphics - IMPA

“— Alo, cotovia!Aonde voaste,Por onde andaste,Que saudades me deixaste?

— Andei onde deu o vento.Onde foi meu pensamentoEm sıtios, que nunca viste,De um paıs que nao existe . . .Voltei, te trouxe a alegria.

— Muito contas, cotovia!E que outras terras distantesVisitaste? Dize ao triste.

— Lıbia ardente, Cıtia fria,Europa, Franca, Bahia . . .

— E esqueceste Pernambuco,Distraıda?

— Voei ao Recife, no CaisPousei na Rua da Aurora.

— Aurora da minha vidaQue os anos nao trazem mais!

— Os anos nao, nem os dias,Que isso cabe as cotovias.Meu bico e bem pequeninoPara o bem que e deste mundo:Se enche com uma gota de agua.Mas sei torcer o destino,Sei no espaco de um segundoLimpar o pesar mais fundo.Voei ao Recife, e dos longesDas distancias, aonde alcancaSo a asa da cotovia,— Do mais remoto e peremptoDos teus dias de criancaTe trouxe a extinta esperanca,Trouxe a perdida alegria.”

Cotovia, Manuel Bandeira

Page 6: On the simulation of fluids for computer graphics - IMPA

vi

Page 7: On the simulation of fluids for computer graphics - IMPA

Agradecimentos

Antes de tudo, gostaria de agradecer a meus pais por sempre se esforcarempara me oferecer uma boa educacao. Agradeco o apoio e o conforto que elese minhas irmas me deram ao longo de todos esses anos perto e longe de casa.

Agradeco a Sılvio Melo, grande amigo e orientador de graduacao, o qualme apresentou a Computacao Grafica e as belezas dessa disciplina. Sem seusensinamentos e sua confianca em mim, jamais chegaria ate aqui.

Sou muito grato a meu orientador Luiz Velho por me aguentar nessesanos de mestrado, confiar em mim e me guiar ate o desenvolvimento destetrabalho, o que lhe deve ter exigido bastante paciencia.

Aos professores Luiz Henrique de Figueiredo e Paulo Cezar Pinto Car-valho, agradeco pelas excelentes aulas e conversas acerca de varios temas.

Agradeco aos demais professores que tive aqui no IMPA: Alfredo Iusem,Benar Fux Svaiter, Vladas Sidoravicius, Mikhail Solodov, Andre Nachbin,Christian Schaerer e Thomas Lewiner, os quais me ensinaram, com a ex-celencia caracterıstica do IMPA, praticamente tudo o que sei de matematica.

Aos demais funcionarios do IMPA, agradeco o seu esforco e cuidados paramanter excelentes as condicoes de estudo e trabalho no instituto.

Gostaria de agradecer a todos os membros de minha famılia que me aco-lheram tao bem quando de minha chegada ao Rio de Janeiro, em particular,a minha tia Ivone.

Fico grato a todos aqueles com quem tive o enorme prazer de dividiruma moradia longe de casa: Vivi, Xanda, Ivana, Renato, Borje, Vitor, Pauloe Fernando. Foram muito felizes nossas noites de conversas e refeicoes emfamılia, mais recentemente, os almocos de Betinha.

Agradeco aos colegas e amigos do Visgraf pelo companheirismo, em par-ticular a Emilio, Dimas, Geisa, Cicconet, Hedlena, Margareth, Ana Regina,Anderson, Aldo, Giordano, Sergio “Meu Caro”, Evilson, Serginho, Otavio,Adriana, Ricardo, Dalia, Asla e Esdras “Meus Ovos”.

Page 8: On the simulation of fluids for computer graphics - IMPA

Jamais esquecerei dos demais amigos que fiz aqui no Rio (minha outra equerida famılia de longe de casa): Emilio, Cristina, Julio, Papito, Italo, Au-gusto, Daniel, Marcelo RH, Tertuliano, Guilherme, Marcelo Cicconet, Paty,Zanforlin, Laura, Braulia, Vanessa, Adriana, Geisa, Dimas, Clarisse. . . Ufa!Desisti de tentar enumera-los. . . Enfim, muito obrigado a todos os meusamigos por todo o seu carinho e amizade! Acharam que eu iria esquecer?!

Nao deixaria de lembrar dos amigos que ajudaram na revisao dessa dis-sertacao: Dimas, Emılio, Borje e Julio Daniel. Obrigado, companheiros!

Finalmente, devo expressar minha gratidao de maneira geral ao IMPA,pela excelencia de suas instalacoes e pessoas, e ao CNPq, por me concederduas bolsas de estudos (mestrado e, agora, doutorado).

P.S.: Sei que ainda tenho muito mais o que (e a quem) agradecer, mas,por favor, compreenda que ja ta na hora d’eu terminar essa bagaca. . .

viii

Page 9: On the simulation of fluids for computer graphics - IMPA

Resumo

A onipresenca e a complexidade dos fenomenos naturais sao responsaveistanto pela alta demanda de softwares capazes de simula-los quanto pelasdificuldades em projetar tais ferramentas. Na industria de efeitos especiais,existe uma necessidade de retratar fenomenos decorrentes da interacao en-tre elementos da natureza. Entretanto, os requisitos impostos por domıniosde aplicacao como esse diferem daqueles oriundos dos cenarios classicos daengenharia, aplicacao tradicional da Dinamica dos Fluidos Computacional.

O aumento tanto no poder computacional quanto na disponibilidade dememoria vem possibilitando a simulacao de varios fenomenos naturais emhardware de baixo-custo, quando a plausibilidade visual desses fenomenos esuficiente. Esses desenvolvimentos, e a demanda por animacoes “realısticas”tanto para filmes quanto para jogos de computador, tem encorajado a comu-nidade de computacao grafica a trabalhar no projeto de novas tecnicas paraa simulacao de fenomenos fısicos especializadas nesses domınios de aplicacao.

Por essas razoes, a literatura sobre simulacao de fluidos, ja bastante ex-tensa devido a suas importantes aplicacoes nas engenharias, tem crescidorapidamente por causa da atencao recente da comunidade de computacaografica. Esse cenario tem nos motivado a estudar os fundamentos da sim-ulacao de fluidos, ainda com vistas a sua utilizacao em animacao por com-putador. Com o proposito de reportar nossos estudos, esta dissertacao temdois objetivos principais: aprender tanto os fundamentos teoricos da dinamicados fluidos quanto os principais metodos para simular escoamentos de fluidos;e auxiliar outros estudantes, agrupando os principais conceitos envolvidos naanimacao de fluidos num texto introdutorio, junto a referencias relevantespara topicos especıficos e tendencias da pesquisa em computacao grafica.

Palavras-chave: dinamica dos fluidos, animacao por computador, fenomenosnaturais, equacoes de Euler, equacoes de Navier-Stokes, Fluidos Estaveis, SPH

Page 10: On the simulation of fluids for computer graphics - IMPA

x

Page 11: On the simulation of fluids for computer graphics - IMPA

Abstract

The ubiquity and complexity of natural phenomena are responsible both forthe high demand of software capable to simulate them and for the difficultiesin designing such tools. In the special effects industry, there is a need ofdepicting phenomena arising from the interactions among the elements ofnature. However, the requirements imposed by this application domain differfrom those in the classical engineering settings with which ComputationalFluid Dynamics is traditionally concerned.

The increase in computing power and memory availability has made itpossible to simulate many natural phenomena in commodity hardware, whenthe visual plausibility of computed motions is enough. These developmentsand the demand for “realistic” animations, both for films and games, haveencouraged the graphics community to work on the design of specializedmethods and techniques to simulate physical phenomena for these applica-tions.

For these reasons, the literature on fluid simulation, already very large dueto its important applications in engineering, has been growing fast because ofthe recent attention from the computer graphics community. This scenariohas motivated us to study the fundamentals of fluid simulation, still withcomputer graphics applications in mind. With the purpose of reporting ourstudies, the goals of this thesis are twofold: to learn both the theoreticalfundamentals of fluid dynamics and the main methods for the computersimulation of fluid flows; and to help other students, by grouping the mainconcepts involved in simulating fluids for animation in an introductory textalong with relevant references to specific topics and current research trends.

Keywords: fluid dynamics, computer animation, Euler’s equations, naturalphenomena, Navier-Stokes’ equations, Stable Fluids, SPH

Page 12: On the simulation of fluids for computer graphics - IMPA

xii

Page 13: On the simulation of fluids for computer graphics - IMPA

Contents

1 Introduction 11.1 Motivation and Goals . . . . . . . . . . . . . . . . . . . . . . . 11.2 Plausibility versus Accuracy . . . . . . . . . . . . . . . . . . . 21.3 Overview of the Thesis . . . . . . . . . . . . . . . . . . . . . . 3

2 Commented Bibliography 52.1 Mathematics and Physics of Fluids . . . . . . . . . . . . . . . 62.2 Computational Fluid Dynamics . . . . . . . . . . . . . . . . . 72.3 Fluid Simulation in Computer Graphics . . . . . . . . . . . . . 92.4 Comments and Further Reading . . . . . . . . . . . . . . . . . 11

3 The Equations of Motion 133.1 Basic Principles and Assumptions . . . . . . . . . . . . . . . . 143.2 Lagrangian and Eulerian Descriptions . . . . . . . . . . . . . . 163.3 Conservation of Mass and Incompressibility . . . . . . . . . . 213.4 Balance of Momentum . . . . . . . . . . . . . . . . . . . . . . 243.5 Ideal Fluids and Euler’s Equations . . . . . . . . . . . . . . . 263.6 Newtonian Viscous Fluids and the Navier-Stokes Equations . . 273.7 Pressure and Incompressibility . . . . . . . . . . . . . . . . . . 303.8 Rotation and Vorticity . . . . . . . . . . . . . . . . . . . . . . 323.9 Comments and Further Reading . . . . . . . . . . . . . . . . . 37

4 Numerical Simulation of Fluids for Animation 394.1 Stable Fluids . . . . . . . . . . . . . . . . . . . . . . . . . . . 40

4.1.1 Flow regime and governing equations . . . . . . . . . . 404.1.2 Field representation and spatial discretization . . . . . 404.1.3 Operator splitting/fractional-stepping . . . . . . . . . . 424.1.4 Semi-Lagrangian advection . . . . . . . . . . . . . . . . 44

xiii

Page 14: On the simulation of fluids for computer graphics - IMPA

4.1.5 Explicit forcing and vorticity confinement . . . . . . . 454.1.6 Implicit diffusion . . . . . . . . . . . . . . . . . . . . . 454.1.7 Pressure projection . . . . . . . . . . . . . . . . . . . . 464.1.8 Experiments . . . . . . . . . . . . . . . . . . . . . . . . 48

4.2 Smoothed Particle Hydrodynamics . . . . . . . . . . . . . . . 534.2.1 Flow regime and governing equations . . . . . . . . . . 534.2.2 Field representation and fluid discretization . . . . . . 544.2.3 The discretized governing equations . . . . . . . . . . . 584.2.4 Experiments . . . . . . . . . . . . . . . . . . . . . . . . 61

4.3 Comments and Further Reading . . . . . . . . . . . . . . . . . 63

5 Final Remarks 65

A A Simple Stable Fluids Solver 67

B A Simple Smoothed Particle Hydrodynamics Solver 75

xiv

Page 15: On the simulation of fluids for computer graphics - IMPA

List of Figures

4.1 A simple flow example . . . . . . . . . . . . . . . . . . . . . . 504.2 A more complex example . . . . . . . . . . . . . . . . . . . . . 514.3 Generation of vorticity in Navier-Stokes’ flows . . . . . . . . . 524.4 Animating a breaking dam . . . . . . . . . . . . . . . . . . . . 62

xv

Page 16: On the simulation of fluids for computer graphics - IMPA

xvi

Page 17: On the simulation of fluids for computer graphics - IMPA

Chapter 1

Introduction

“As Aladdin rubbed the lamp to try to get a better look, the lampsprang magically to life! It was all Aladdin could do to hold onto thebucking lamp as it spewed colored smoke and magic sparkles! Like avolcano erupting, the lamp launched a long, blue stream upward. Theblue smoke twisted and expanded as it rose toward the ceiling. Finally,it became an enormous, blue genie!”, Disney’s Aladdin1

1.1 Motivation and Goals

The ubiquity and complexity of natural phenomena are responsible both forthe high demand of tools capable of simulating them and for the difficultiesin designing such tools. In the special effects industry, there is a need to de-pict phenomena arising from the interactions among elements of nature (e.g.clouds, mountains, rivers, trees). Frequently, those interactions either cannotjust be captured by real cameras (e.g., explosions of space stations) or theyare too expensive, even dangerous, to shoot in location (e.g., the inundationof a populated city, or fire spreading through a forest). Many other applica-tions demand visually plausible computer simulations of natural phenomena,including computer games and flight simulators.

The increase in computing power and memory availability has made itpossible to simulate many natural phenomena in commodity hardware, whenthe visual plausibility of computed motions is enough. These developments

1 Story Plot as reported in the Animated Storybook at Disney.com,c.f. http://www.geocities.com/aladdin it/Aladdin eindex.html

1

Page 18: On the simulation of fluids for computer graphics - IMPA

and the demand for “realistic” animations have encouraged the computergraphics community to work on the design of methods and techniques tosimulate physical phenomena. For these reasons, the computer animationliterature on simulation of the elements of nature has grown significantly inthe past decade. Many of those works deal with the animation of fluidflows, phenomena omnipresent in our everyday life and complex per se.In fact, when asked which is the single hardest shot they did in “Shrek”,the DreamWorks SKG principal and producer of “Shrek”, Jeffrey Katzen-berg, answered: “It’s the pouring of milk into a glass.”

As such, the literature on fluid simulation, already very large due to itsimportant applications in engineering, has been growing fast because of therecent attention from the computer graphics community. This has motivatedus to study more about the simulation of fluids, with computer graphicsapplications in mind. For these reasons, the goals of this thesis are twofold:

• to learn both the theoretical fundamentals of fluid dynamics and themain methods for the computer simulation of fluid flows;

• to help other students by grouping the main concepts involved in thesimulation of fluids for computer graphics in an introductory text alongwith relevant references to specific topics and current research trends.

Since most of the literature on the foundations of Computational FluidDynamics (CFD) was written either with theoretical or engineering purposes,where the needs are rather different from those of computer graphics, oneshould take care on how to employ the developments from CFD in anima-tion applications. We comment on these distinct viewpoints in the followingsection.

1.2 Plausibility versus Accuracy

With its roots in engineering disciplines, most works on the numerical simu-lation of fluid dynamics focus on the accuracy of computed flows. However,computer graphics applications demand different qualities in the methodsthey employ to simulate fluid motion: plausibility, efficiency and complexity.

Visual plausibility of the motion is paramount in applications desiring toimmerse a person in some virtual environment (e.g., flight simulators, com-puter games, theatrical films). This is the driving goal of techniques in com-puter graphics [BHW96], but, perhaps influenced by the classical literature

2

Page 19: On the simulation of fluids for computer graphics - IMPA

on Computational Fluid Dynamics, it is not always exploited in publishedworks (which stay conservative, relying just on accurate methods).

Many works have benefited from exploiting this “relaxed” accuracy re-quirement in designing more efficient schemes to simulate natural phenom-ena. Even this efficiency need is somewhat different from that in engineering,where high-end computers and clusters are often available to perform days(sometimes weeks) of computations. Animators need a quick feedback froma simulation (often performed just on a “good” desktop), since many param-eters are tunned to achieve a desired motion effect. This way, the efficiencyrequirements in computer graphics applications are, in a sense, more strin-gent than in engineering. The systematic exploitation of visual perceptionand human attention in designing efficient methods for plausible animation ofphysical phenomena is a subject of active research [OD01, ODGK03, O’S05].

Another property that needs to be taken into account concerns the com-plexity of the method with respect to its implementation and its integrationwith other simulators designed for other physical phenomena. This is moreof a practical “requirement”, since a technique is rarely implemented if itis too hard to code, and the special effects industry is often interested inmotions resulting from complex interactions among rigid, deformable andfluid objects (“multiphysics” interactions). Complexity also plays a role inthe interface used for simulations, as the animators are not experts in fluiddynamics, there is a requirement that the methods should be easy to use(besides the discussed efficiency of feedback).

All those differences in requirements make it difficult to directly adoptstandard CFD techniques in computer graphics. Therefore, there is a need todevelop specialized algorithms and methods for special effects, what has beenaccomplished by both adapting existing techniques from CFD and developingnovel ones to meet the graphics’ requirements.

As this is an introductory text, we will not pursue further issues regardingthese requirements, they are overcome by employing well adopted techniquesto simulate fluid motion for computer graphics applications.

1.3 Overview of the Thesis

This thesis is organized to provide the reader a gradual introduction to thesimulation of fluids for computer graphics applications. In Chapter 2 wecomment on part of the available literature concerned with the main topics

3

Page 20: On the simulation of fluids for computer graphics - IMPA

treated on this text: mathematics and physics of fluids, numerical analy-sis and computational fluid dynamics and computer animation of fluid flows.In Chapter 3, the governing equations that model the motion of fluids are de-rived directly from basic physical and mathematical assumptions. That chap-ter provides the fundamentals of mathematical fluid dynamics needed tounderstand most of the computer graphics literature on fluid animation.In Chapter 4, we describe two of the most influent methods for fluid anima-tion introduced to computer graphics: Stable Fluids and Smoothed ParticleHydrodynamics. In Chapter 5, a discussion of some efforts which have been(and are intended to be) made concludes the main text. For completeness,appendices A and B contain the C code of our basic implementations of StableFluids and SPH.

4

Page 21: On the simulation of fluids for computer graphics - IMPA

Chapter 2

Commented Bibliography

This chapter is intended to provide the reader with an overview (somewhatbiased) to available literature both on the prerequisites and fundamentalsof mathematical and computational fluid dynamics and on works developedin the computer graphics community to simulate the natural phenomena offluid flows with animation and depiction purposes.

Both theoretical and numerical fluid dynamics communities are very pro-lific. For this reason, we have neither the intention to provide a compre-hensive list of published works nor the ambition to give a complete pictureof this vast discipline. Even the restriction to those efforts in the computergraphics literature would be a superb task to anyone pursuing such a goal.That is why, in the present chapter, we hope to provide more something likea “student report”: a guide for those interested in studying fluid mechanicswith animation ambitions. The discussion is restricted to materials relevantto the simulation of fluids and doesn’t even touch on efforts on the visual-ization of simulated flows. The goal of providing a guide for students andresearchers starting in this field motivated us to employ a different writtingstyle for this chapter, almost informal compared to the following chapters.

We first provide references on the mathematical modeling of the physicsof fluids and comment on the disciplines required to be able to follow thosereferences. The discussion following that concerns the literature dealing withthe discretization of the governing equations and differential equations ingeneral, as well as the basics of numerical analysis and linear algebra onwhich the “computational theory” relies. After that, we overview publishedworks of the computer graphics community regarding the animation of fluidflows. This chapter ends with comments and some tips for further studies.

5

Page 22: On the simulation of fluids for computer graphics - IMPA

2.1 Mathematics and Physics of Fluids

As would be expected, a good understading of the foundations of mathemati-cal and computational fluid dynamics requires knowledge of basic graduatemathematics. To be able to follow the references we cite here, the readershould feel comfortable with real analysis of several variables, linear algebra(both theoretical and computational) and some elements from the theory(and practice) of ordinary and partial differential equations (and, sometimes,results regarding functions of one complex variable). References for thesesubjects can be provided by people in the math department nearest to you.

Assuming those subjects are familiar to the reader, we provide the refer-ences which helped us in preparing this text. The literature on mathematicalmodeling of the physics of fluids is rather broad, the available textbooks focuson varied audiences (e.g. mechanical engineers, physicists and applied math-ematicians) and topics (e.g. aero, hydro and fire dynamics). Our choicesrely on the bibliography adopted in an introductory graduate course on fluiddynamics, directed to applied mathematics students, and some references wefound (and enjoyed) on our way through.1

The classical book by Batchelor [Bat99] provides a broad (and verbal)treatment of the physics and mathematical modeling of fluid dynamics; itis a very nice reference for those interested (and somewhat mathematicallybiased) in the subtleties of modeling the physics of fluids. Those who pre-fer a more formal (but intended to be introductory) view of fluid mechanicswill appreciate the succinct approach adopted in [CM93]. We recommend[Mey82] as a good balance on the presentation of the physics and the mathe-matical aspects of fluid dynamics (not to mention the book was written in aconcise and clear language directed to students of applied mathematics andphysics).

For those who can read Portuguese, the books [Nac01, MN91] provideboth an introduction to mathematical fluid dynamics. Nachbin’s text is moreaccessible to beginners who are familiar with elements of complex analysisof one variable, while Melo and Moura Neto’s is intended for those comfort-able with the language of differential equations (although the first chaptersprovide a nice structure for deriving the governing equations of fluid motionand influenced our developments in the next chapter).

1 The mentioned course was lectured by Professor Andre Nachbin on the March–Junesemester of 2007 here at IMPA.

6

Page 23: On the simulation of fluids for computer graphics - IMPA

We also found useful the course notes [Nac07, Mei07]. The first is onlyavailable at IMPA’s copy room, the notes of Professor Chiang Mei can befound on the internet (by October 2007) as part of a “school-wide modu-lar program for Fluid Mechanics” hosted at the Massachusetts Institute ofTechnology, http://web.mit.edu/fluids-modules/www/.

2.2 Computational Fluid Dynamics

Since the available references for CFD is even larger than those dedicated tomathematical fluid dynamics and the methods most commonly used in com-puter graphics for the simulation of fluid flows are rather classical, we chose tostudy these specific methods rather than attempt to cover this overwhelmingliterature. We pursued standard textbooks on computational linear algebraand the numerical analysis of differential equations as well as some of theclassical papers most frequently cited by the computer graphics community.

On the subject of numerical linear algebra, we adopted the textbooks[TB97, Dem97]. The first of these introduce both basic and advanced meth-ods in a very modular way, suitable both for teaching this subject as well asfor individual study. Demmel’s book complements that text providing a nicecovering of state-of-the-art techniques and issues related to their computerimplementation. For those who aren’t still comfortable with the theory oflinear algebra, but are interested in studying it with applied endeavours, werecommend [Str80] as a very didatic reference with plenty of examples.

With respect to classical numerical analysis, the book [SB02] providesa rather complete covering of the basic problems and solutions. For imple-mentation of the methods by means of computer programs, the NumericalRecipes series [PTVF92] are the classic reference, providing lots of commentsand source code (available in FORTRAN, C and C++).

The reason for providing all those references on numerical linear algebraand analysis is to build the foundations on which the numerical analysisof differential equations is supported. A good introduction to this topicis [Ise96], it contains a study of discretizations of both ordinary and partialdifferential equations with simple examples without restricting the text to oneparticular method (e.g., finite differences schemes, finite elements methods).For a discussion on issues related to the discretization of ODE’s, the book[AP98] provides a thorough analysis of numerical schemes for both non-stiffand stiff equations. This is one reason for which concepts as consistency,

7

Page 24: On the simulation of fluids for computer graphics - IMPA

stability and convergence of time-stepping methods are introduced, what isdone in a manner similar to that applied on numerical methods for PDE’s.

As one of the most employed methods to discretize differential equations,finite difference schemes comprehend the most used methods in computergraphics to simulate the physics of fluids through their governing equations.The references we recommend to study FD methods are the textbooks byLeVeque and Strikwerda [LeV07, Str04] and an unfinished monograph byTrefethen [Tre96] (freely available on the internet by October 2007). LeV-eque’s book covers the numerical analysis of finite difference methods forboth ordinary and partial differential equations in a formal, but still very di-datic, way. Strikwerda’s text is a bit more dry and focuses on FD schemes forPDE’s, but is a classic reference and has a nice material on stability analysis.Trefethen’s unfinished book is a fine (low cost, but of good quality) referencefor some topics on finite differences methods, but sometimes the ausence ofinteresting stuff cited in the text is rather annoying. No free lunch. . .

Provided the fundamentals of the basic numerical methods for differentialequations and their analysis, we comment highly cited (in the computergraphics fluid simulation literature) papers on numerical analysis and CFD.

We believe the most cited CFD paper in the CG literature is [HW65], inthis work, Harlow and Welch introduced the marker and cell (MAC) methodto simulate the behaviour of non-steady viscous incompressible free-surfacefluid flows. That paper used a finite-difference scheme to discretize the in-compressible Navier-Stokes equations on a staggered grid and a set of markerparticles, advected by the computed flow, both to determine the computa-tional cells filled with fluid and to depict/visualize the free-surface flow.

Although the use of a staggered grid contributed to diminish effects ofnumerical dissipation, the direct discretization of the NSE by an explicitfinite difference scheme imposed to [HW65], as stability requirements (simi-lar to the CFL condition derived in [CFL67] to linear, constant coefficientsPDE’s), severe (to CG applications at least) restrictions on the step sizeused by the time-stepping method. Those restrictions encouraged the com-puter graphics community to look for computationally cheap strategies toovercome the CFL condition. The most applied of those strategies was in-troduced in CG by Jos Stam at SIGGRAPH in 1999 [Sta99], it employeda splitting method [MQ02, PTVF92] to decompose the Navier-Stokes equa-tions into a sequence of simpler subproblems to which specialized methodswere used. The most important of these methods tackled the convection andthe diffusion equations and the incompressibility condition with, respectively,

8

Page 25: On the simulation of fluids for computer graphics - IMPA

a semi-Lagrangian advection scheme [SC91], a standard (implicit) backwardEuler discretization scheme [Ise96] and Chorin’s projection method [Cho68].These improvements made possible to take arbitrarily large time steps inthe simulation, at the expense of some loss in accuracy (but still producingmotions plausible enough for animation purposes).

The relatively coarse grids used in animation applications, combined withother factors, contributed to cause much numerical diffusion in the flow sim-ulations, evidenced by loss of the swirling behaviour of rotating gases. Totackle this problem, Fedkiw et al. [FSJ01] employed a forcing term, the vor-ticity confinement force, in the Euler equations which induced an increase inthe vortical details in the flow. This was done based on the work of Steinhoffand Underhill [SU94] in the interaction of vortex rings arising in simulationsof air flows around helicopters’ rotor blades.

More recently, with the widespread use of smoothed particle hydrodynam-ics (SPH) methods in the computer graphics community, many articles havecited the seminal works of Lucy, Gingold and Monaghan [Luc77, GM77] onthe application of particle systems (also known as meshfree/meshless meth-ods) to simulate astronomical fluids and study the formation of stars.

2.3 Fluid Simulation in Computer Graphics

Physically-plausible animation of fluid motion is a long-standing goal in thecomputer graphics community. Many models to describe the complex phe-nomena arising in the interaction of fluids with the environment have beenproposed for computer depiction. In this chapter, we overview some classicaland some recent papers from the graphics literature which take an approachgrounded on the governing equations of fluid flows.

The work of Kass and Miller [KM90] was one of the first to solve PDE’sfor the computer animation of fluids. Their model departed from the shallow-water/long-wave equations to model the height-field (free-surface) of a tra-velling water wave with amplitude and depth small compared to its wave-length. After neglecting the non-linear term in these equations, they arrivedat the classical wave equation, a systematic derivation (from Boussinesq’s)of both shallow-water and wave equations can be found in [Nac07]. To nu-merically integrate the resulting PDE, Kass and Miller adopted an implicitfinite-differences scheme, based on the alternating-direction method whensimulating “3D” waves, to avoid the requirement of small time-steps.

9

Page 26: On the simulation of fluids for computer graphics - IMPA

Restricting to inviscid (non-viscous), irrotational and incompressible flows,[WH91] was able to animate (non-turbulent) aerodynamic transport with amodeling approach similar to that employed in the classical potential theoryof fluids [CM93]. In [SF93], Stam and Fiume depicted gaseous flows usingelements from the theory of turbulence and advection-diffusion equations.

Only in 1995, Chen and da Vitoria-Lobo [CdVL95] used a FD-discretizationof the full 2D Navier-Stokes equations to animate fluid flows. To “simulate”3D fluids, their work solved the 2D NSE and used a height-field, calculatedfrom the (scaled) pressure values, to depict a free-surface. In the same year,Stam and Fiume introduced in computer graphics the Smoothed Particle Hy-drodynamics method of [Luc77, GM77] to depict the motion of gases [SF95].

It seems that the first work to employ the 3D Navier-Stokes equations inthe animation of fluids was developed by Foster and Metaxas in 1996 [FM96a,FM96b]. Their work uses the MAC-scheme of Harlow and Welch [HW65] tosimulate viscous incompressible flows, and presented detailed descriptions ofhow to deal with various boundary conditions encountered in typical flowregimes. Since Foster and Metaxas were interested in providing tools forcomputer animation of fluids, their subsequent work dealed with control offluid flows [FM97a] and coarse-grid simulations of turbulent gases [FM97b].

Although Foster and Metaxas were able to animate full three-dimensionalflows, the adoption of the original MAC-scheme forced time-steps so smallthat the refinement process commonly employed in animation production wasrendered inviable. This problem inspired the work of Stam [Sta99], in whichthe Stable Fluids (SF) scheme was introduced. Employing a time splittingof the Navier-Stokes equations, Stable Fluids solves a sequence of “simple”PDE’s using classic unconditionally stable methods, allowing the simulationto take arbitrarily large time-steps without numerical blow-up.2

The original Stable Fluids method suffered from severe numerical diffu-sion and volume loss in its simulations, these problems were circumvented in[FSJ01, FF01], which introduced “vorticity confinement” forces to keep rota-tional detail in gaseous flows and the use of level-sets [OF03] to represent andadvect the fluid-air interface. These improvements made possible the simu-lation of gases and bulk water with high visual fidelity and details. Latter,[EMF02] coupled level-sets with particles and a simplified semi-Lagrangianadvection scheme which, coupled with the hierarchical representation of thecomputational domain presented in [LGF04], allowed an efficient simulation

2 In chapter 4, we provide a more detailed description of the Stable Fluids method.

10

Page 27: On the simulation of fluids for computer graphics - IMPA

of stunning details in water flows.Since Stam’s seminal work [Sta99], many authors have developed ex-

tensions to the basic Stable Fluids scheme [FSJ01, FF01, Sta01, NFJ02,CMIT02, FOA03, Sta03, RNGF03, GBO04, CMT04, SRF05] and alterna-tive approaches [FOK05, FOKG05, KFCO06, ETK+07, BBB07, CFL+07],although they adopted the general splitting structure of the orginal StableFluids method.

Other interesting researches concern meshfree (particle-based) methods.Even though introduced in computer graphics by [SF95] for gases and [DG96]for elastic solids, the SPH method only became popular after the work ofMuller et al. [MCG03], in which it was demonstrated that it could be usedto simulate 3D fluids at interactive rates. Althought it is one of the mostpopular methods, [MCG03] was not the first to use physically-based particlemethods to simulate the Navier-Stokes equations. In [GLG95], Gamito etal. presented a particle method based on the vorticity formulation of thegoverning equations to simulate gaseous flows. Also in 2003, Premoze etal. [PTB+03] employed the Moving Particle Semi-implicit (MPS) schemeto simulate water flows, but the use of MPS required a grid structure tosolve a Poisson equation, which did not free the simulation from using grids.Since then, many papers proposed extensions and other meshless schemes tosimulate fluid flows [MST+04, MSKG05, PK05, PPLT06, CACC06, BT07,APKG07].

The computer graphics literature on the simulation of fluid flows is largeand diverse. Many people are working to develop efficient methods to gen-erate visually realistic fluid imagery. Interesting research trends includeflow control for animation [FM97a, TMPS03, MTPS04, FL04, REN+04,SY05a, SY05b, TKPR06, KMT06], alternative methods [Thu07, BWHT07,WBOL07, GN07, SMML07] and implementations on graphics processing units(GPU’s) [Har04, SCC04, SCC05, CLT07].

More introductory references on the simulation of fluid flows (and relatedtopics) for computer graphics applications can be found in the course notes[BMF07, DEF+04, WB01] and in the overview papers [FM00, Sta00, Igl04].

2.4 Comments and Further Reading

We presented an overview of some available references on the theoretical andcomputational aspects of fluid dynamics and how they have been exploited

11

Page 28: On the simulation of fluids for computer graphics - IMPA

by the computer graphics community to simulate fluid motion for animation.In this chapter, we intended to provide the citations most recurrent in the

fluid animation literature. Our belief is that a more thorough understandingof the discipline of mathematical fluid dynamics can be acquired through thestudy of classic texts on the subject. Besides those cited, some of the classicsinclude [Lam93, CF76, HM76, Whi99]. Another work that seems to adoptan interesting viewpoint, and is somewhat different from the cited texts, isthe book [WG00] that models and simulates fluids by cellular automata, anapproach already brought to computer graphics and has generated ratherimpressive imagery [Thu07].

Other references which seem to be worthy, but we didn’t inspect yet, re-gard the generalized simplified marker and cell (GENSMAC) method [TM94,TFC+01] and its use in the simulation of 3D flows, both Newtonian andnon-Newtonian [TDM96, TGC+04]. This scheme is based on earlier workby Amsden and Harlow [AH70] which introduced the simplified marker andcell (SMAC) method and which has also been employed in the (real-time)animation of fluid flows by an implementation on GPU’s [SCC04, SCC05].

An interesting result from studying the mathematics of fluid dynamicsis that most of the modeling done for fluids is very similar to that em-ployed in mathematical elasticity. Hence, for those also interested in thephysically-based animation of elastic media, we recommend the textbooks[MH94, Lov44] as the analogous to those references cited in the first sec-tion of this chapter. We have also found a reference written in Portuguese[Pat87] which would provide an analogous for Nachbin’s text, but may be abit harder to find because it is out of print by now.

12

Page 29: On the simulation of fluids for computer graphics - IMPA

Chapter 3

The Equations of Motion

This chapter is devoted to presenting the basic concepts and results frommathematical fluid dynamics. The governing equations of fluid motion willbe derived from the fundamental conservation laws and assumptions of con-tinuum fluid mechanics. Our derivations will be kept general up till thepoint where the need to specialize our results to the most commonly sim-ulated flows in computer graphics is necessary (i.e., incompressible inviscidflows and incompressible Newtonian flows with uniform viscosity).

From this theoretical treatment, we hope to gain a solid understandingof the assumptions behind the equations of motion used in physically-basedfluid animation. We have chosen the concepts and results most recurrent inthe computer graphics literature and some we believe could be more exploitedin the development of animation techniques.

For reasons of space and time we have chosen to omit derivations andresults from some topics of continuum fluid mechanics also exploited by thecomputer graphics community (e.g., the shallow-water equations and non-newtonian fluids). However, at the end of this chapter, we provide somecomments about those topics and references for further reading.

Our developments result from studying (some topics from) five books[CM93, MN91, Nac01, Mey82, Bat99] and two sets of lecture notes fromcourses on “Fluid Dynamics” [Nac07, Mei07]. If a more in-depth treatmentof mathematical fluid dynamics is needed, the reader is strongly encouragedto pursue those references.

13

Page 30: On the simulation of fluids for computer graphics - IMPA

3.1 Basic Principles and Assumptions

To mathematically model the physical phenomenon of fluid motion, we needto make some basic assumptions about our objects of study. The theory ofcontinuum fluid mechanics is grounded on principles which every fluid flowis supposed to obey:

• the law of conservation of mass : also known as the Lomonosov–Lavoisierlaw, states that

“the mass of a closed system of substances will remain con-stant, regardless of the processes acting inside the system.”

In fact, this law is only approximately true. Since, according tospecial relativity, the relativistic/apparent mass (m) depends on one’sframe of reference. However, for low speeds (much lower than light’s),the variation in apparent mass is negligible to a high accuracy.

For our mathematical modeling of fluid dynamics, we assume that“mass is neither created nor destroyed.”

(dmdt

= 0)

• Newton’s laws of motion: the three physical laws which provide rela-tionships between the forces acting on a body and the motion of thebody. They form the basis for classical mechanics, from which contin-uum fluid mechanics is a subdiscipline. The modern understanding ofNewton’s three laws of motion is1:

First Law “if no external force acts on a particle, then it is possible to selecta set of reference frames, called inertial reference frames, observedfrom which the particle moves without any change in velocity.”

Second Law “observed from an inertial reference frame, the net force (~F ) ona particle equals the time rate of change of its linear momentum(~p = m~v). This law can also be stated as ~F = d~p

dt= m~a.”

Third Law “whenever A exerts a force on B, B simultaneously exerts a forceon A with the same magnitude in the opposite direction.”

1 http://en.wikipedia.org/wiki/Newton%27s laws of motion

14

Page 31: On the simulation of fluids for computer graphics - IMPA

The second law defines the net force on a body in terms of its linearmomentum. This principle is called the law of balance of momentumand is recurrent in our derivations.2

• the first law of thermodynamics : which states that

“The increase in the internal energy (U) of a thermodynamicsystem is equal to the amount of energy added to the systemas the result of heating (Q) minus the amount of energy lostas the result of work done by the system on the surroundings(W ).”3

in equations this means dU = δQ− δW .4 In simple words, it accountsfor the assumption that “energy is neither created nor destroyed.”

• continuum hypotesis : although fluids are composed of molecules thatcollide with one another and solid objects, at a large scale, they may beconsidered as a continuum, i.e. their properties can be assumed con-tinuous functions defined on subsets of Rn.5 This assumption is calledthe continuum hypotesis and provides us a very good approximationfor the macroscopic phenomena we are interested in.

Besides those general principles of continuum fluid mechanics, for easy ofpresentation, we assume a standard smoothness convention [Mey82, CM93]:“the fluid properties (e.g. velocity, density and stress tensor to be introducedlater) are smooth enough, with respect to position and time on the closureof the fluid domain (to be mathematically defined lated), in such a way thatthe standard operations of calculus may be performed on them.”

Having set our fundamental assumptions and basic conservation laws, weare able to begin our mathematical modeling of fluid dynamics.

2 “Notice that the surface of the Earth does not define an inertial frame of referencebecause it is rotating and orbiting and because of Earth’s gravity. However, since the speedof rotation and revolution change relatively slowly, the inertial force is tiny. Therefore,Newton’s laws of motion remain a good approximation on earth. In a non-inertial frameof reference, inertial forces must be considered for Newton’s laws to remain valid.”

3 http://en.wikipedia.org/wiki/First law of thermodynamics4 As our derivations assume that no amount of heat energy is exchanged in the system

(i.e. δQ = 0), for our purposes, this law reads dU = −δW ⇐⇒ δW = −dU .5 For our considerations, we always have n ∈ 2, 3.

15

Page 32: On the simulation of fluids for computer graphics - IMPA

3.2 Lagrangian and Eulerian Descriptions

Our object is to mathematically describe the motion of a fluid region duringa given time interval. Such a description can be based on the idea of studyingthe trajectory taken by each one of the “infinitesimal fluid particles” thatcompose the fluid. This idea leads us to associating fluid motion with ageometrical transformation from the configuration this fluid domain presentsat a reference time instant into the configuration it presents at another time.

To mathematically model “fluid motion”, we first need to formalize theconcepts discussed and our intuitions through mathematical definitions.

Definition 1 (fluid region). Let D ⊆ Rn be an open and bounded set suchthat ∂D is smooth.6 If D is supposed to be “filled with a fluid”, we call D afluid region.

Definition 2 (reference configuration and time instant). The reference con-figuration is a fluid region Ω0 fixed at the reference time instant t0 ∈ I ⊆ R,where I is the open time interval during which we are interested in studyingthe fluid dynamics.

Definition 3 (fluid motion and flow map). The fluid motion is the familyϕtt∈I of continuous maps ϕt : Ω0 → Rn whose ϕt, for each t ∈ I, mapsthe position x0 ∈ Ω0 of a fluid particle in the reference configuration to thisparticle’s position at time t. With this, we can define the fluid flow map asthe function ϕ : Ω0 × I → Rn such that ϕ (x0, t) = ϕt (x0).

7

After mathematically modeling the notion of “fluid motion” as a familyof maps, we need to study the properties these maps are supposed to pos-sess (besides continuity). The intuitive idea that two different bodies cannotsimultaneously occupy the same portion of space can be expressed as a prop-erty for our definition of fluid motion: “for each t ∈ I, ϕt

∣∣Ω0

is smooth and

has a smooth inverse on Ωt := ϕt (Ω0)”. Another intuitive property ensuresthe continuity of ϕ (x0, ·) : I → Rn, for each x0 ∈ Ω0.

8 Intuitively, this means

6 Notice the use of our smoothness convention. In this case, the convention was usedto avoid the technical requirements that allow us to invoke the Divergence Theorem insubsequent calculations.

7 Don’t confuse the subscript t with a time derivative!And notice that ϕt0 (x0) = ϕ (x0, t0) = x0.

8 In fact, we assume ϕ is smooth on Ω0 × I and its time derivatives (at least the firsttwo of them) are continuous on Ω0 × I.

16

Page 33: On the simulation of fluids for computer graphics - IMPA

that “no particle can suddenly disappear and reappear at another position”,i.e., the trajectory of a fluid particle is (at least) continuous.

Definition 4 (trajectory). From the definition and properties of ϕ, we cannotice that the trajectory x : I → Rn of a fluid particle initially located at apoint x0 ∈ Ω0 can be defined by x (t) = ϕ (x0, t), and, from our smoothnessconvention, x describes a smooth curve in Rn.

This description of fluid motion through the fluid flow map and the fluidparticles’ trajectories with respect to the reference configuration is the socalled Lagrangian description and the points in Ω0 are known as materialcoordinates.

Another approach to describe the particles’ motion is through the defini-tion of a smooth vector field u : D × I → Rn defined in a fixed fluid region D.We define u (x, t) as the velocity of the fluid particle which passes throughx ∈ D at time t ∈ I:

u (ϕ (x0, t) , t) =∂ ϕ

∂t(x0, t) , x0 := ϕ−1

t (x)

From this definition of the velocity field u, we are able to provide anequivalent definition to a particle’s trajectory x as the (unique) solution of theordinary differential equation (sometimes known as the trajectory equation):

dx

dt= u (x, t) , x (t0) = x0

This is the so called Eulerian description and the points in D are knownas spatial coordinates.

Defined the trajectory of a fluid’s particle, we would like to measure therates in which quantities change along a particle’s trajectory, i.e., we wantto be able to take time derivatives along trajectories. With this goal, letf : D × I → R be a smooth function and x : I → Rn be a trajectory. Thetime derivative of f along the trajectory x at a time instant t is calculated(using the chain rule) as:

fx (t) := f (x (t) , t)

f ′x (t) = ∇f (x (t) , t) · dxdt

(t) +∂f

∂t(x (t) , t)

=

(∂f

∂t+ u · ∇f

)(x (t) , t)

17

Page 34: On the simulation of fluids for computer graphics - IMPA

From these observations, we can define a time differentiation operatorwhich acts along particles’ trajectories.

Definition 5 (material derivative and derivation along trajectories). Defin-ing the material derivative operator9 as D

Dt:= ∂

∂t+ (u · ∇), the derivative of

f along the trajectory passing through point x at time t is given by DfDt

(x, t).

With the material derivative, we are able to calculate time derivativesof functions along material curves (trajectories). As an example, from thevelocity vector field u (x, t), we can compute the fluid acceleration (vector)field a (x, t) as simply as:10

a (x, t) =Du

Dt(x, t) =

(∂u

∂t+ (u · ∇)u

)(x, t)

where the material derivative is applied componentwise (which also allowsus to apply it on tensor fields). Note the connection between Lagrangianand Eulerian descriptions of the acceleration field made possible throughthe material derivative, such a connection is recurrent both in theory andalgorithm development.

By now, we are able to demonstrate one of our most useful results.

Theorem 1 (Reynolds’ Transport Theorem).Let f : D × I → R as in the smoothness convention and Ωt := ϕ (Ω0, t) ⊆ D,for each t ∈ I and Ω0 ⊆ D the (arbitrary) reference fluid region, then

d

dt

∫Ωt

f dV =

∫Ωt

(Df

Dt+ f div u

)dV

where dV denotes the volume element.

Before providing a proof for this result, we demonstrate the followinglemma concerning the time derivative of J (x0, t) := det (∇ϕ (x0, t)) (wherethe Jacobian of ϕ is taken with respect to spatial coordinates).

9 Also known as transport derivative, substantial derivative, convective derivate. . .10 From this, we see that, given the velocity field u, the acceleration field a is not given

by ∂u∂t (a very common mistake).

18

Page 35: On the simulation of fluids for computer graphics - IMPA

Lemma 1. ∂∂t

J (x0, t) = J (x0, t) [div u (ϕ (x0, t) , t)]

Proof of Lemma 1. First of all, notice that

∂t∇ϕi (x0, t) = ∇∂ ϕi

∂t(x0, t)

= ∇ [ui (ϕ (x0, t) , t)]

= ∇ui (ϕ (x0, t) , t) · ∇ϕ (x0, t)

=n∑

j=1

∂ui

∂xj

(ϕ (x0, t) , t)∇ϕj (x0, t)

From this equality, the n-linearity and the antisymmetry of det (·), we have

∂tJ (x0, t) =

∂tdet (∇ϕ (x0, t))

=∂

∂tdet (∇ϕ1 (x0, t) , . . . ,∇ϕn (x0, t))

=n∑

i=1

det

(∇ϕ1 (x0, t) , . . . ,

∂t∇ϕi (x0, t) , . . . ,∇ϕn (x0, t)

)

=n∑

i=1

det

(. . . ,

n∑j=1

∂ui

∂xj

(ϕ (x0, t) , t)∇ϕj (x0, t), . . .

)

=n∑

i=1

n∑j=1

∂ui

∂xj

(ϕ (x0, t) , t) det(. . . ,∇ϕj (x0, t) , . . .

)=

n∑i=1

∂ui

∂xi

(ϕ (x0, t) , t) det (∇ϕ1 (x0, t) , . . . ,∇ϕn (x0, t))

= det (∇ϕ (x0, t))n∑

i=1

∂ui

∂xi

(ϕ (x0, t) , t)

= J (x0, t) [div u (ϕ (x0, t) , t)]

19

Page 36: On the simulation of fluids for computer graphics - IMPA

Proof of Reynolds’ Transport Theorem. From the smoothness of ϕt

∣∣Ω0

(and

its inverse’s), the continuity of ϕ (x0, ·) and that ϕ (·, t0) ≡ id (·), we havethe positivity of J (x0, t) for each x0 ∈ Ω0 and each t ∈ I. From this, thepreceding lemma and the Change of Variables Theorem:

d

dt

∫Ωt

f (x, t) dV =d

dt

∫ϕ(Ω0,t)

f (x, t) dV

=d

dt

∫Ω0

f (ϕ (x0, t) , t) J (x0, t) dV

=

∫Ω0

(∂f

∂t+∇f · ∂ ϕ

∂t

)(ϕ (x0, t) , t) J (x0, t) dV

+

∫Ω0

f (ϕ (x0, t) , t)∂

∂tJ (x0, t) dV

=

∫Ω0

(∂f

∂t+∇f · u

)(ϕ (x0, t) , t) J (x0, t) dV

+

∫Ω0

f (ϕ (x0, t) , t) J (x0, t) [div u (ϕ (x0, t) , t)] dV

=

∫Ω0

Df

Dt(ϕ (x0, t) , t) J (x0, t) dV

+

∫Ω0

(f div u) (ϕ (x0, t) , t) J (x0, t) dV

=

∫Ω0

(Df

Dt+ f div u

)(ϕ (x0, t) , t) J (x0, t) dV

=

∫ϕ(Ω0,t)

(Df

Dt+ f div u

)(x, t) dV

=

∫Ωt

(Df

Dt+ f div u

)(x, t) dV

20

Page 37: On the simulation of fluids for computer graphics - IMPA

The following corollary of the transport theorem establishes a connectionbetween the Lagrangian and the Eulerian viewpoints (in an integral form).

Corollary 1. With Ωt and f as in the transport theorem, let Ω1 be the fixedset in Rn which coincides with Ωt at t = t1. Then at the (arbitrary) time t1,

d

dt

∫Ωt

f dV =∂

∂t

∫Ω1

f dV +

∫∂Ω1

fu · n dA

where n is the unit outward normal, and dA the surface element, on ∂Ω1.

Proof. From the identity div(fu) = ∇f · u + f div u, it suffices to note thatDfDt

+ f div u = ∂f∂t

+ div(fu). From the transport and divergence theorems,

d

dt

∫Ωt

f dV =

∫Ω1

(Df

Dt+ f div u

)dV =

∫Ω1

(∂f

∂t+ div(fu)

)dV

=

∫Ω1

∂f

∂tdV +

∫Ω1

div(fu) dV =∂

∂t

∫Ω1

f dV +

∫∂Ω1

fu · n dA

The left-hand side of this expression denotes the rate of change of the “f -content” of the fixed body of fluid occupying the region Ω1 ⊆ D at time t1.The first term on the right-hand side is the rate of change of the f -contentof this fixed spatial domain. And the last term is the rate of outflow of fthrough the fixed boundary of Ω1 (“flux of f through ∂Ω1”) [Mey82].

3.3 Conservation of Mass and Incompressibil-

ity

In the previous section, we deduced some preliminary results based on our(still too abstract) mathematical model of fluid motion. From now on, webegin to describe our physical assumptions and conservation laws from sec-tion 3.1 in terms of mathematical properties of our model.

This section deals with the first of our basic principles, the law of con-servation of mass, and its relationship with incompressibility in fluids. Theassumption which ensures the conservation of mass of a fluid region in motioncan be mathematically stated as:

21

Page 38: On the simulation of fluids for computer graphics - IMPA

Definition 6 (mass and density). There exists a function ρ (x, t) such that,for any fluid region W ⊆ Ω0 and every t ∈ I

0 < m (W , t) =

∫ϕ(W,t)

ρ (x, t) dV andd

dtm (W , t) = 0

where m (W , t) is the mass of the fluid in ϕ (W , t) and the function ρ (x, t)defined this way is called mass density. 11

From this definition, the conservation of mass can be stated in terms ofρ and u as an application of the Reynolds’ Transport Theorem:

0 =d

dtm (W , t) =

d

dt

∫ϕ(W,t)

ρ (x, t) dV =

∫ϕ(W,t)

(Dρ

Dt+ ρ div u

)(x, t) dV

This way, from the smoothness properties of ρ, we have the equivalence∫ϕ(W,t)

(Dρ

Dt+ ρ div u

)dV = 0⇐⇒ Dρ

Dt+ ρ div u = 0 (3.1)

in which the left-hand side is called the integral form of the law of conser-vation of mass, while the right-hand side is the so called differential form ofthe law of conservation of mass (or the continuity equation).

From these forms of mass conservation, and applying once more the trans-port theorem, we can prove the following result.

Corollary 2. With Ωt and f as in the Reynolds’ Transport Theorem,

d

dt

∫Ωt

ρf dV =

∫Ωt

ρDf

DtdV

Proof.

d

dt

∫Ωt

ρf dV =

∫Ωt

(D

Dt(ρf) + (ρf) div u

)dV

=

∫Ωt

(ρDf

Dt+ f

(Dρ

Dt+ ρ div u

))dV =

∫Ωt

ρDf

DtdV

11 Sometimes we may refer to ρ as density or specific mass. As pointed in section 3.1,we adopt the smoothness convention for ρ, this way ρ > 0 almost everywhere.

22

Page 39: On the simulation of fluids for computer graphics - IMPA

Although real fluids change volume, most fluid flows of “interest” can beapproximated, to a high degree of accuracy, by incompressible flows. Thismeans that, for many practical applications (e.g. the simulation of “every-day” fluids for computer animation), we can assume the incompressibility ofour fluid flows.12

Definition 7 (incompressible flow). We say that ϕ denotes an incompres-sible flow when, for any fluid region W ⊆ Ω0 and every t ∈ I

volume (W) = volume (ϕ (W , t))⇔∫W

dV =

∫ϕ(W,t)

dV ⇔ d

dt

∫ϕ(W,t)

dV = 0

From this definition and the transport theorem, for incompressible flows,

0 =d

dt

∫ϕ(W,t)

dV =

∫ϕ(W,t)

div u dV ⇐⇒ div u = 0

where the right-hand side is often known as the incompressibility condition.13

The incompressibility condition and lemma 1 also result that a flow isincompressible if and only if J ≡ 1, since J (·, t0) = 1.

From the equation of continuity 3.1, and the fact that ρ > 0, a fluid isincompressible if and only if Dρ

Dt= 0, that is, the mass density is constant

following the fluid. If the fluid is homogeneous (i.e. ρ = constant in space),it also follows that the flow is incompressible if and only if ρ is constant intime. So, for a homogeneous incompressible fluid, ρ (x, t) = ρ0 > 0.14

12 Notice this doesn’t hold for simulations involving high-speed flows like sonic boomsand blast waves. The study of how fluids behave in these situations is generally called“compressible flow”. It’s usually so much more complicated and expensive to simulatethese high-speed flows that, even if we have sonic booms and blast waves, they’re invisibleand most audiences have no idea really how they behave, so it’s generally a much betteridea (for computer graphics applications) to hack together something that looks cool thantry to simulate them accurately. [BMF07]

13 A velocity field div u = 0 is often called divergenceless or divergence-free.14 Notice that this does not mean that incompressibility =⇒ homogeneity.

23

Page 40: On the simulation of fluids for computer graphics - IMPA

3.4 Balance of Momentum

In this section we incorporate in our model the second of our basic princi-ples, the Newton’s laws of motion. From these, the second is the one mathe-matically translated into properties of our model, while both others imposesimplifying assumptions in our derivations (e.g. symmetry in binary forcesdue to the third law).

To ensure the law of balance of momentum (Newton’s second law of mo-tion), we first need to define it in the context of continuum fluid mechanics.

Definition 8 (linear momentum). The (linear) momentum of a fluid re-gion Ωt is given by the integral15∫

Ωt

ρ (x, t)u (x, t) dV .

With this definition of momentum, Newton’s second law can be stated as

net force on Ωt =d

dt

∫Ωt

ρu dV =

∫Ωt

ρDu

DtdV ,

where the second equality holds from corollary 2.16 The net force on Ωt isdue to contributions from external forces (also known as body or long-rangeforces) and internal forces (also known as surface stress forces).

The canonical example of external force is the gravity field. These forcesact per unit volume on the fluid, so they can be modeled as the productρb : Ωt × I → Rn (where b : Ωt × I → Rn is a vector field denoting theexternal force field per unit mass and, abusing nomenclature, will be calledthe body force field).

An example of surface stress force is the hydrostatic pressure force onefeels when diving, this force is due to the weight of a fluid and increases withthe depth (evidencing the influence of the rest of fluid). These forces aremodeled as a field τ : Ωt × I × Sn−1 → Rn, which depends on the positionin the fluid region’s boundary x, time instant t and the (outward) normal nat the point x on the boundary ∂Ωt.

15 Intuitively, notice that ρu dV = (ρ dV )u denotes the linear momentum (of an “in-finitesimal fluid element”) as defined by Newton’s second law (m~v).

16 Again, intuitively, the quantity ρDuDt dV = (ρ dV )Du

Dt denotes the net force exerted onan “infinitesimal fluid element” (from Newton’s second law, ~F = m~a).

24

Page 41: On the simulation of fluids for computer graphics - IMPA

This way, the net force on Ωt is given by

net force on Ωt = surface stress forces+ body forces

=

∫∂Ωt

τ (x, t,n) dA +

∫Ωt

ρ (x, t)b (x, t) dV

which can be further simplified using a theorem of Cauchy ensuring, as aconsequence of a continuous dependence of τ on n and the balances of linearand angular momenta, the existence of a tensor field T : Ωt × I → Rn×n suchthat τ (x, t,n) = T (x, t) · n and T (x, t) is symmetric

(∀ (x, t) ∈ Ωt × I

).17

From this result, and the Divergence Theorem for tensor fields,

∫Ωt

ρDu

DtdV =

∫∂Ωt

T · n dA +

∫Ωt

ρb dV =

∫Ωt

(Div T + ρb) dV (3.2)

where Div T is the vector in which each component corresponds to the diver-gence of the corresponding row in T (seen as a vector field). This equalityensures the balance of momentum in our model and is known as the integralform of the law of balance of momentum. As we did for mass conservation,assuming regularity of the fields involved, we get the differential form of thelaw of balance of momentum

ρDu

Dt= Div T + ρb. (3.3)

Notice that no further assumptions on the structure of T have been madeto arrive at these forms of balance of momentum. This proves useful whenone desires to study the behavior of Non-Newtonian fluids, which are notdealt with in this text, because all we have done so far has been generalenough to accomodate these materials as well. In the next two sections, wespecialize our derivations assuming a certain structure for T.

17 Although we don’t prove the Cauchy’s Theorem [HM76, Pat87], the particular resultτ (x, t,−n) = −τ (x, t,n), necessary for the linearity of τ on n, is a direct (and simple)consequence of Newton’s third law of motion.[MN91]

25

Page 42: On the simulation of fluids for computer graphics - IMPA

3.5 Ideal Fluids and Euler’s Equations

Our first simplifying assumption on the structure of the tensor field T is thatit doesn’t impose tangential surface forces, i.e. T (x, t) · n is parallel to n.From this assumption, T (x, t) must be a multiple of the identity matrix

T = −pI =⇒ Div T = −∇p

where p : Ωt × I → R is called (mechanical) pressure.18

This assumption of inexistence of tangential forces on a fluid domain’ssurface is an approximation which neglects effects due to viscous friction,that is the reason why fluid flows derived from it are called inviscid or also

Definition 9 (ideal fluids). A fluid flow is called ideal if the surface stressforces are given by a tension field such that τ (x, t,n) = −p (x, t)n.

From these considerations, 3.2 and 3.3, we deduce both the integral anddifferential forms of the law of balance of momentum for ideal fluid flows,∫

Ωt

ρDu

DtdV =

∫Ωt

(−∇p + ρb) dV ⇐⇒ ρDu

Dt= −∇p + ρb

Together with the forms of the law of conservation of mass, the equationsabove form a system of n + 2 unknowns (u, ρ and p)19 and n + 1 equations(n from balance of momentum and 1 from conservation of mass).

One way to “close” this system of equations is coupling p and ρ throughan equation of state, which specifies the pressure as a function of density.In this way, we have p (x, t) = f (ρ (x, t)), where f : R+ → R is smooth.20

Common examples of equations of state used in computer graphics are:

• p (ρ) = c2 (ρ− ρ0), where c is the sound speed in fluid (the maximumspeed attainable by a propagating wave) and ρ0 a reference density;

18 The minus sign in −pI is an account to the intuitive concept that a positive pressureindicates a compression imposed on the fluid domain, i.e. tension is oriented in the oppositedirection of the surface’s normal field.

19 Notice that we assume b is known.20 For a more in-depth discussion of the physical interpretation (and an implicit form)

for equations of state, see [Bat99].

26

Page 43: On the simulation of fluids for computer graphics - IMPA

• p (ρ) = p0

[(ρρ0

− 1], where p0 and ρ0 are the reference pressure and

density, respectively, and γ a constant (typically chosen as γ = 7).21

Another very common way to ensure that all degrees of freedom have beentackled is to assume both incompressibility and homogeneity of the fluid flow,this way we have the system of partial differential equations known as theEuler’s equations (for incompressible homogeneous inviscid flows):

Du

Dt= −∇p + b, div u = 0, u ‖ ∂W (3.4)

where p := 1ρ0

p and the third equation is a boundary condition on the flowasserting that no fluid “traverses walls” but is “allowed” to freely slip alongthem without friction effects. That is the reason why this condition is some-times refered to as (free-)slip, no-stick or inviscid boundary condition.22

In the next chapter, we will present two classes of numerical schemes usedfor the simulation of fluid flows in computer graphics, the first is based onthe Eulerian description of fluid motion and addresses the degrees of freedomby assuming incompressibility and homogeneity of the fluid flows, while thesecond method employs the Lagrangian description and makes use of anequation of state to animate quasi-incompressible fluid flows.

3.6 Newtonian Viscous Fluids and the Navier-

Stokes Equations

As noted in previous section, the assumption of ideal fluids neglects effectsdue to viscous friction. This assumption is reasonable for some gaseous flowsbut it is still too restrictive for many fluids (e.g., water, milk, beer, etc.).

In this section, we make different simplifying assumptions on the structureof the tensor field T in order to model some common “everyday fluid flows”.

21 The first equation was proposed in [MFZ97] and is very popular in computer graphics;

the second was adapted from p (ρ) = (1 + B)(

ρρ0

)n

−B, suggested as an equation of statefor water by [Bat99], where n and B are chosen as 7 and 3, 000 respectively.

22 Different boundary conditions can be imposed on the fluid domain, also often used incomputer graphics are the inflow/outflow, open boundary and the free-surface conditionsdiscussed elsewhere [FM96a, SCP+04, FF01, BMF07] and the no-slip boundary conditionwe discuss later.

27

Page 44: On the simulation of fluids for computer graphics - IMPA

Instead of assuming that T (x, t) = −p (x, t) I as for ideal fluids, we nowassume that T (x, t) = −p (x, t) I + σ (x, t), where σ is such that [CM93]:

1. σ depends linearly on the velocity gradients ∇u, i.e. σ is related to ∇uby some linear transformation at each point.23

2. σ is invariant under rigid body rotations, i.e.

U ∈ SO(n) =⇒ σ(U · ∇u ·U−1

)= U · σ (∇u) ·U−1

This means that, under rigid body rotations, there is no diffusion ofmomentum due to viscosity.

3. σ is symmetric. This can be deduced from the symmetry of T (due tobalance of angular momentum [MH94]).

From these assumptions, the Newtonian fluids ’ assumptions, follows [CM93]

σ = λ tr (D) I + 2µD

where λ (x, t) and µ (x, t) are the non-negative coefficients of viscosity and

D := 12

[∇u + (∇u)T

]is the symmetric part of ∇u.

Since tr (D) = div u, we have T = −pI + λ (div u) I + µ[∇u + (∇u)T

].

From these considerations, the differential form of the law of balance of mo-mentum for Newtonian viscous flows follows:24

ρDu

Dt= −∇p +∇ [λ (div u)] + Div

(µ[∇u + (∇u)T

])+ ρb (3.5)

A common assumption is to consider λ (x, t) = λ0 and µ (x, t) = µ0, yielding25

ρDu

Dt= −∇p + (λ + µ)∇ (div u) + µ∆u + ρb (3.6)

23 This means σ (x, t) = f (∇u (x, t)), for some f : Rn×n → Rn×n linear. Sometimes,we use the notation σ (∇u) instead of σ (x, t) to make explicit the dependence on ∇u.

24 We omitted the integral form for space reasons.25 Notice the use of the laplacian ∆ := ∂2

∂x2 + ∂2

∂y2 + ∂2

∂z2 , which is applied componentwise in

a vector field u yielding another vector field ∆u, and the identity Div[(∇u)T

]= ∇ (div u).

28

Page 45: On the simulation of fluids for computer graphics - IMPA

Which, adding the incompressibility assumption, amounts in the most com-monly used form for the law of balance of momentum in computer graphics:

ρDu

Dt= −∇p + µ∆u + ρb (3.7)

Notice that, if we assumed incompressibility before the homogeneity of λand µ, we would have no dependence on λ because

ρDu

Dt= −∇p + Div

(µ[∇u + (∇u)T

])+ ρb,

which is a form used to model varying viscosity incompressible fluid flows.26

The assumptions of homogeneity (of both ρ and µ) and incompressibilityyield, along with the differential form of the law of conservation of mass, re-sults in the most common system of PDE’s for the modeling of fluid motion,the Navier-Stokes equations (for incompressible homogeneous Newtonian vis-cous flows):27

Du

Dt= −∇p + ν∆u + b, div u = 0, u|∂W = 0 (3.8)

where p := 1ρp, ν := 1

ρµ is known as the kinematic viscosity and the third

equation denotes a boundary condition on the flow asserting that the flow“adheres to walls”, due to effects of viscous friction. For this reason, thiscondition is refered to as the no-slip or viscous boundary condition.

In the next chapter, when we discuss the Lagrangian scheme known asSmoothed Particle Hydrodynamics, it is noticed the omission of one term fromthe differential form of the law of balance of momentum in the PDE’s usedby a popular paper in the computer graphics community. Such omission isdue to an assumption of flow incompressibility, which cannot be ensured bytheir implementation of SPH (not designed for really incompressible flows).

26 This one should be the form of the momentum equation used in [CMIT02], howeverit seems they forgot the second parcel appearing in the diffusive term.

27 Notice that the expression modeling the law of balance of momentum is often calledNavier-Stokes equation. In this text, we use the name Navier-Stokes equation(s) inter-changeably to mean the systems of PDE’s coupling one of the differential forms for thelaw of balance of momentum derived in this section, the differential form of the law ofconservation of mass and the no-slip boundary condition we comment later (and, possibly,an equation of state, if the incompressibility assumption is not made).

29

Page 46: On the simulation of fluids for computer graphics - IMPA

3.7 Pressure and Incompressibility

In section 3.5, we introduced the mechanical pressure p as the magnitude ofcontact forces acting on a fluid surface in a direction parallel to the normaln. Also, we asked fluid incompressibility and homogeneity to determine p.

We now shall explore the role of the pressure in incompressible flow.With this aim, we exploit the following vector field decomposition theorem.

Theorem 2 (Helmholtz-Hodge Decomposition Theorem). Let W ⊆ Rn bea fluid region and u : W → Rn a smooth vector field. There exists a uniquedecomposition of u such that, for smooth us :W → Rn and up :W → Rn,

u = us + up, ∇ · us ≡ 0 on W , us · n ≡ 0 on ∂W , up ≡ ∇φ on W

for some smooth φ :W → R.

Proof. The existence of such a decomposition is due to the existence of afunction φ :W → R such that, for smooth f :W → R and g : ∂W → R,

−∆φ = f on W ,dφ

dn= g on ∂W ⇐⇒

∫W

f dV = −∫

∂W

g dA.

Taking f := −∇ · u and g := u · n, the divergence theorem ensures theright-hand side of the above equivalence, which guarantees a φ as before.Defining up := ∇φ and us := u−up, it is easy to verify the stated properties.

To prove uniqueness, we suppose that u = uas + ua

p = ubs + u2

p, then

0 = (uas − ub

s) + (uap − ub

p) = (uas − ub

s) +∇(φa − φb).

Taking the L2 inner product with (uas − ub

s), we have that

0 =

∫W

‖ua

s − ubs‖22 + (ua

s − ubs) · ∇(φa − φb)

dV

=

∫W

‖uas − ub

s‖22 dV +

∫W

∇ ·[(φa − φb)(ua

s − ubs)]dV

=

∫W

‖uas − ub

s‖22 dV +

∫∂W

(φa − φb)[(ua

s − ubs) · n

]dA =

∫W

‖uas − ub

s‖22 dV

where the second equality is due to ∇·uas = ∇·ub

s = 0 onW , the third to thedivergence theorem and the final is due to ua

s · n = ubs · n = 0 on ∂W . This

implies that ‖uas −ub

s‖L2 = 0, hence we must have uas = ub

s and uap = ub

p.

30

Page 47: On the simulation of fluids for computer graphics - IMPA

The above proof is specially important because it provides a method toperform the Helmholtz-Hodge decomposition of a vector field through theresolution of a Poisson problem with Neumann boundary conditions. Thismethod will be useful later to the design of numerical simulation algorithms.

The field us is called the divergence-free (or divergenceless) componentof u, while up is known as its potential (or gradient) part. With this result,we are able to define an orthogonal projection operator which maps a givenvector field onto its divergence-free (incompressible) component.

Definition 10 (projection operator). The projection operator P acts onvector fields for which the Helmholtz-Hodge Decomposition Theorem holdsand is defined as Pu := us, where us is the divergence-free component of u.

The importance of this operator may be better appreciated through itsaction on both Euler’s and the Navier-Stokes equations for homogeneousincompressible flows (3.4) and (3.8), which take, respectively, the forms:

ut = P(−u · ∇u + b

), div u = 0, u ‖ ∂W

ut = P(−u · ∇u + ν∆u + b

), div u = 0, u|∂W = 0

These equations shed some light on the role of pressure in incompressiblefluid flows. From them, one can think about pressure as whatever it takesto keep flow incompressibility [BMF07].28 Other interesting implication ofthe above equations is the “blindness” of the fluid flow to conservative bodyforces

(i.e., ∃U : W → R such that b = −∇U

), since this implies P

(b)≡ 0.

Such forms of the governing equations not only allow us to give an in-terpretation for the role of pressure in incompressible fluid flows, but alsothey are at the heart of some of the most commonly used numerical schemesfor the animation of fluid flows in the computer graphics community. Theexploitation of the projection operator to design a numerical scheme basedon the Eulerian description of fluid motion is discussed in the next chapter.

28 Such a loose interpretation for pressure is often exploited by fluid modelers to enforcesome properties at the fluid’s boundary (e.g., the pressure jump in two-phase fluids [HK05],the coupling of fluids and deformable bodies [GSLF05, CGFO06]).

Another way of thinking about pressure comes from interpreting it as a Lagrange multi-plier of a fluid dynamics constrained by the incompressibility condition (i.e., the equalityconstraint div u ≡ 0) [BMF07].

31

Page 48: On the simulation of fluids for computer graphics - IMPA

3.8 Rotation and Vorticity

In this section, we study the rotational motion of fluids. Such a study isof foremost importance due to the key influence of turbulent and rotationalbehavior of fluids in the visual perception of fluid motion. To this end,we introduce the concept of vorticity as closely related to the local angularvelocity of the flow.

Definition 11 (vorticity). The vorticity field ω : D × I → Rn of a fluid flowis defined as the curl of the flow’s velocity field, i.e. ω (x, t) := ∇× u (x, t).

As the curl of the velocity field u, the vorticity quantifies the local spin-ning speed and direction induced by the fluid flow map. Such an interpreta-tion can also be supported by Batchelor’s definition of vorticity as twice thelocal angular velocity [Bat99].

An interesting result regarding the local structure of a vector field states,

Proposition 1. Consider a stationary flow29 around a small neighborhood

of a given point x0 ∈ D. Let u0 := u (x0), D0 := 12

(∇u (x0) +

(∇u (x0)

)T)and ω0 := ω (x0), then, for sufficiently small ‖h‖,30

u(x0 + h) ≈ u0 + D0 · h +1

2ω0 × h

Proof. This proposition follows imediately from Taylor’s formula and thefact that ω (x) equals twice the anti-symmetric part of ∇u (x) (propertyreadly verifiable by simple hand calculation).

This proposition can be physically interpreted as: a fluid flow’s veloc-ity field induces, locally and approximately, the superposition of translation,deformation and rotational effects. From it, we can appreciate the role of vor-ticity in the rotational behavior of the fluid flow and a reason for Batchelor’sdefinition of ω.

We now introduce the notion of circulation, which may be understood asthe total amount of “spinning” around a closed contour.

29 A fluid flow is said stationary if its velocity field is time-independent, i.e. ∂u∂t ≡ 0.

Notice this doesn’t imply that u ≡ 0.30 Somewhat more precisely stated: for every h ∈ Rn such that (x0 + h) ∈ D,

u (x0 + h) = u0 + D0 · h + ω0 × h + o(‖h‖

).

32

Page 49: On the simulation of fluids for computer graphics - IMPA

Definition 12 (circulation). Let C0 ⊂ Ω0 be a simple closed contour in thereference configuration Ω0 at time t = t0 and Ct := ϕ (C, t) be the contourcarried along by the flow. The circulation ΓCt around the curve Ct is definedto be the line integral ΓCt =

∮Ct

u · ds, where ds is the line element on Ct.

This definition relates, through Stokes’s Theorem, the circulation arounda contour to the flux of vorticity across a surface bounded by this curve.

By now, we are ready to prove some theorems regarding properties of thevorticity field induced by a fluid flow and the circulation around advectedcontours. The first of those, is a lemma that resembles the transport theorem.

Lemma 2. ddt

∮Ct

u · ds =∮Ct

DuDt· ds

Proof. Let x (s) be a parametrization of the loop C0, s ∈ [0, 1]. Then aparametrization of Ct is ϕ

(x (s) , t

), s ∈ [0, 1]. Thus, by definition of the line

integral and the material derivative,

d

dt

∮Ct

u · ds =d

dt

1∫0

u(ϕ(x (s) , t

), t)· ∂

∂sϕ(x (s) , t

)ds

=

1∫0

Du

Dt

(ϕ(x (s) , t

), t)· ∂

∂sϕ(x (s) , t

)ds

+

1∫0

u(ϕ(x (s) , t

), t)· ∂

∂t

∂sϕ(x (s) , t

)ds

=

∮Ct

Du

Dt· ds +

1∫0

u(ϕ(x (s) , t

), t)· ∂

∂su(ϕ(x (s) , t

), t)ds

=

∮Ct

Du

Dt· ds +

1

2

1∫0

∂s

(u · u

)(ϕ(x (s) , t

), t)ds

=

∮Ct

Du

Dt· ds, since Ct is a simple closed contour.

With this result, we can prove that the circulation around any reducibleclosed curve that is advected by an ideal flow is an invariant quantity.

33

Page 50: On the simulation of fluids for computer graphics - IMPA

Theorem 3 (Kelvin’s Circulation Theorem). For an inviscid incompressiblehomogeneous fluid flow subject to the action of conservative external forces,ΓCt is constant in time, i.e. ∀t ∈ I, ΓCt = ΓC0 ∈ R.

Proof. From DuDt

= −∇p−∇U = −∇(p + U) and the preceding lemma,

d

dtΓCt =

d

dt

∮Ct

u · ds =

∮Ct

Du

Dt· ds = −

∮Ct

∇(p + U) · ds = 0

where the last equality follows from the fact that Ct is a closed contour.

Such a result has a different interpretation regarding the flux of vorticityacross an advected surface, which has recently been exploited to numericallysimulate fluid motion for computer graphics applications [ETK+07].

Corollary 3. The flux of vorticity across a surface moving with an inviscidincompressible homogeneous fluid under potential forces is constant in time.

Proof. The flux of vorticity across the surface, by Stokes’ Theorem, equalsthe circulation across its bounding curve. The corollary follows by applyingKelvin’s Circulation Theorem to this curve.

Another very useful result deals with the dynamics of the vorticity field.

Proposition 2. Consider an incompressible homogeneous fluid flow underconservative body forces, then we have

(i) in the inviscid case (modeled by Euler’s equations 3.4):

Dt= (ω · ∇)u

(ii) in the viscous case (modeled by the Navier-Stokes equations 3.8):

Dt= (ω · ∇)u + ν∆ω

Proof. Both items can be verified by taking the curl of the respective momen-tum equation, using the vector identities 1

2∇(u ·u) = u× (∇×u)+(u ·∇)u,

∆F = ∇(∇ ·F)−∇× (∇×F), ∇× (∇f) = 0, ∇× (F×G) = F(∇ · G)−G(∇ · F) + (G · ∇)F − (F · ∇)G and ∇ · (∇ × F) = 0, and from theincompressibility condition.31

31 The identity for ∆F is used only in the viscous case (for F = u and again for F = ω).A lot of such useful vector calculus’ identities can be found in the last pages of [CM93].

34

Page 51: On the simulation of fluids for computer graphics - IMPA

Corollary 4. If n = 2 (two-dimensional flow) and the fluid is incompressibleand homogeneous (under conservative body forces), then Dω

Dt= 0 (in the

inviscid case) and DωDt

= ν∆ω (in the viscous case).

Proof. Follows from the preceding proposition and that, for n = 2, ω isorthogonal to the velocity field, which is constrained to the plane z = 0.

This corollary ensures the time invariance of vorticity along particle tra-jectories of bidimensional fluid flows. Such property has also been used incomputer graphics animations [GLG95].

Some interesting objects of study consist of special curves and surfacesembedded in the fluid domain which are everywhere tangent to the vorticitydistribution.

Definition 13 (vortex line/sheet). Let C (S) be a regular curve (surface) inD. We call C (S) a vortex line (sheet) if, for each time instant t ∈ I, it istangent to the vorticity field ω, i.e. ∀x ∈ C (∈ S), ω (x, t) ∈ TxC (∈ TxS).

These concepts model situations where there is a structured distributionof vorticity along a curve or a surface. For example, in a distant scale, atornado could be mathematically modeled as a vortex line. In a closer scalea different notion would be necessary,

Definition 14 (vortex tube). Let S ⊂ D be a two-dimensional surface (dif-feomorphic to a disc) that is nowhere tangent to ξ at a time t and C := ∂S itsbounding curve. We call T :=

⋃x∈C

integral line of ω through x at time t

a

vortex tube.

Notice that every vortex tube is a vortex sheet, but the converse is not truein general. Intuitively, it is like a vortex sheet that has been twisted to theshape of a cylinder, but the vorticity field is kept tangent to this cylinder’swall (i.e., the vortex tube). This provides a simplified model for a tornadobuilt-up by rising air-currents in the atmosphere. An invariance propertyalso holds for ideally advected vortex structures.

Proposition 3. If a surface (or curve) moves with the flow on an inviscidincompressible homogeneous fluid under conservative body forces and is avortex sheet (line) at t = t0, then it remains so for all time.

35

Page 52: On the simulation of fluids for computer graphics - IMPA

Proof. Let P ⊆ S be an arbitrary patch (regular surface diffeomorphic to adisc) of S. From the definition of a vortex sheet, ω ·n = 0 at time t0 (wheren is the unit normal to S). By the preceding corollary, the flux of vorticityacross P is zero for all time. Since P is arbitrary, by continuity, ω · n = 0for all time in S. Then, S will always remain a vortex sheet.

For a vortex line C, we use the Implicit Function Theorem (under theassumption that ω is non-zero at every point of C for all time) to describe Cas (locally) the intersection of two vortex sheets and use the surface case.

We also have the notion of strength of a vortex tube and an invariancetheorem for this quantity as the tube evolves along the flow.

Theorem 4 (Helmholtz’s Theorem). Consider an inviscid incompressiblehomogeneous fluid flow under conservative body forces. Then

(i) If C1 and C2 are two arbitrary curves encircling the same vortex tube,then

ΓC1 =

∮C1

u · ds =

∮C2

u · ds = ΓC2 .

This common value is called the strength of the vortex tube.

(ii) The strength of a vortex tube is constant in time, as the tube moveswith the fluid.

Proof. Let S ⊂ T be the segment of the vortex tube T diffeomorphic to abounded (open) cylinder whose bounding countours are the loops C1 and C2(supposed non-intersecting). Let S1 and S2 be two arbitrary regular surfacesdiffeomorphic to a disc whose bounding curves are given by C1 and C2, respec-tively. Let Σ := S1 ∪ S ∪ S2 be the boundary of the bounded fluid region V(which is “inside the vortex tube”). By Gauss’ Theorem, the vector calculusidentity ∇ · (∇× F) = 0 and the definition of the vorticity field ω, we have

0 =

∫V

∇ · ω dV =

∫Σ

ω · n dA =

∫S1∪S2

ω · n dA +

∫S

ω · n dA

=

∫S1∪S2

ω · n dA =

∫S1

ω · n dA +

∫S2

ω · n dA =

∮C1

u · ds−∮C2

u · ds

36

Page 53: On the simulation of fluids for computer graphics - IMPA

where the last equality follows from Stokes’ Theorem and, without loss ofgenerality, the assumption that C2 is oriented clockwise with respect to Σ’sunit (outward) normal field n. Thus ending the proof of item (i).

Having proved (i), item (ii) now follows from the circulation theorem.

This classic theorem allows us to observe that, if a vortex tube getsstretched and its cross-sectional area decreases, then the magnitude of ωmust increase. Thus, the stretching of vortex tubes can increase vorticity,but it cannot create it. This also implies that, with the increase of vorticity,the particles near the stretched region spin faster. A phenomenon similar tothe increased angular velocity of a figure skater when, once in rotation, shecloses her arms to spin faster.32

3.9 Comments and Further Reading

In this chapter, we presented the basics of mathematical fluid dynamics.We tried to provide a coherent development of the main concepts and re-sults used by the computer graphics community in the design of novel fluidanimation tools and techniques.

The mathematical theory of fluid dynamics is a very broad subject, tobegin a more in-depth study, we would recommend the textbooks [Bat99,CM93, Mey82].33 Other classic texts on this theory include [Lam93, CF76].

Many interesting topics were completely ignored in the main text, eventhough they have been investigated for computer graphics applications (e.g.shallow-waters/long-waves equations [Whi99, KM90, LvdP02], wave equa-tion [Eva98, Joh91, BMF07, YHK07], vorticity dynamics formulation [CM93,GLG95, PK05, ETK+07], cellular-automata and lattice-Boltzmann mod-els [WG00, Thu07, HCSL02, WLMK04, TRS06]).

It is interesting to observe that our first notions of motion and the resultsrelated to mass conservation (and some others) are mostly grounded on thebasic assumptions of continnum mechanics. As such, they would also bepresent in an account on the mathematical theory of elastic solids [MH94,Lov44, TPBF87, TF88, NMK+06], motivating this chapter as well for thosealso interested in the animation of elastically deformable objects.

32 This effect is due to the law of conservation of angular momentum.33 Batchelor’s book is a good source of physical interpretations for the results, Chorin’s

is a classic for those mathematically savvy and Meyer’s text provides a very nice balanceof physical motivation and mathematical rigour in a clear and well written text.

37

Page 54: On the simulation of fluids for computer graphics - IMPA

38

Page 55: On the simulation of fluids for computer graphics - IMPA

Chapter 4

Numerical Simulation of Fluidsfor Animation

In this chapter, we present two representatives of the numerical schemes mostcommonly used by the computer graphics community for the simulation offluid flows with the purpose of animation, namely, the Stable Fluids and theSmoothed Particle Hydrodynamics methods.

In Stable Fluids, the Eulerian description of fluid motion is adopted andthe fluid domain is discretized as a computational grid, in which the fieldquantities are stored and their differential operators are approximated byfinite differences schemes. Operator splitting / fractional-step methods areused to decompose the governing partial differential equations into a seriesof smaller (and simpler to solve) equations connected by their respective ini-tial conditions. To numerically solve each subproblem, efficient and stablemethods are chosen from the computational fluid dynamics literature and ad-equately adapted to the performance and robustness requirements demandedby graphics applications.

The Smoothed Particle Hydrodynamics scheme is based on the Lagrangianviewpoint of fluid dynamics and relies on a discretization of the fluid massin a finite number of blob-like moving particles. To represent fluid prop-erties (e.g., velocities, density) and their differentials, this method employstools from approximation theory and scattered data interpolation to smooththese quantities from particles’ positions to the whole fluid domain. Such aparticle-based description of the fluid dynamics reduces the governing PDE’sto a coupled system of ordinary differential equations whose solution can beapproximated by classical time-stepping methods.

39

Page 56: On the simulation of fluids for computer graphics - IMPA

4.1 Stable Fluids

In this section, we describe the basic stable fluids scheme as presented by JosStam in [Sta99], with a minor modification to add “vortex detail” throughvorticity confinement forces, as was introduced by Fedkiw et al. in [FSJ01].

To keep clarity of presentation and focus on the salient features of thismethod, we restrict our attention to a simple flow regime and to the useof basic discretization and numerical schemes. At the end of this chapter,we provide further references to other works devoted to both extending andfixing some problems encountered in the basic stable fluids approach.

4.1.1 Flow regime and governing equations

The flow regime with which we present the stable fluids scheme comprehendsa wall-bounded square domain inside which an incompressible homogeneousviscous Newtonian fluid flows subject to external (user-applied) body forces.In these conditions, we model the fluid flow with the Navier–Stokes equationsas presented in the previous chapter (the projected version of the NSE):1

ut = P(−u · ∇u + ν∆u + b

), div u = 0, u|∂W = 0 (4.1)

where W = (0, 1)n ⊂ Rn is the open unit hypercube (i.e., square or cube).2

4.1.2 Field representation and spatial discretization

In order to approximate candidate solutions of 4.1,3 we first need to representthe unknown field quantities involved

(e.g., u :W × [0, +∞)→ Rn

).

To represent a scalar (or vector) field f :W → R, we discretize its domainW into a Nn grid, where N ∈ N is the grid’s resolution along each dimension,

1 The reasons for this choice will be clearer when we present the time-stepping stategyadopted in stable fluids.

2 Notice that, although not everywhere smooth, ∂W is smooth enough (indeed piece-wise C∞) to hold the theory we developed in the previous chapter.

3 It is still an open problem both the existence and uniqueness of solutions to4.1 in dimension three. In fact, the Clay Mathematics Institute offers a prize of1 million dollars to anyone that (dis)proves existence and uniqueness of solutions tothe Navier-Stokes equations. For a detailed statement of this Prize Problem seehttp://www.claymath.org/millennium/Navier-Stokes Equations/.

40

Page 57: On the simulation of fluids for computer graphics - IMPA

and store a sample of this function value at the middle of each grid’s voxel.This strategy to discretize a function at cell-centered samples in a regulargrid is known as collocation and the structure is called a collocated grid. It isone of the classical representations used by finite differences schemes, whichapproximate the continuous differential equations on bounded domains bydiscrete difference equations on finite regular point sets [Str04, LeV07, Tre96].

With this domain discretization, we use the finite differences method toapproximate both the spatial and temporal differential operators by differ-ence equations. The most common of these difference approximations are(for a 1D scalar field):

forward differences:df

dx(xi) ≈

fi+1 − fi

h

backward differences:df

dx(xi) ≈

fi − fi−1

h

central differences:df

dx(xi) ≈

fi+1 − fi−1

2h

where h = 1N

is the space step. These schemes to approximate the differen-tial operator d

dxprovide the most basic building blocks with which we will

search approximate solutions to differential equations. For example, assum-ing n = 2, the differential operators appearing in 4.1 could be discretizedas:

ut (xi, yj, tn) ≈un+1

i,j − uni,j

k

∇u (xi, yj, tn) ≈

(un

i+1,j−uni−1,j

2h

vni+1,j−vn

i−1,j

2hun

i,j+1−uni,j−1

2h

vni,j+1−vn

i,j−1

2h

)

∆u (xi, yj, tn) ≈un

i+1,j − 2uni,j + un

i−1,j

h2+

uni,j+1 − 2un

i,j + uni,j−1

h2

div u (xi, yj, tn) ≈un

i+1,j − uni−1,j

2h+

vni,j+1 − vn

i,j−1

2h

where k > 0 is the time step and u (x, y, t) =(u (x, y, t) , v (x, y, t)

).4

Remark: Various choices for combining spatial-temporal finitedifferences approximations are discussed in [Str04, LeV07] as well

4 In these equations, the superscript n and the subscripts i,j denote a value sampled attime tn and at the point xi,j = (xi, yj), respectively.

41

Page 58: On the simulation of fluids for computer graphics - IMPA

as their implications. We have decided not to discuss issues re-lated to concepts as consistency, order, stability, or accuracy ofapproximations in this text. The interested reader is directed tothe cited references for in-depth treatments of these subjects.5

A note is needed regarding this discretization scheme with respect to thetreatment of boundary conditions. Whenever we need to approximate thedifferential at a boundary cell, the value at an inexistent adjacent cell isneeded. To deal with this problem, an additional layer of cells is appendedadjacently to ∂W (in the “outer side”) and their values are determined byboth the values at the “inner” boundary cells and the boundary conditions.

As an example, we deal with the homogeneous Dirichlet boundary con-ditions of 4.1 (u|∂W = 0) by assigning to an outer cell the negated value ofits adjacent inner cell, as the averaged value at the boundary point betweenthem thus satisfies the no-slip boundary condition. Homogeneous Neumannconditions are dealt with in the same way, except that, rather than assigningthe negation of the value in the adjacent cell, the assigned value is the samestored at the adjacent inner cell. In this way, the normal derivative at theboundary point is zeroed, thus obeying the homogeneous Neumann bound-ary condition

(dudn

= 0, at ∂W). This kind of condition appears both in the

simulation of inviscid flows and in the determination of pressures betweenthe fluid and solid obstacles (a stationary solid wall in our flow regime).Additional material regarding common boundary conditions in graphics ap-plications can be found in [FM96a, BMF07].

4.1.3 Operator splitting/fractional-stepping

For simulating unsteady flows, we need a time-stepping scheme to advancein time the field quantities that represent our fluid. To this end, we adoptan operator splitting/fractional-stepping method [PTVF92, MQ02] to decom-pose 4.1 in a sequence of simpler subproblems (each one connected to theprevious by its initial condition), which are solved by specialized schemes.

5 An advice, if you decide to study finite difference schemes by the first edition ofStrikwerda’s book, manage to download its 13-page errata!

42

Page 59: On the simulation of fluids for computer graphics - IMPA

Our splitting of 4.1 consists in the following sequence of subproblems6:

• Convection: which describes the “self-transport” in fluid flows.

ut = −u · ∇u ⇐⇒ Du

Dt= 0

• Forcing: which accounts for external/body forces acting on the fluid.

ut = b

• Diffusion: which propagates viscous stresses across the fluid domain.

ut = ν∆u

• Projection: which enforces incompressibility by applying pressure forces.

ut = −∇p, div u = 0

where each of these time-dependent PDE’s has as initial condition a solutionof the previous equation. This means that, to advance a complete time stepfrom un

i,j to un+1i,j , the discretized field un

i,j (assumed to be divergence-free)is used as the initial condition for numerical integration of the convectionequation along a time interval of lenght k and the resulting (convected) fieldun,c

i,j is used as initial condition for the subsequent step (in this case, forcing).

In this way, the sequence of fields un,ci,j , un,f

i,j , un,di,j and un,p

i,j (respectivelyconvected, forced, diffused and the final projected velocity fields) is generatedfrom un

i,j and un+1i,j is taken as the last of these intermediate fields.7

The processing of a time step by this splitting can be summarized as:

uni,j

convection−−−−−−→ un,ci,j

forcing−−−−→ un,fi,j

diffusion−−−−−→ un,di,j

projection−−−−−−→ un,pi,j → un+1

i,j

In the following subsections, we describe the methods chosen to solve eachsubproblem of the operator splitting scheme adopted by Stable Fluids.

6 Respectively augmented by appropriate boundary conditions. Notice that, to simulateinviscid flows governed by Euler’s equations, the diffusion step should be ommited.

7 Notice that un+1i,j = un,p

i,j is a divergence-less velocity field, so that it is ready to beused as initial condition for integration into un+2

i,j .

43

Page 60: On the simulation of fluids for computer graphics - IMPA

4.1.4 Semi-Lagrangian advection

The numerical integration of the convection equation 0 = ut + u·∇u = DuDt

,also known as the (inviscid) Burgers’ equation, will be performed by approx-imating the solution of this nonlinear PDE by a sequence of solutions to theadvection/transport equation 0 = ft + u · ∇f = Df

Dt, a linear PDE (on f).

Such an approach to this problem is motivated by the interpretation of thematerial derivative operator D

Dt= ∂t + u · ∇ as the rate in which a quantity

changes along a material trajectory. So the equation DfDt

= 0 means thatf (x (t) , t) is constant in time, where x (t) denotes a material curve/trajectory(hence an integral line of u, if it is assumed steady, i.e., ut ≡ 0).

This is the key reasoning behind the semi-Lagrangian methodology foradvection, where the goal is to transport a field through a divergence-freesteady velocity/vector field during a given time step k > 0 [SC91]. To thisend, a semi-Lagrangian solver takes a velocity field u, an initial (scalar,vector, tensor etc.) field fn and outputs a field fn+1 as the solution offt + u · ∇f = 0 (with initial condition fn) evaluated at time tn+1. Sucha task is performed by assigning to fn+1

i,j the value from fn at the pointx (k) ∈ W , where x is the solution of the following ODE:

x = −u (x) , x (0) = xi,j.

Intuitively, this means that the value attributed to fn+1i,j (located at xi,j) is

the same as that from the point where the particle positioned at xi,j at timetn+1 was at time tn = tn+1 − k, i.e. to set fn+1

i,j , we backtrace xi,j along thevector field u during a time step k and evaluate fn (which, for a discretizedrepresentation fn

i,j, involves an interpolation procedure).

It is with the semi-Lagrangian method to solve advection equations, weapproximate a solution to the convection equation. This is performed byadvecting un

i,j along itself, i.e. we solve a vector advection equation whereun

i,j is taken as both the steady velocity field (along which the transportedfield flows) and as the initial condition for its solution. Therefore, the valueatributed to un,c

i,j is computed by tracing backward in time a massless particleat xi,j along the steady vector field un

i,j (using some ODE time-stepper, e.g.Euler scheme) and interpolating un

i,j at the resulting position (e.g. usingbilinear interpolation), the vector value thus found in assigned to un,c

i,j .

44

Page 61: On the simulation of fluids for computer graphics - IMPA

4.1.5 Explicit forcing and vorticity confinement

To integrate the body forcing equation ut = b during a time step k > 0,we assume ∂b

∂t= 0 in (tn, tn+1)×W , effectively approximating b by a vector

field which varies piecewise-constantly in time. With this approximation, wehave un,f

i,j = un,ci,j + kbn

i,j, which is equivalent to applying the forward Euler

scheme to the ODE ddtui,j(t) = bn

i,j and advancing from un,ci,j to un,f

i,j .

Vorticity confinement. A particular kind of body force was introducedby [FSJ01] with the purpose of adding “vortical detail” into fluid simulationsfor computer graphics, the vorticity confinement forces bvc. Their analytical

expression bvc = εh(

η‖η‖ × ω

), where ε > 0 is used to control the amount

of detail added into the flow, h > 0 is the grid spacing, η = ∇‖ω‖ andω = ∇ × u is the vorticity as defined in the previous chapter, reflects theintended effect of “slapping” the vortical regions and augmenting the overallrotational motion present in the flow. Vorticity confinement forces have beenboth widely used and extended for simulation on coarse grids as those usedin computer graphics applications [FSJ01, SRF05, SU94].

4.1.6 Implicit diffusion

The diffusion step in our splitting scheme is the classical heat equation withDirichlet boundary conditions

(the no-slip condition, u|∂W = 0

)[Eva98, Joh91].

To numerically solve the diffusion equation, we adopt a fully implicit schemebased on a backward in time and central in space discretization scheme[PTVF92, Str04, LeV07, Tre96]. In such an approximation, the spatial dif-ferential operator (in this case, the laplacian ∆) is discretized using centraldifferences yielding a coupled linear system of ODE’s on the unknown vari-ables. Then, the backward Euler scheme is applied to this resulting ODE:

ut = ν∆u −→ d

dtu =

ν

h2Lu −→ un+1 − un

k=

ν

h2Lun+1

where u groups the unknown grid values ui,j in a vector of dimension N2

and L is the finite differences matrix representing the laplacian operator.8

8 A component-wise version of the above differential/difference equations would read:

d

dtui,j = ν

(ui+1,j − 2ui,j + ui−1,j

h2+

ui,j+1 − 2ui,j + ui,j−1

h2

)initial←−−−−−−

conditionu0

i,j = un,fi,j

45

Page 62: On the simulation of fluids for computer graphics - IMPA

Notice that the last equation from the backward Euler discretization isequivalent to solving the linear system of equations

(I− ν k

h2L)un+1 = un,

where un+1 corresponds to un,di,j and un represents un,f

i,j . It is interesting tonotice that the matrix on the right-hand side of this system has good numer-ical properties: it is symmetric, positive definite and sparse. So specialized(and fast) methods can be applied to approximately solve these equations(e.g., preconditioned conjugate gradients and multigrid methods [Dem97]).9

Another very important property of the above discretization scheme isthat

(I− ν k

h2L)

has eigenvalues stricly greater than 1, an implication of thisfact (and a very instructive exercise in numerical analysis of ODE’s) is that,no matter how large the time step k, the numerical integration conserves theasymtoptic behaviour of the original ODE (as t → +∞, the solution con-verges to the origin). This means that we can take arbitrarily large time stepswithout suffering with stability concerns, i.e., the simulation never “blowsup” as a consequence of diffusion, a very important feature for simulatorsdesigned for computer graphics applications [Sta99, CMIT02].

4.1.7 Pressure projection

After performed the diffusion step, the resulting velocity field un,di,j is not

divergence-free, so doesn’t respect the law of conservation of mass. Hence weneed to solve for pressure, since it has an incompressibility enforcement role(as noticed in the previous chapter), and complete our splitting pipeline.

After discretizing in time the projection equation we have that:

ut = −∇p, div u = 0 −→ un+1 − un

k= −∇pn+1, div un+1 = 0

Taking the divergence on both sides of the discretized equation yields:

−∆pn+1 = −1

k∇ · un, in W

un,di,j − un,f

i,j

k= ν

(un,d

i+1,j − 2un,di,j + un,d

i−1,j

h2+

un,di,j+1 − 2un,d

i,j + un,di,j−1

h2

)

Notice that, actually, u would have dimension (2N)2, because u is a vector field in R2,but here it is treated as a scalar field, since the laplacian operator is applied separatelyfor each coordinate field u, v of u = (u, v).

9 The implementation of Stable Fluids we have is based on an iterative Gauss-Seidelmethod for simplicity reasons.

46

Page 63: On the simulation of fluids for computer graphics - IMPA

where the no-slip condition (in fact, the kinematic condition that u ‖ ∂W)and the original partial differential equation give a homogeneous Neumanncondition on pn+1, i.e. dpn+1

dn= 0 on ∂W . Solved this Poisson problem with

Neumann boundary conditions, we take un+1 = un−k∇pn+1. The interestingfact behind all these calculations is that we have in fact taken un+1 as theprojection of un by P, what can be verified by projecting the last equation:

un+1 = P(un+1

)= P

(un − k∇pn+1

)= P (un)

This configures a remarkable application of the projection operator Pdefined through the Helmholtz–Hodge Decomposition Theorem. It provides anatural connection between the abstraction from the theory and a tool in thepracticalities of numerical computation. Such a view for incompressibilityenforcement has been extensively exploited and extended by others bothto advance the theory and to design new simulation techniques that modelthe coupling of multiple fluids and solids [CM93, HK05, LSSF06, CMT04,GSLF05, FOKG05, CGFO06, BBB07].

With these considerations we are able to design a numerical scheme toenforce flow incompressibility and solve the final step of our splitting method.To apply the above procedure for advancing from un,d

i,j to un,pi,j , all we need is

to solve the Poisson problem described before. This is done by discretizingin space the laplacian operator in the very same way as done for diffusion10,with the sole observation regarding the change from Dirichlet to Neumannboundary conditions as noted in the subsection on spatial discretization. Thediscretization procedure yields a linear system of equations:

−∆p = f −→ − 1

h2Lp = − 1

2hkDu ⇐⇒ (−L) p = − h

2kDu

where L is as before, p groups the unknown grid values pni,j in a vector

of dimension N2, D denotes the finite differences matrix of the divergenceoperator and u groups the known grid values un,d

i,j

(now really in a vector of

dimension (2N)2, since the divergence operator needs derivatives for both uand v of u = (u, v)

).11 Where (−L) shares the same properties commented

about the matrix derived for the diffusion step, hence the same methods usedto solve numerically that problem can be reused in the projection step.

10 Just notice that, for diffusion, the laplacian operator was applied for each u, v ofu = (u, v). Therefore, we will use the same notation for the finite differences matrix Lused to solve for pressure.

11 The above equations in matrix/vector-form comprise just a compact version of the

47

Page 64: On the simulation of fluids for computer graphics - IMPA

After solving for pni,j, we finally compute un,p

i,j = un,di,j − k∇pn

i,j by approx-imating the gradient operator by central differences, yielding the update

un,pi,j = un,d

i,j −k

2h

(pn

i+1,j − pni−1,j

pni,j+1 − pn

i,j−1

),

finishing the pressure projection step and one step of our splitting scheme.

4.1.8 Experiments

As an illustration for our description of the basic Stable Fluids method,we implemented a simple fluid simulator in the C language for the flow regimedescribed in 4.1.1. In this subsection, we present some results generatedwith that solver and some issues which appeared during its development.Appendix A presents the core code of our simple Stable Fluids solver as amore concrete example of the method described.

Flow visualization. For our basic Stable Fluids solver, we implemented acouple simple visualizations to inspect some concepts discussed in Chapter 3:

• scalar fields advected and diffused along the fluid flow as marker dyefields (top left of Figure 4.1), evolving according to Df

Dt= κ∆f + f ;

• velocity fields depicted by small vectors originating at computationalcell centers (top right of Figure 4.1);

• scalar fields derived from other fields (e.g. the velocity and vorticitymagnitude fields ‖u‖ and ‖ω‖, at the middle and bottom of Figure 4.1).

These visualizations were implemented with OpenGL with simple user in-teractions using GLUT (e.g., mouse-driven body forcing and dye sourcing).

linear system formed from:

−(

pni+1,j − 2pn

i,j + pni−1,j

h2+

pni,j+1 − 2pn

i,j + pni,j−1

h2

)=

− 1k

(un,d

i+1,j − un,di−1,j

2h+

vn,di,j+1 − vn,d

i,j−1

2h

)

48

Page 65: On the simulation of fluids for computer graphics - IMPA

Some results. The solver presented in Appendix A is able to simulate bothinviscid and viscous flows. We comment a couple results generated using it.

Figure 4.1 contains some visualizations of a simple flow in which the fluidwas acted by localized mouse-driven body forces pushing the fluid up frombottom. This motion induced the generation of two main vortices which wereadvected along the inviscid flow and transported the dye scalar field.

Figure 4.2 depicts a later frame in a more complex viscous flow animation,in which there is plenty of rotational behaviour and localized vortices kept“alive” by vorticity confinement forces.

Figure 4.3 illustrates the generation of vorticity along boundaries in vis-cous Navier-Stokes flows (left) and the sole transport of vorticity along withinviscid Euler flows (right), in accordance with Corollary 4.

Implementation issues. The development of a fluid simulator is a deli-cate problem, many little details must be kept in mind when implementingsuch a code. Care must be taken in enforcing the boundary conditions ateach stage during simulation and in performing interpolations at the advec-tion stage. Another issue is solving the linear systems that arise in the finitedifference discretization of the linear PDE’s; often it is not needed to build thesystem matrix to apply an iterative method [Dem97], we employed a simpleGauss–Seidel method, but other methods (e.g., Krylov subspace methods)only require the programmer to provide a routine which returns the resultof multiplying a given vector by the system matrix and have better con-vergence rate properties (e.g., preconditioned conjugate gradients) [Saa03].These methods avoid keeping large (and sparse) matrices saving memory,time and implementation/maintenance efforts [BBC+94] of both diffusionand projection stages (we didn’t use them in our code to keep it simple).For other details on developing more complex simulators, we recommend thepractical approach taken in the lecture notes [BMF07].

49

Page 66: On the simulation of fluids for computer graphics - IMPA

Figure 4.1: A “simple” flow example; Top left: scalar field advected/diffusedalong the velocity field depicted in the top right figure; Middle: magnitudesof the velocity field; Bottom: magnitudes of the vorticity field.

50

Page 67: On the simulation of fluids for computer graphics - IMPA

Figure 4.2: A more complex flow example; Top left: scalar field ad-vected/diffused along the velocity field depicted in top right figure; Middle:magnitudes of the velocity field; Bottom: magnitudes of the vorticity field.

51

Page 68: On the simulation of fluids for computer graphics - IMPA

Figure 4.3: In viscous flows governed by the Navier-Stokes’ equations, vor-ticity is generated along boundaries. Left: a viscous flow animated using theNavier-Stokes’ equations and its respective vorticity field. Right: an inviscidflow governed by Euler’s equations (where vorticity slips along boundaries).

52

Page 69: On the simulation of fluids for computer graphics - IMPA

4.2 Smoothed Particle Hydrodynamics

This section is devoted to describe the Smoothed Particle Hydrodynamics(SPH) methodology to simulate fluid flows. Our presentation is roughlybased on the works of Muller et al. [MCG03], which employed it in the simu-lation of fluids for interactive graphics applications, and Paiva Neto [Net07],who extended SPH in his Ph.D. thesis to simulate non-Newtonian viscoplas-tic and multiphase flows also for computer graphics applications.12

As before, our focus is on clarity and simplicity of presentation. Althoughour considerations are restricted to a simple flow regime, at the end of thischapter we provide further references to works concerned with deeper descrip-tions of the SPH framework and its implementation issues, both for computergraphics and its “more serious” original applications [GM77, Luc77].

4.2.1 Flow regime and governing equations

Our description of the smoothed particle hydrodynamics method for flowsimulation is based on a regime where the fluid has uniform viscosity andthe pressure obeys an equation of state of the type p (x, t) = f (ρ (x, t)).Under these assumptions, the governing equations for such a fluid flow are:13

continuity equation:Dρ

Dt= −ρ (∇ · u)

momentum equation: ρDu

Dt= −∇p + (λ + µ)∇ (∇ · u) + µ∆u + ρb

The Lagrangian formulation used to state the governing equations is dueto the discretization strategy adopted by SPH (to be explained later), whichalso makes use of the identity a = Du

Dt(where a stands for acceleration).

As noted in the previous chapter, the explicit use of an equation of statedoesn’t imply the incompressibility condition ∇ · u ≡ 0. Therefore, it isconceptually incorrect (at best) to adopt an equation of state and assume∇·u ≡ 0 to simplify the governing equations, even if this equation of state isdesigned to direct the system to a quasi-incompressible state. This was doneby Muller et al. in [MCG03], when they adopted ρ Du

Dt= −∇p + µ∆u + ρb

as their momentum equation and p = c2 (ρ− ρ0) as their equation of state.

12 Before [MCG03] used SPH to simulate liquids, the Smoothed Particle Hydrodynam-ics framework had been exploited by computer graphics both to depict fire and gaseousphenomena [SF95] and to animate the soft deformations of elastic solids [DG96].

13 Already derived in the previous chapter.

53

Page 70: On the simulation of fluids for computer graphics - IMPA

4.2.2 Field representation and fluid discretization

Instead of representing the field quantities by regularly sampled values andtheir differentials by difference equations (as done in stable fluids), SPH re-lies on scattered data approximation schemes and analytical differentiationof its approximations. This is accomplished by exploting the integral repre-sentation of a function f : Ω ⊆ Rn → R as a convolution with Dirac’s deltadistribution δ and that this distribution can be defined as a generalized limitof certain smooth functions Wh, i.e., h→ 0⇒ Wh → δ [Net07, II01]:

f (x) =

∫Ω

f (x′) δ (x− x′)dx′ = limh→0

∫Ω

f (x′) Wh (x− x′)dx′

(4.2)

Motivated by 4.2, the SPH approximation 〈f〉 to the field f is defined bya given family Wh of smooth kernel functions and a fixed h > 0 as

〈f (x)〉 :=

∫Ω

f (x′) Wh (x− x′)dx′ (4.3)

which is numerically discretized by the quadrature formula:

〈f (x)〉 ≈∑

j

f (xj) Wh (x− xj)∆Vj =∑

j

fjmj

ρj

Wh (x− xj) (4.4)

where the weight ∆Vj =mj

ρjcorresponds to the volume associated to the j-th

fluid particle (located at the quadrature point xj ∈ Ω), mj to its mass and ρj

to its associated specific mass(notice that fj is an abbreviation to f (xj)

).

This quadrature form for the integral SPH approximation is interpreted asdiscretizing the fluid mass into a finite number of particles which evolveaccording to the governing equations, that describe the system dynamics bya coupled set of nonlinear ODE’s (a topic treated in the next subsection).

Inspecting 4.4, we notice that whenever the family Wh is composed bycompactly supported kernels, with influence radius say κh,

(i.e., ∃κ > 0 such

that ‖x−xj‖ ≥ κh⇒ Wh (x− xj) = 0)

the sum in 4.4 effectively only takesplace for those particles which are less than κh away from x. Defining theneighboring particles of a point x ∈ W asN (x) := j ∈ N | ‖x− xj‖ < κh ,we can rewrite the discrete SPH approximation 4.4 as [Net07]:

〈f (x)〉 ≈∑

j

fjmj

ρj

Wh (x− xj) =∑

j∈N (x)

fjmj

ρj

Wh (x− xj) (4.5)

54

Page 71: On the simulation of fluids for computer graphics - IMPA

To simplify notation, we adopt 〈f (x)〉 to represent the discrete SPH approx-imation in 4.5, since we won’t use its integral form in this text anymore.

The compact support property is just one of a few useful (hence desired)properties for choosing the family of smooth kernels Wh : Rn → R, 14

• Even: ∀h > 0 ∀x ∈ Rn, Wh (x) = Wh (−x)

• Non-negative: ∀h > 0 ∀x ∈ Rn, Wh (x) ≥ 0

• Smooth: ∀h > 0, Wh ∈ Ck (Rn), where k > 1

• Partition of unity: ∀h > 0,∫

ΩWh (x) dx = 1

• Compact support: ∃κ > 0, ∀x ∈ Rn, ‖x− xj‖ ≥ κh⇒ Wh (x) = 0

• Convergence: h→ 0 =⇒ Wh → δ

An important class of radial compactly supported piecewise-smooth ker-nels can be derived from splines functions, examples of those are the cubicand quintic splines defined by [Mon05, Net07]:

Wh (x) =αn

hnw3

(‖x‖h

)and Wh (x) =

βn

hnw5

(‖x‖h

)where α1 = 1

6, α2 = 15

14π, α3 = 1

4π, β1 = 120, β2 = 7

478π, β3 = 3

359πand

w3 (q) =

(2− q)3 − 4(1− q)3, for 0 ≤ q ≤ 1

(2− q)3, for 1 ≤ q ≤ 2

0, for q > 2

w5 (q) =

(3− q)5 − 6(2− q)5 + 15(1− q)5, for 0 ≤ q ≤ 1

(3− q)5 − 6(2− q)5, for 1 ≤ q ≤ 2

(3− q)5, for 2 ≤ q ≤ 3

0, for q > 3

Although the Gaussian is the most common kernel, it doesn’t have com-pact support (even thought it has a very fast decay), not a good propertyfor computational implementations. Nevertheless, for its simplicity (which is

14 Notice that some of these properties are necessary to allow the manipulations thatlead to the integral SPH approximation [II01].

55

Page 72: On the simulation of fluids for computer graphics - IMPA

a key goal of our presentation), we employ the 2D Gaussian function in oursimple example implementation (Appendix B).

Provided an SPH approximation for a field quantity, spatial derivativescan be analytically computed from the discretized form:

∇〈f (x)〉 =∑

j∈N (x)

mj

ρj

fj∇Wh (x− xj)

∆ 〈f (x)〉 =∑

j∈N (x)

mj

ρj

fj∆Wh (x− xj)

∇ · 〈f (x)〉 =∑

j∈N (x)

mj

ρj

fj · ∇Wh (x− xj)

∇× 〈f (x)〉 =∑

j∈N (x)

mj

ρj

fj ×∇Wh (x− xj)

Even though these approximations to differentials of fields are natural, inpractice they suffer from a number of problems related both to accumulationof numerical errors and to bad representation of physical properties (e.g.,symmetry in Newton’s Third Law of motion). To overcome these problems,identities from calculus are exploited to both symmetrize and amortize nu-merical imprecisions. For example, better numerically conditioned rules canbe derived by subtracting from the above equations what should be a nullconstant

(e.g. ∇(1) or ∇× (1), approximated by ∇〈1〉 and 1 · ∇ 〈1〉

):

〈∇f (xi)〉 ≈ ∇(〈f (xi)〉 − fi 〈1〉

)=

∑j∈N (xi)

mj

ρj

(fj − fi)∇Wh (xi − xj)

〈∆f (xi)〉 ≈ ∆(〈f (xi)〉 − fi 〈1〉

)=

∑j∈N (xi)

mj

ρj

(fj − fi)∆Wh (xi − xj)

〈∇ · f (xi)〉 ≈ ∇ ·(〈f (xi)〉 − fi 〈1〉

)=

∑j∈N (xi)

mj

ρj

(fj − fi) · ∇Wh (xi − xj)

〈∇ × f (xi)〉 ≈ ∇ ×(〈f (xi)〉 − fi 〈1〉

)=

∑j∈N (xi)

mj

ρj

(fj − fi)×∇Wh (xi − xj)

Although these rules can be numerically more suitable for approximatingthe differential operators, they are not suitable to use in physical simula-tions, since they do not respect the Third Law of motion (what can be veri-fied by analyzing just the interaction of two particles with different masses).

56

Page 73: On the simulation of fluids for computer graphics - IMPA

Symmetric approximations which work fairly well in practice [Net07] can bederived by considering the following identity:

1

g∇f =

f

gk∇(

1

g1−k

)+

1

g2−k∇(

f

gk−1

), where k ∈ Z (4.6)

By means of identity 4.6, we can establish for 1ρ∇f [Net07]:⟨

∇f

ρ(xi)

⟩=

∑j∈N (xi)

mj

(fj

ρ2−ki ρk

j

− fi

ρki ρ

2−kj

)∇Wh (xi − xj)

which give rise to symmetric approximations as, by taking k = 1:

〈∇f (xi)〉 ≈∑

j∈N (xi)

mj

ρj

(fj + fi)∇Wh (xi − xj)

〈∇ · f (xi)〉 ≈∑

j∈N (xi)

mj

ρj

(fj + fi) · ∇Wh (xi − xj)

and, by taking k = 2:⟨∇f

ρ(xi)

⟩≈

∑j∈N (xi)

mj

(fj

ρ2j

+fi

ρ2i

)∇Wh (xi − xj)⟨

∇ · fρ

(xi)

⟩≈

∑j∈N (xi)

mj

(fjρ2

j

+fiρ2

i

)· ∇Wh (xi − xj)

After deriving a systematic strategy to discretely represent field quan-tities and their differentials, we have enough material to numerically solvethe governing equations. However, a note on how to deal with boundariesis appropriate at this point. The classical approach to boundary conditionsin SPH is to approximate the solid surface by a sample of boundary parti-cles (or ghost particles) and, to each fluid particle which is within the radiusof influence of some boundary particle, to apply a compactly supported re-pulsive force (as those derived from a Lennard–Jones potentials, common incomputer graphics and molecular dynamics [BMF07]). Such a force (per unitmass) is of the form [Mon94]:

1

mi

f (rib) =

D((

r0

rib

)p1

−(

r0

rib

)p2)

rib

r2ib, for rib ≤ r0

0, for rib > r0

57

Page 74: On the simulation of fluids for computer graphics - IMPA

where D is a problem dependent constant (of the same order of the maximumexpected speed squared), p1 > p2 are constants (usually (p1, p2) = (4, 2) or(p1, p2) = (12, 6)), rib = xi − xb and rib = ‖xi − xb‖.

This provides a physically-inspired approach to deal with stationary solidwalls. However, when these obstacles have complex geometries and (possibly)move, different approaches should be used [MFZ97, Mon05, Net07].15

4.2.3 The discretized governing equations

The approach employed by SPH to discretize the governing equations is basedon the Lagrangian formulation of the governing equations of fluid flow. Al-though [MCG03] depart from the equations mentioned above, we adopt thedifferential form of the momentum equation 3.3 as derived in section 3.4,along with the tensor field deduced in section 3.6, namely:

ρDu

Dt= Div T + ρb, where T = −pI + σ and σ = λ tr (D) I + 2µD

recalling D = 12

(∇u +∇uT

), we have the following set of equations:

Du

Dt= −1

ρ∇p +

1

ρDiv σ + b, with σ = λ tr (D) I + 2µD

Since we have discretized the fluid mass into a finite number of fluid par-ticles, the dynamics of this particle system is dictated by how each particle’sposition, velocity and density vary in time. Hence, the behaviour of oursystem is described by how dx

dt, Dρ

Dtand Du

Dtare determined for each particle

along this particle’s trajectory x (t). Thus, for particle i, we have:16

dxi

dt= ui pi = f (ρi)

dρi

dt= −ρi 〈∇ · ui〉 Di =

1

2

(〈∇ui〉+ 〈∇ui〉T

)dui

dt= −

⟨1

ρi

∇pi

⟩+

⟨1

ρi

Div σi

⟩+ 〈bi〉 σi = λ tr (Di) I + 2µDi

15 Although our simple solver implements a flow regime in which there are only station-ary walls, the boundaries were enforced geometrically using a simple particle-wall collisionresponse model similar to that presented in [Net07].

16 Notice the change of notation from DDt to d

dt , since we are talking about the rates ofchange of a particle’s properties instead of derivatives of field quantities along trajectories.

58

Page 75: On the simulation of fluids for computer graphics - IMPA

where each spatial derivative is approximated by the symmetric rules wederived before (to ensure conformance with Newton’s Third Law). Now, wepresent discretizations for each of the terms in the above equations.

The continuity equation

Since the equation of continuity is an expression which enforces the law ofconservation of mass, we have the possibility of simply ignore it, in view ofthe explicit conservation of the total mass in our particle system [MCG03].In this case, the particles densities are computed at each time-step throughthe SPH approximation (derived by considering ρ as an ordinary scalar field):

ρi := 〈ρ (xi)〉 =∑

j∈N (xi)

mjWh (xi − xj)

Altought our implementation makes use of this expression for simplicity,some authors prefer to directly discretize the continuity equation to reuse cer-tain computations and to not oversmooth the density field [Mon92, Mon94].In this case, the discretization recommended is given by [Mon05, Net07]:

dρi

dt= −ρi 〈∇ · ui〉 = −ρi

∑j∈N (xi)

mj

ρj

(uj − ui) · ∇Wh (xi − xj)

The momentum equation

The discretization of the momentum equation is performed on each term.

Pressure term. To compute a discretization for the pressure term, wemake use of the symmetric rules derived in the later section:⟨

1

ρi

∇pi

⟩=

∑j∈N (xi)

mj

(pj

ρ2j

+pi

ρ2i

)∇Wh (xi − xj)

where the pressures pk are given by the chosen equation of state f (ρk).

59

Page 76: On the simulation of fluids for computer graphics - IMPA

Viscous term. The viscous term requires the computation of the defor-mation tensor Di, which is given by the numerically better rule:

〈∇ui〉 =∑

j∈N (xi)

mj

ρj

(uj − ui)⊗∇Wh (xi − xj)

Di =1

2

(〈∇ui〉+ 〈∇ui〉T

), where v ⊗w = vwT .

With the deformation tensor calculated, the viscous term in computed bya rule from the same family used in the pressure term (adapted to tensors):⟨

1

ρi

Div σi

⟩=

∑j∈N (xi)

mj

ρjρi

(σj + σi)∇Wh (xi − xj)

where σk = λ tr (Dk) I + 2µDk as before. Notice that more general expres-sions for the viscous stress tensor σ could be adopted with this scheme andthat no second-order derivatives are required. This approximation was used,with another σ, to simulate non-Newtonian flows in [PPLT06] and [Net07].

Body forces. The forcing term in the momentum equation accounts forexternal body forces and, in an SPH implementation adopting repulsive ghostparticles, the repulsive boundary forces as defined above. To compute bi, thediscrete SPH approximation scheme can be applied directly, resulting in:

〈bi〉 =∑

j∈N (xi)

mj

ρj

bjWh (xi − xj)

This allows a force applied on a particle to spread to others inside its support.

Time-stepping

After discretizing the governing equations by SPH approximations, a coupledsystem of nonlinear ordinary differential equations result. The numericalintegration of this system can be performed by employing any standard time-stepper designed for ODE’s [PTVF92, SB02, Ise96, AP98, LeV07].

In our implementation, we employed a simple explicit symplectic Eulermethod [SD06, KYT+06]. The integration rule of this method is very similarto the classical forward Euler scheme, applied to the ODE, x = f (x):

60

Page 77: On the simulation of fluids for computer graphics - IMPA

forward Euler scheme: symplectic Euler scheme:

vn+1 = vn + kf (xn) vn+1 = vn + kf (xn)xn+1 = xn + kvn xn+1 = xn + kvn+1

where x = f (x) was transformed to the first-order ODE,

(xv

)=

(v

f (x)

).

A note is required regarding the choice of the time step k. In an im-plementation of SPH with more than didatic goals, the integration of thediscretized governing equations by an explicit method during a time k is per-formed by a sequence of iterations with smaller time steps in such a way toguarantee that the simulation doesn’t blow up. This means that, after eachsubstep, a new time step k is chosen in such a manner that some stabilitycondition is satisfied (e.g., the Courant–Friedrichs–Lewy (CFL) condition forPDE’s [CFL67]). The form in which these conditions restrict the time stepused in each substep is dependent of the discretization performed. Stabilityconditions for discretizations similar to ours can be found in [MFZ97, Net07].Since we don’t choose our substeps by a stability condition in our implemen-tation, our time step k has to be hand-tuned for every simulation performed.

4.2.4 Experiments

As an illustration for our description of a simple Smoothed Particle Hydrody-namics scheme, we implemented a simple fluid simulator in the C language forthe governing equations as described in 4.2.1. In this subsection, we presentsome results generated with that solver and some issues which appeared dur-ing its development. Appendix B presents the core code of our simple SPHsolver as a more concrete example of the method described.

A simple breaking dam. Figure 4.4 presents six frames from a simpletwo-dimensional breaking dam animation. The fluid is confined inside asquare bounded domain, in which a vertical wall is fixed at the middle of theceiling in this chamber going down to 1

8of the chamber’s height above its

floor. The simulation is then initialized with half the left-side of the chamberfilled with a fluid under the action of gravity. Those frames were capturedlittle after the simulation began and are spaced roughly regularly in time(they are intended just to illustrate the resulting animation).

61

Page 78: On the simulation of fluids for computer graphics - IMPA

Figure 4.4: Frames from an animation of a breaking dam (1024 particles).

62

Page 79: On the simulation of fluids for computer graphics - IMPA

To avoid excessive compression and blow up of the simulation, we neededto take very small time steps. Combined with the fact that we did not use anydata structure to accelerate neighbor queries, the simulation ran annoyinglyslowly, at least compared to our simple Stable Fluids implementation, evenusing just 1024 fluid particles.

Implementation issues. As before, we experienced some problems indealing with boundaries. We first implemented the ghost particle approachoutlined in 4.2.2 but they introduced too much stiffness in the resultingODE’s, which required time steps prohibitively small for interactive simu-lation and avoiding blow up. For this reason, we changed paradigm andemployed a collision response scheme similar to those used in rigid body an-imations [Net07]. This change allowed us to take time steps large enoughto keep interactivity without blow up. Improvements in stability can bemade using particle-dependent time steps by “freezing” the acceleration fieldduring the time step and evolving each particle independently using the inter-polated accelerations. Such an approach is adaptive both in time and spaceand improvements are reported in the simulation time complexity [HK89].

4.3 Comments and Further Reading

In this chapter, we presented the two most basic and commonly used meth-ods to simulate the governing equations of fluid flows in computer graphics.Although they already produce very nice (and physically-plausible) results,many other methods and extensions have been developed to overcome prob-lems and limitations encountered in their basic formulation.

Stable Fluids and variants. The stable fluids method was introduced byStam [Sta99] as an alternative to the work of Foster and Metaxas [FM96a]better suited to computer graphics, because of the stringent restrictions onthe time step imposed by the techniques they used to numerically solvethe Navier-Stokes equations, which was strongly based on the seminal workof Harlow and Welch [HW65], that introduced both the Marker And Cellmethod and the use of a staggered grid to represent the velocity field. After[Sta99], some works proposed modifications to the basic stable fluids schemein order to reduce effects of vortical diffusion [FSJ01, SRF05], mass dissipa-tion in liquid simulation [FF01, EMF02] and to speed-up pressure projection

63

Page 80: On the simulation of fluids for computer graphics - IMPA

[LGF04]. Other works proposed extensions to the basic approach (and toother extensions) to be able to animate fire [NFJ02, RNGF03], highly vis-cous and viscoelastic fluids [CMIT02, GBO04], flows on surfaces [Sta03],coupling of fluids and solids [CMT04, GSLF05, CGFO06, BBB07], hybrid,deforming and dynamic meshes [FOK05, FOKG05, KFCO06] and GPU im-plementations [Har04, CLT07, Bor06] (just to name a few).

Smoothed Particle Hydrodynamics and variants. SPH was proposedindependently by Gingold and Monaghan [GM77] and Lucy [Luc77] in 1977with the purpose of simulating stellar flows in astronomy and astrophysics.Since then, much work has been done in improving the method both for itsoriginal applications in astrophysics and to other fields [Mon92, Mon05]. Incomputer graphics, it was introduced by Stam to depict gaseous phenomena[SF95] and used later by Desbrun and Cani to simulate deformable solids[DG96]. However, it was just after the work of Muller et al. [MCG03] oninteractive simulation of liquids that SPH has caught widespread attentionfrom the computer graphics community. Since its introduction, many authorshave been exploting the SPH methodology to animate systems as complex as:weakly compressible fluids [BT07], non-Newtonian fluids [PPLT06, Net07],bubbling and frothing [CPPK07], coupling of solids and fluids [KAG+05],adaptive fluids [APKG07], fluids in GPU’s [Nak07], elastic, plastic and melt-ing objects [MKN+04] and even hair [HMT01, BCN03].

Other methods. The computational fluid dynamics community is veryprolific, this may be a reason for the many different techniques recently in-troduced into the computer animation community to simulate fluid flows,a few of them are [SCC04, SCC05, ZB05, ETK+07, WBOL07, BWHT07,GN07, GLG95, PK05, CACC06, AN05, ANSN06].

64

Page 81: On the simulation of fluids for computer graphics - IMPA

Chapter 5

Final Remarks

After an overview of the fundamentals of mathematical fluid dynamics em-ployed in the simulation of fluid flows for computer graphics, and the basicmethods used by the CG community, we have provided some of the foun-dations needed by the interested (and mathematically educated) reader topursue a more in-depth understanding of the techniques which have been pub-lished in the computer animation literature regarding the animation of fluidmotion. As a complement to this introductory text, we provided some guid-ance for further reading of relevant references. In the following, we presentsome efforts which have been (and, in near future, are intended to be) made.

Work in Progress. Both our implementations of Stable Fluids and SPHare still very basic. Currently, we are working on an extension of these solversto handle moving boundaries (internal and external) [CMT04], high-viscosityand non-Newtonian fluids [CMIT02, PPLT06], liquids (using particle level-sets in stable fluids and contouring in rendering SPH simulations) [FF01,EMF02, LLVT03], and on optimizing the SPH code with data-structures forhierarchical range queries [HK89]. Since we are also interested in simula-ting deformable objects, we are currently studying the foundations of mathe-matical elasticity [MH94, Lov44, Pat87] and the recent works on discretedifferential geometry [Gri06], which have found interesting applications inthe simulation of fluids [ETK+07].

Future Work. In (a not so far) future, we intend to experiment with re-cently developed (and promising) techniques to animate fluids for computergraphics. These include the work of Elcott et al. [ETK+07], which applies the

65

Page 82: On the simulation of fluids for computer graphics - IMPA

tools of discrete differential geometry to stably simulate fluids avoiding the“correction” procedure that projects an intermediary vector field onto itsdivergence-free part; the dynamic/adaptive remeshing method of Klingneret al. [KFCO06] which conforms the mesh to fluid features attaining de-tailed simulations without over-subdividing the computational domain (andimpacting performance); the variational/Eulerian approach of Mullen et al.[MMTD07] to represent and advect field quantities; the hierarchical run-lenght encoded level-set structure of Houston et al. [HNB+06] to compactlyrepresent highly detailed level-sets; and the lattice Boltzmann method em-ployed by Thuerey [Thu07] in the simulation of fluid motion by means ofcellular automata.

Some Ideas and more Future Work. During the preparation of thistext, some ideas have shown up as interesting avenues for future research.We believe that proposition 1 — describing the local behaviour of the fluidflow — might be exploited to design some criteria for adaptive subdivisiondynamic Eulerian simulations [KFCO06], adaptively sampled particle-basedsimulations [APKG07], and anisotropic rendering of the free-surface in li-quid/fire animations [AA06] (possibly avoiding the blobby artifacts commonwhen using few particles). Another possibility regards the design of veloc-ity/vector fields [AN05, ANSN06] as a “cheap” alternative to a full simulationof the Navier-Stokes equations. Maybe an intuitive modeling metaphor canbe provided by exploiting the concepts involved in the definitions of vortexlines/sheets/tubes and in theorem 4 (Helmholtz’s Theorem). Recently, amodel-reduced simulation method has been introduced to computer graphicsfor real-time fluid simulation [TLP06], we believe this technique (or a sim-ilar one using machine learning algorithms other than principal componentanalysis) could be exploited to perform faster optimization-based fluid con-trol methods [TMPS03, MTPS04]. Another intesting possibility, would be toevaluate the feasibility of employing domain decomposition methods (spatialsplitting methods) [Bor07] to parallelize computations, both in distributedsystems and GPU’s. At last, further study of the variational principles un-derlying fluid motions might be used to perform numerical simulations whichbetter preserve invariants of flows (e.g., kinetic energy in unforced ideal flu-ids), some recent works have benefited from an understanding of such varia-tional principles [BBB07, KYT+06] and we think these properties could bemore exploited in the design of better solvers [LR04].

66

Page 83: On the simulation of fluids for computer graphics - IMPA

Appendix A

A Simple Stable Fluids Solver

In this appendix, we present our implementation in C of the basic StableFluids scheme as described in [Sta99]. This code also contains a simpleimplementation of the vorticity confinement forces as introduced in [FSJ01].We stress that this code is neither optimized for performance nor memoryconsumption, it was written for didatic reasons (i.e., designed to be almostreadable).

#include <math.h>#include <string.h>

#define INDEX(i,j) ((i)+((j)*(N+2)))#define FOR_EACH_CELL for(i=1;i<=N;++i)for(j=1;j<=N;++j)#define END_FOR_EACH #define MAX_ITERATIONS 25#define CLAMP(x,m,M) (((x)<(m))?(m):(((x)>(M))?(M):(x)))#define EPSILON (1e-12)

typedef enum boundary_e DIRICHLET,NEUMANN

boundary_t;

typedef enum boolean_e FALSE = 0,TRUE = (!0)

boolean_t;

67

Page 84: On the simulation of fluids for computer graphics - IMPA

void setBoundaryCondition( boundary_t bx, boundary_t by,unsigned int N, float* f )

register unsigned int i;

for ( i = 1 ; i <= N ; ++i ) f[INDEX( 0, i)]=((bx==DIRICHLET)?-f[INDEX(1,i)]:f[INDEX(1,i)]);f[INDEX(N+1, i)]=((bx==DIRICHLET)?-f[INDEX(N,i)]:f[INDEX(N,i)]);f[INDEX( i, 0)]=((by==DIRICHLET)?-f[INDEX(i,1)]:f[INDEX(i,1)]);f[INDEX( i,N+1)]=((by==DIRICHLET)?-f[INDEX(i,N)]:f[INDEX(i,N)]);

f[INDEX( 0, 0)] = 0.5f * (f[INDEX( 0,1)] + f[INDEX(1, 0)]);f[INDEX(N+1, 0)] = 0.5f * (f[INDEX(N+1,1)] + f[INDEX(N, 0)]);f[INDEX( 0,N+1)] = 0.5f * (f[INDEX( 0,N)] + f[INDEX(1,N+1)]);f[INDEX(N+1,N+1)] = 0.5f * (f[INDEX(N+1,N)] + f[INDEX(N,N+1)]);

/** Solves (\alpha I - \beta\Delta)u = f on the unit square,* with boundary conditions ’b’ using the Gauss-Seidel iteration*/void solve( boundary_t bx, boundary_t by, float alpha, float beta,

unsigned int N, float* f, float* u ) register unsigned int i, j, k;float n = beta * N * N;float d = alpha + 4.0f * n;float left, right, down, up;

for ( k = 0 ; k < MAX_ITERATIONS ; ++k ) FOR_EACH_CELLleft = u[INDEX(i-1, j)];right = u[INDEX(i+1, j)];down = u[INDEX( i,j-1)];up = u[INDEX( i,j+1)];u[INDEX(i,j)] = (f[INDEX(i,j)]+n*(left+right+down+up))/d;

END_FOR_EACH

setBoundaryCondition( bx, by, N, u );

68

Page 85: On the simulation of fluids for computer graphics - IMPA

void advect( boolean_t advectAndForce, boundary_t bx, boundary_t by,float dt, unsigned int N, float* u, float* v, float* f0, float* f )

register unsigned int i, j;float x0, y0, x, y, xi, yj, fxi, fyj, cxi, cyj, h = 1.0f/N;float s, t, ld, rd, lu, ru, c;

FOR_EACH_CELLx0 = (i - 0.5f) * h;y0 = (j - 0.5f) * h;

x = x0 - dt * u[INDEX(i,j)];y = y0 - dt * v[INDEX(i,j)];

x = CLAMP(x,0.0f,1.0f);y = CLAMP(y,0.0f,1.0f);

xi = x * N + 0.5f;yj = y * N + 0.5f;

fxi = floor(xi);cxi = ceil(xi);

if ( fxi != cxi ) s = (xi - fxi) / (cxi - fxi);

else s = 0.0f;

fyj = floor(yj);cyj = ceil(yj);

if ( fyj != cyj ) t = (yj - fyj) / (cyj - fyj);

else t = 0.0f;

ld = f0[INDEX((int)fxi,(int)fyj)];rd = f0[INDEX((int)cxi,(int)fyj)];lu = f0[INDEX((int)fxi,(int)cyj)];ru = f0[INDEX((int)cxi,(int)cyj)];

c = ((1.0f-t)*((1.0f-s)*ld+s*rd)+t*((1.0f-s)*lu+s*ru));

69

Page 86: On the simulation of fluids for computer graphics - IMPA

if ( advectAndForce == TRUE ) f[INDEX(i,j)] *= dt;f[INDEX(i,j)] += c ;

else f[INDEX(i,j)] = c;

END_FOR_EACH

setBoundaryCondition( bx, by, N, f );

void force( boundary_t bx, boundary_t by, float dt,unsigned int N, float* f, float* u )

register unsigned int i, j;

FOR_EACH_CELLu[INDEX(i,j)] += dt * f[INDEX(i,j)];

END_FOR_EACH

setBoundaryCondition( bx, by, N, u );

void confineVorticity ( boundary_t ubx, boundary_t uby,boundary_t vbx, boundary_t vby, float dt, float epsilon,unsigned int N, float* u, float* v,float* hOmega, float* hAbsOmega )

if ( epsilon < EPSILON ) return;

register unsigned int i, j;float left, right, down, up;float dx, dy, norm, alpha = dt * epsilon;

FOR_EACH_CELLleft = v[INDEX(i-1, j)];right = v[INDEX(i+1, j)];down = u[INDEX( i,j-1)];up = u[INDEX( i,j+1)];hOmega[INDEX(i,j)] = ( right - left ) - ( up - down );hAbsOmega[INDEX(i,j)] = (float) fabs( hOmega[INDEX(i,j)] );

END_FOR_EACH

70

Page 87: On the simulation of fluids for computer graphics - IMPA

setBoundaryCondition( NEUMANN, NEUMANN, N, hOmega );setBoundaryCondition( NEUMANN, NEUMANN, N, hAbsOmega );

FOR_EACH_CELLleft = hAbsOmega[INDEX(i-1, j)];right = hAbsOmega[INDEX(i+1, j)];down = hAbsOmega[INDEX( i,j-1)];up = hAbsOmega[INDEX( i,j+1)];dx = right - left;dy = up - down;norm = sqrt( dx * dx + dy * dy );

if ( norm > EPSILON ) u[INDEX(i,j)] += alpha * hOmega[INDEX(i,j)] * dy / norm;v[INDEX(i,j)] += alpha * hOmega[INDEX(i,j)] * (-dx) / norm;

END_FOR_EACH

setBoundaryCondition( ubx, uby, N, u );setBoundaryCondition( vbx, vby, N, v );

void diffuse( boundary_t bx, boundary_t by, float nu, float dt,unsigned int N, float* u0, float* u )

solve( bx, by, 1.0f, nu * dt, N, u0, u );

/** Solve -\Delta\phi = \nabla\cdot U, using Neumann boundary conditions* for \phi, and assigns U <- U + \nabla\phi (U <- IP(U))*/

void project( unsigned int N, float* u, float* v, float* divU, float* phi ) register unsigned int i, j;float n = 0.5f * N;float left, right, down, up;

FOR_EACH_CELLleft = u[INDEX(i-1, j)];right = u[INDEX(i+1, j)];down = v[INDEX( i,j-1)];up = v[INDEX( i,j+1)];divU[INDEX(i,j)] = n * ( ( right - left ) + ( up - down ) );phi[INDEX(i,j)] = 0.0f;

71

Page 88: On the simulation of fluids for computer graphics - IMPA

END_FOR_EACH

setBoundaryCondition( NEUMANN, NEUMANN, N, divU );setBoundaryCondition( NEUMANN, NEUMANN, N, phi );

solve( NEUMANN, NEUMANN, 0.0f, 1.0f, N, divU, phi );

FOR_EACH_CELLleft = phi[INDEX(i-1, j)];right = phi[INDEX(i+1, j)];down = phi[INDEX( i,j-1)];up = phi[INDEX( i,j+1)];u[INDEX(i,j)] += n * ( right - left );v[INDEX(i,j)] += n * ( up - down );

END_FOR_EACH

setBoundaryCondition( DIRICHLET, NEUMANN, N, u );setBoundaryCondition( NEUMANN, DIRICHLET, N, v );

void stepNavierStokes( float dt, float nu, float epsilon,unsigned int N, float* bx, float* by, float* u, float* v )

/** Advect -> Force -> Diffuse -> Project*/advect( TRUE, DIRICHLET, DIRICHLET, dt, N, u, v, u, bx );advect( TRUE, DIRICHLET, DIRICHLET, dt, N, u, v, v, by );confineVorticity( DIRICHLET, DIRICHLET, DIRICHLET, DIRICHLET,

dt, epsilon, N, bx, by, u, v );diffuse( DIRICHLET, DIRICHLET, nu, dt, N, bx, u );diffuse( DIRICHLET, DIRICHLET, nu, dt, N, by, v );project( N, u, v, bx, by );setBoundaryCondition( DIRICHLET, DIRICHLET, N, u );setBoundaryCondition( DIRICHLET, DIRICHLET, N, v );

void stepScalarField( float dt, float kappa, unsigned int N,float* u, float* v, float* f, float* rho )

/** Force -> Advect -> Diffuse*/force( NEUMANN, NEUMANN, dt, N, f, rho );advect( FALSE, NEUMANN, NEUMANN, dt, N, u, v, rho, f );diffuse( NEUMANN, NEUMANN, kappa, dt, N, f, rho );

72

Page 89: On the simulation of fluids for computer graphics - IMPA

void stepEuler( float dt, float epsilon, unsigned int N,float* bx, float* by, float* u, float* v )

/** Advect -> Force -> Project*/advect( TRUE, DIRICHLET, NEUMANN, dt, N, u, v, u, bx );advect( TRUE, NEUMANN, DIRICHLET, dt, N, u, v, v, by );confineVorticity( DIRICHLET, NEUMANN, NEUMANN, DIRICHLET,

dt, epsilon, N, bx, by, u, v );project( N, bx, by, u, v );memcpy( u, bx, (N + 2) * (N + 2) * sizeof(float) );memcpy( v, by, (N + 2) * (N + 2) * sizeof(float) );

“I think that the most important result of the computer graphics revolutionis that it has helped heal the gulf between art and science.”

Jim Blinn

73

Page 90: On the simulation of fluids for computer graphics - IMPA

74

Page 91: On the simulation of fluids for computer graphics - IMPA

Appendix B

A Simple Smoothed ParticleHydrodynamics Solver

In this appendix, we present our implementation in C of a simple SPHscheme as outlined in section 4.2. We stress that this code is neither op-timized for performance nor memory consumption, like our Stable Fluidssolver, it was written for the purpose of illustrating our considerations inchapter 4.

#include <math.h>#include <string.h>

#define FOR_EACH_PARTICLE for(i=0;i<N;++i)#define END_FOR_EACH_PARTICLE

#define FOR_EACH_PAIR for(i=0;i<(N-1);++i)for(j=i+1;j<N;++j)#define END_FOR_EACH_PAIR

float W(float h, float dx, float dy) static const float r2pi = 0.15915494309189535f;float rh2 = 1.0f / ( h * h );return r2pi * rh2 * exp( - 0.5f * rh2 * ( dx * dx + dy * dy ) );

void gradW(float h, float dx, float dy, float* gradWx, float* gradWy) float scale = - W(h, dx, dy) / ( h * h );*gradWx = scale * dx;*gradWy = scale * dy;

75

Page 92: On the simulation of fluids for computer graphics - IMPA

void wGradW(float h, float dx, float dy,float* w, float* gradWx, float* gradWy)

*w = W(h, dx, dy);float scale = - (*w) / ( h * h );*gradWx = scale * dx;*gradWy = scale * dy;

void computeDensities( float h, float m, unsigned int N,float* x, float* y, float* rho )

register unsigned int i, j;float Wh = W(h, 0.0f, 0.0f);

FOR_EACH_PARTICLErho[i] = Wh;

END_FOR_EACH_PARTICLE

FOR_EACH_PAIRWh = W(h, x[i]-x[j], y[i]-y[j]);rho[i] += Wh;rho[j] += Wh;

END_FOR_EACH_PAIR

FOR_EACH_PARTICLErho[i] *= m;

END_FOR_EACH_PARTICLE

void computeStressTensors( float h, float m, float lambda, float mu,unsigned int N, float* rho, float* x, float* y, float* u, float* v,float* s11, float* s12, float* s22 )

register unsigned int i, j;float twomu = mu+mu, gradWx, gradWy, du, dv;float d11, twod12, d22, lambdaTrD;float s11rho, s12rho, s22rho, rrho;

memset(s11, 0, N * sizeof(float));memset(s12, 0, N * sizeof(float));memset(s22, 0, N * sizeof(float));

FOR_EACH_PAIRgradW(h, x[i]-x[j], y[i]-y[j], &gradWx, &gradWy);

du = u[j]-u[i];

76

Page 93: On the simulation of fluids for computer graphics - IMPA

dv = v[j]-v[i];

d11 = du * gradWx;twod12 = du * gradWy + dv * gradWx;d22 = dv * gradWy;lambdaTrD = lambda * ( d11 + d22 );

s11rho = lambdaTrD + twomu * d11 ;s12rho = mu * twod12;s22rho = lambdaTrD + twomu * d22 ;

rrho = 1.0f / rho[j];s11[i] += s11rho * rrho;s12[i] += s12rho * rrho;s22[i] += s22rho * rrho;

rrho = 1.0f / rho[i];s11[j] += s11rho * rrho;s12[j] += s12rho * rrho;s22[j] += s22rho * rrho;

END_FOR_EACH_PAIR

FOR_EACH_PARTICLEs11[i] *= m;s12[i] *= m;s22[i] *= m;

END_FOR_EACH_PARTICLE

void addAccelerations( float h, float m, float B, float n, float rho0,unsigned int N, float* rho, float* x, float* y,float* s11, float* s12, float* s22, float* f, float* g )

register unsigned int i, j;float Wh, gradWx, gradWy, rrhoi, rrhoj, pi, pj, scale, a, b;

FOR_EACH_PAIRwGradW(h, x[i]-x[j], y[i]-y[j], &Wh, &gradWx, &gradWy);

rrhoi = 1.0f / rho[i];rrhoj = 1.0f / rho[j];

/* Equation of state */pi = (1.0f+B)*pow(rho[i]/rho0,n)-B;pj = (1.0f+B)*pow(rho[j]/rho0,n)-B;

77

Page 94: On the simulation of fluids for computer graphics - IMPA

scale = m * ( pi * rrhoi * rrhoi + pj * rrhoj * rrhoj );

a = - scale * gradWx;b = - scale * gradWy;

f[i] += a; f[j] += -a;g[i] += b; g[j] += -b;

scale = m * rrhoi * rrhoj;a = scale * ((s11[i]+s11[j])*gradWx + (s12[i]+s12[j])*gradWy);b = scale * ((s12[i]+s12[j])*gradWx + (s22[i]+s22[j])*gradWy);

f[i] += a; f[j] += -a;g[i] += b; g[j] += -b;

END_FOR_EACH_PAIR

void enforceBoundaryConditions( float dt, float epsilon, float h,float* x, float* y, float* u, float* v )

float x0 = (*x) - dt * (*u);float y0 = (*y) - dt * (*v);float gap = 0.75f * h;

if ( (*x) < 0.0f+gap ) *x = 0.0f+gap;*u = -epsilon * ((*x) - x0) / dt;

if ( 1.0f-gap < (*x) ) *x = 1.0f-gap;*u = -epsilon * ((*x) - x0) / dt;

if ( (*y) < 0.0f+gap ) *y = 0.0f+gap;*v = -epsilon * epsilon * ((*y) - y0) / dt;

if ( 1.0f-gap < (*y) ) *y = 1.0f-gap;*v = -epsilon * epsilon * ((*y) - y0) / dt;

78

Page 95: On the simulation of fluids for computer graphics - IMPA

if ( x0 <= 0.5f && 0.5f < *x+gap && 0.125f < y0+gap ) *x = 0.5f-gap;*u = -epsilon * ((*x) - x0) / dt;

else if ( 0.5f <= x0 && *x-gap < 0.5f && 0.125f < y0+gap ) *x = 0.5f+gap;*u = -epsilon * ((*x) - x0) / dt;

void step( float dt, float h, float m, float lambda, float mu, float epsilon,float B, float n, float rho0, unsigned int N, float* rho,float* x, float* y, float* u, float* v, float* f, float* g,float* s11, float* s12, float* s22 )

computeDensities( h, m, N, x, y, rho );computeStressTensors( h, m, lambda, mu, N, rho,

x, y, u, v, s11, s12, s22 );addAccelerations( h, m, B, n, rho0, N, rho,

x, y, s11, s12, s22, f, g );

register unsigned int i;

FOR_EACH_PARTICLEu[i] += dt * f[i];v[i] += dt * g[i];

x[i] += dt * u[i];y[i] += dt * v[i];

enforceBoundaryConditions( dt, epsilon, h, &x[i], &y[i], &u[i], &v[i] );END_FOR_EACH_PARTICLE

“Beware of bugs in the above code;I have only proved it correct, not tried it.”

Donald E. Knuth

79

Page 96: On the simulation of fluids for computer graphics - IMPA

80

Page 97: On the simulation of fluids for computer graphics - IMPA

Bibliography

[AA06] Anders Adamson and Marc Alexa. Anisotropic point set sur-faces. In Afrigaph ’06: Proceedings of the 4th international con-ference on Computer graphics, virtual reality, visualisation andinteraction in Africa, pages 7–13. ACM, 2006.

[AH70] A. A. Amsden and F. H. Harlow. The SMAC method: A numeri-cal technique for calculating incompressible fluid flows. TechnicalReport LA-4370, Los Alamos Scientific Laboratory, 1970.

[AN05] Alexis Angelidis and Fabrice Neyret. Simulation of smoke basedon vortex filament primitives. In SCA ’05: Proceedings of the2005 ACM SIGGRAPH/Eurographics symposium on Computeranimation, pages 87–96, New York, NY, USA, 2005. ACM Press.

[ANSN06] Alexis Angelidis, Fabrice Neyret, Karan Singh, and DerekNowrouzezahrai. A controllable, fast and stable basis for vor-tex based smoke simulation. In SCA ’06: Proceedings of the2006 ACM SIGGRAPH/Eurographics symposium on Computeranimation, pages 25–32, Aire-la-Ville, Switzerland, Switzerland,2006. Eurographics Association.

[AP98] Uri M. Ascher and Linda R. Petzold. Computer methods forordinary differential equations and differential-algebraic equa-tions. Society for Industrial and Applied Mathematics (SIAM),Philadelphia, PA, 1998.

[APKG07] Bart Adams, Mark Pauly, Richard Keiser, and Leonidas J.Guibas. Adaptively sampled particle fluids. In SIGGRAPH’07: ACM SIGGRAPH 2007 papers, New York, NY, USA, 2007.ACM Press.

81

Page 98: On the simulation of fluids for computer graphics - IMPA

[Bat99] G. K. Batchelor. An introduction to fluid dynamics. CambridgeMathematical Library. Cambridge University Press, Cambridge,paperback edition, 1999.

[BBB07] Christopher Batty, Florence Bertails, and Robert Bridson. A fastvariational framework for accurate solid-fluid coupling. ACMTrans. Graph., 26(3):100, 2007.

[BBC+94] R. Barrett, M. Berry, T. F. Chan, J. Demmel, J. Donato, J. Don-garra, V. Eijkhout, R. Pozo, C. Romine, and H. Van der Vorst.Templates for the Solution of Linear Systems: Building Blocksfor Iterative Methods, 2nd Edition. SIAM, Philadelphia, PA,1994.

[BCN03] Yosuke Bando, Bing-Yu Chen, and Tomoyuki Nishita. Animat-ing hair with loosely connected particles. Computer GraphicsForum, 22(3):411–418, 2003.

[BHW96] Ronen Barzel, John F. Hughes, and Daniel Wood. Plausible mo-tion simulation for computer animation. In EGCAS ’96: SeventhInternational Workshop on Computer Animation and Simula-tion, 1996.

[BMF07] Robert Bridson and Matthias Muller-Fischer. Fluid simulation.In SIGGRAPH’07: ACM SIGGRAPH 2007 Courses, pages 1–81, New York, NY, USA, 2007. ACM Press.

[Bor06] Alex Laier Bordignon. Navier-stokes em GPU. Master’s thesis,Departamento de Matematica, Pontifıcia Universidade Catolicado Rio de Janeiro, 2006.

[Bor07] Carlos E. C. Borges. Coarse grid correction operator splitting forparabolic partial differential equations. Master’s thesis, InstitutoNacional de Matematica Pura e Aplicada, 2007.

[BT07] Markus Becker and Matthias Teschner. Weakly compressiblesph for free surface flows. In SCA ’07: Proceedings of the 2007ACM SIGGRAPH/Eurographics symposium on Computer ani-mation, pages 209–217, Aire-la-Ville, Switzerland, Switzerland,2007. Eurographics Association.

82

Page 99: On the simulation of fluids for computer graphics - IMPA

[BWHT07] Adam W. Bargteil, Chris Wojtan, Jessica K. Hodgins, and GregTurk. A finite element method for animating large viscoplasticflow. In SIGGRAPH ’07: ACM SIGGRAPH 2007 papers, NewYork, NY, USA, 2007. ACM Press.

[CACC06] Mathieu Coquerelle, Jeremie Allard, Georges-Henri Cottet,and Marie-Paule Cani. A vortex method for bi-phasicfluids interacting with rigid bodies, 2006. Available athttp://arxiv.org/abs/math/0607597.

[CdVL95] Jim X. Chen and Niels da Vitoria Lobo. Toward interactive-ratesimulation of fluids with moving obstacles using navier-stokesequations. Graph. Models Image Process., 57(2):107–116, 1995.

[CF76] R. Courant and K. O. Friedrichs. Supersonic flow and shockwaves. Springer-Verlag, New York, 1976. Reprinting of the 1948original, Applied Mathematical Sciences, Vol. 21.

[CFL67] R. Courant, K. Friedrichs, and H. Lewy. On the partial differ-ence equations of mathematical physics. IBM J. Res. Develop.,11:215–234, 1967.

[CFL+07] Nuttapong Chentanez, Bryan E. Feldman, Francois Labelle,James F. O’Brien, and Jonathan R. Shewchuk. Liquid simula-tion on lattice-based tetrahedral meshes. In SCA ’07: Proceed-ings of the 2007 ACM SIGGRAPH/Eurographics symposium onComputer animation, pages 219–228, Aire-la-Ville, Switzerland,Switzerland, 2007. Eurographics Association.

[CGFO06] Nuttapong Chentanez, Tolga G. Goktekin, Bryan E. Feldman,and James F. O’Brien. Simultaneous coupling of fluids and de-formable bodies. In SCA ’06: Proceedings of the 2006 ACMSIGGRAPH/Eurographics symposium on Computer animation,pages 83–89, Aire-la-Ville, Switzerland, Switzerland, 2006. Eu-rographics Association.

[Cho68] Alexandre Joel Chorin. Numerical solution of the Navier-Stokesequations. Math. Comp., 22:745–762, 1968.

83

Page 100: On the simulation of fluids for computer graphics - IMPA

[CLT07] Keenan Crane, Ignacio Llamas, and Sarah Tariq. GPU Gems 3 –Chapter 30: Real-Time Simulation and Rendering of 3D Fluids.Addison-Wesley Professional, 2007.

[CM93] Alexandre J. Chorin and Jerrold E. Marsden. A mathematicalintroduction to fluid mechanics, volume 4 of Texts in AppliedMathematics. Springer-Verlag, New York, third edition, 1993.

[CMIT02] Mark Carlson, Peter J. Mucha, R. Brooks Van Horn III, andGreg Turk. Melting and flowing. In SCA ’02: Proceedings of the2002 ACM SIGGRAPH/Eurographics symposium on Computeranimation, pages 167–174, New York, NY, USA, 2002. ACMPress.

[CMT04] Mark Carlson, Peter J. Mucha, and Greg Turk. Rigid fluid:animating the interplay between rigid bodies and fluid. ACMTrans. Graph., 23(3):377–384, 2004.

[CPPK07] Paul W. Cleary, Soon Hyoung Pyo, Mahesh Prakash, and Bon KiKoo. Bubbling and frothing liquids. In SIGGRAPH ’07: ACMSIGGRAPH 2007 papers, New York, NY, USA, 2007. ACMPress.

[DEF+04] Oliver Deusen, David S. Ebert, Ron Fedkiw, F. Kenton Mus-grave, Przemyslaw Prusinkiewicz, Doug Roble, Jos Stam, andJerry Tessendorf. The elements of nature: interactive and real-istic techniques. In SIGGRAPH ’04: ACM SIGGRAPH 2004Course Notes, New York, NY, USA, 2004. ACM Press.

[Dem97] James W. Demmel. Applied numerical linear algebra. Societyfor Industrial and Applied Mathematics (SIAM), Philadelphia,PA, 1997.

[DG96] M. Desbrun and M. P. Gascuel. Smoothed particles: a newparadigm for animating highly deformable bodies. In EGCAS’96: Seventh International Workshop on Computer Animationand Simulation, 1996.

[EMF02] Douglas Enright, Stephen Marschner, and Ronald Fedkiw. Ani-mation and rendering of complex water surfaces. In SIGGRAPH

84

Page 101: On the simulation of fluids for computer graphics - IMPA

’02: Proceedings of the 29th annual conference on Computergraphics and interactive techniques, pages 736–744, New York,NY, USA, 2002. ACM Press.

[ETK+07] Sharif Elcott, Yiying Tong, Eva Kanso, Peter Schroder, andMathieu Desbrun. Stable, circulation-preserving, simplicial flu-ids. ACM Trans. Graph., 26(1):4, 2007.

[Eva98] Lawrence C. Evans. Partial differential equations, volume 19of Graduate Studies in Mathematics. American MathematicalSociety, Providence, RI, 1998.

[FF01] Nick Foster and Ronald Fedkiw. Practical animation of liquids.In Proceedings of ACM SIGGRAPH 2001, Computer Graph-ics Proceedings, Annual Conference Series, pages 23–30, August2001.

[FL04] Raanan Fattal and Dani Lischinski. Target-driven smoke ani-mation. In SIGGRAPH ’04: ACM SIGGRAPH 2004 Papers,pages 441–448, New York, NY, USA, 2004. ACM.

[FM96a] Nick Foster and Dimitri Metaxas. Realistic animation of liquids.In GI ’96: Proceedings of the conference on Graphics interface’96, pages 204–212, Toronto, Ont., Canada, Canada, 1996. Cana-dian Information Processing Society.

[FM96b] Nick Foster and Dimitri Metaxas. Realistic animation of liquids.Graphical Models and Image Processing, 58(5):471–483, 1996.

[FM97a] Nick Foster and Dimitris Metaxas. Controlling fluid animation.In CGI ’97: Proceedings of the 1997 Conference on ComputerGraphics International, Washington, DC, USA, 1997. IEEEComputer Society.

[FM97b] Nick Foster and Dimitris Metaxas. Modeling the motion ofa hot, turbulent gas. In SIGGRAPH ’97: Proceedings of the24th annual conference on Computer graphics and interactivetechniques, pages 181–188, New York, NY, USA, 1997. ACMPress/Addison-Wesley Publishing Co.

85

Page 102: On the simulation of fluids for computer graphics - IMPA

[FM00] Nick Foster and Dimitris Metaxas. Modeling water for computeranimation. Communications of the ACM, 43(7):60–67, 2000.

[FOA03] Bryan E. Feldman, James F. O’Brien, and Okan Arikan. Ani-mating suspended particle explosions. In SIGGRAPH ’03: ACMSIGGRAPH 2003 Papers, pages 708–715, New York, NY, USA,2003. ACM.

[FOK05] Bryan E. Feldman, James F. O’Brien, and Bryan M. Klingner.Animating gases with hybrid meshes. In SIGGRAPH ’05: ACMSIGGRAPH 2005 Papers, pages 904–909, New York, NY, USA,2005. ACM Press.

[FOKG05] Bryan E. Feldman, James F. O’Brien, Bryan M. Klingner, andTolga G. Goktekin. Fluids in deforming meshes. In SCA ’05:Proceedings of the 2005 ACM SIGGRAPH/Eurographics sympo-sium on Computer animation, pages 255–259, New York, NY,USA, 2005. ACM Press.

[FSJ01] Ronald Fedkiw, Jos Stam, and Henrik Wann Jensen. Visualsimulation of smoke. In SIGGRAPH ’01: Proceedings of the28th annual conference on Computer graphics and interactivetechniques, pages 15–22, New York, NY, USA, 2001. ACM Press.

[GBO04] Tolga G. Goktekin, Adam W. Bargteil, and James F. O’Brien.A method for animating viscoelastic fluids. In SIGGRAPH ’04:ACM SIGGRAPH 2004 Papers, pages 463–468, New York, NY,USA, 2004. ACM Press.

[GLG95] Manuel Noronha Gamito, Pedro Faria Lopes, and Mario RuiGomes. Two-dimensional simulation of gaseous phenomena us-ing vortex particles. In Demetri Terzopoulos and Daniel Thal-mann, editors, Computer Animation and Simulation ’95, pages2–15. Eurographics, Springer-Verlag, September 1995.

[GM77] R. A. Gingold and J. J. Monaghan. Smoothed particle hydrody-namics - Theory and application to non-spherical stars. MonthlyNotices of the Royal Astronomical Society, 181:375–389, Novem-ber 1977.

86

Page 103: On the simulation of fluids for computer graphics - IMPA

[GN07] Mohit Gupta and Srinivasa G. Narasimhan. Legendre fluids:a unified framework for analytic reduced space modeling andrendering of participating media. In SCA ’07: Proceedings of the2007 ACM SIGGRAPH/Eurographics symposium on Computeranimation, pages 17–25, Aire-la-Ville, Switzerland, Switzerland,2007. Eurographics Association.

[Gri06] Eitan Grinspun. Discrete differential geometry: An appliedintroduction. In SIGGRAPH ’06: ACM SIGGRAPH 2006Courses, New York, NY, USA, 2006. ACM.

[GSLF05] Eran Guendelman, Andrew Selle, Frank Losasso, and RonaldFedkiw. Coupling water and smoke to thin deformable and rigidshells. ACM Trans. Graph., 24(3):973–981, 2005.

[Har04] Mark Harris. GPU Gems – Chapter 38: Fast Fluid DynamicsSimulation on the GPU. Addison-Wesley Professional, 2004.

[HCSL02] Mark J. Harris, Greg Coombe, Thorsten Scheuermann, andAnselmo Lastra. Physically-based visual simulation on graphicshardware. In Graphics Hardware 2002, pages 109–118, Septem-ber 2002.

[HK89] L. Hernquist and N. Katz. TREESPH - A unification of SPHwith the hierarchical tree method. The Astrophysical JournalSupplement Series, 70:419–446, June 1989.

[HK05] Jeong-Mo Hong and Chang-Hun Kim. Discontinuous fluids.ACM Trans. Graph., 24(3):915–920, 2005.

[HM76] Thomas J. R. Hughes and Jerrold E. Marsden. A short coursein fluid mechanics. Publish or Perish Inc., Boston, Mass., 1976.Mathematics Lecture Series, No. 6.

[HMT01] Sunil Hadap and Nadia Magnenat-Thalmann. Modeling dy-namic hair as a continuum. Computer Graphics Forum,20(3):329–338, 2001.

[HNB+06] Ben Houston, Michael B. Nielsen, Christopher Batty, Ola Nils-son, and Ken Museth. Hierarchical RLE level set: A compact

87

Page 104: On the simulation of fluids for computer graphics - IMPA

and versatile deformable surface representation. ACM Trans.Graph., 25(1):151–175, 2006.

[HW65] Francis H. Harlow and J. Eddie Welch. Numerical calculationof time-dependent viscous incompressible flow of fluid with freesurface. Physics of Fluids, 8(12):2182–2189, 1965.

[Igl04] A. Iglesias. Computer graphics for water modeling and ren-dering: A survey. Future Generation Computer Systems,20(8):1355–1374, 2004.

[II01] Rafael Jose Iorio, Jr. and Valeria de Magalhaes Iorio. Fourieranalysis and partial differential equations, volume 70 of Cam-bridge Studies in Advanced Mathematics. Cambridge UniversityPress, Cambridge, 2001.

[Ise96] Arieh Iserles. A first course in the numerical analysis of dif-ferential equations. Cambridge Texts in Applied Mathematics.Cambridge University Press, Cambridge, 1996.

[Joh91] Fritz John. Partial differential equations, volume 1 of AppliedMathematical Sciences. Springer-Verlag, New York, fourth edi-tion, 1991.

[KAG+05] R. Keiser, B. Adams, D. Gasser, P. Bazzi, P. Dutre, andM. Gross. A unified lagrangian approach to solid-fluid anima-tion. pages 125–148, 2005.

[KFCO06] Bryan M. Klingner, Bryan E. Feldman, Nuttapong Chentanez,and James F. O’Brien. Fluid animation with dynamic meshes.In SIGGRAPH ’06: ACM SIGGRAPH 2006 Papers, pages 820–825, New York, NY, USA, 2006. ACM Press.

[KM90] Michael Kass and Gavin Miller. Rapid, stable fluid dynamicsfor computer graphics. In Computer Graphics (Proceedings ofSIGGRAPH 90), pages 49–57, August 1990.

[KMT06] Yootai Kim, Raghu Machiraju, and David Thompson. Path-based control of smoke simulations. In SCA ’06: Proceed-ings of the 2006 ACM SIGGRAPH/Eurographics symposium on

88

Page 105: On the simulation of fluids for computer graphics - IMPA

Computer animation, pages 33–42, Aire-la-Ville, Switzerland,Switzerland, 2006. Eurographics Association.

[KYT+06] L. Kharevych, Weiwei Yang, Y. Tong, E. Kanso, J. E. Marsden,P. Schroder, and M. Desbrun. Geometric, variational integra-tors for computer animation. In SCA ’06: Proceedings of the2006 ACM SIGGRAPH/Eurographics symposium on Computeranimation, pages 43–51, Aire-la-Ville, Switzerland, Switzerland,2006. Eurographics Association.

[Lam93] Horace Lamb. Hydrodynamics. Cambridge Mathematical Li-brary. Cambridge University Press, Cambridge, sixth edition,1993.

[LeV07] Randall J. LeVeque. Finite Difference Methods for Ordinaryand Partial Differential Equations: Steady-State and Time-Dependent Problems. Society for Industrial and Applied Math-ematics (SIAM), Philadelphia, PA, 2007.

[LGF04] Frank Losasso, Frederic Gibou, and Ron Fedkiw. Simulatingwater and smoke with an octree data structure. In SIGGRAPH’04: ACM SIGGRAPH 2004 Papers, pages 457–462, New York,NY, USA, 2004. ACM Press.

[LLVT03] Thomas Lewiner, Helio Lopes, Antonio Wilson Vieira, and Geo-van Tavares. Efficient implementation of marching cubes’ caseswith topological guarantees. Journal of Graphics Tools, 8(2):1–15, 2003.

[Lov44] A. E. H. Love. A Treatise on the Mathematical Theory of Elas-ticity. Dover Publications, New York, 1944. Fourth Ed.

[LR04] Benedict Leimkuhler and Sebastian Reich. Simulating Hamilto-nian dynamics, volume 14 of Cambridge Monographs on Appliedand Computational Mathematics. Cambridge University Press,Cambridge, 2004.

[LSSF06] Frank Losasso, Tamar Shinar, Andrew Selle, and Ronald Fedkiw.Multiple interacting liquids. ACM Trans. Graph., 25(3):812–819,2006.

89

Page 106: On the simulation of fluids for computer graphics - IMPA

[Luc77] L. B. Lucy. A numerical approach to the testing of the fission hy-pothesis. Astronomical Journal, 82:1013–1024, December 1977.

[LvdP02] Anita T. Layton and Michiel van de Panne. A numerically ef-ficient and stable algorithm for animating water waves. TheVisual Computer, 18(1):41–53, 2002.

[MCG03] Matthias Muller, David Charypar, and Markus Gross. Particle-based fluid simulation for interactive applications. In SCA ’03:Proceedings of the 2003 ACM SIGGRAPH/Eurographics sym-posium on Computer animation, pages 154–159, Aire-la-Ville,Switzerland, Switzerland, 2003. Eurographics Association.

[Mei07] Chiang C. Mei. Lecture notes on fluid dynamics. Available athttp://web.mit.edu/1.63/www/, 2007.

[Mey82] Richard E. Meyer. Introduction to mathematical fluid dynamics.Dover Publications Inc., New York, 1982.

[MFZ97] Joseph P. Morris, Patrick J. Fox, and Yi Zhu. Modeling lowreynolds number incompressible flows using sph. Journal ofComputational Physics, 136(1):214–226, 1997.

[MH94] Jerrold E. Marsden and Thomas J. R. Hughes. Mathematicalfoundations of elasticity. Dover Publications Inc., New York,1994.

[MKN+04] M. Muller, R. Keiser, A. Nealen, M. Pauly, M. Gross, andM. Alexa. Point based animation of elastic, plastic and melt-ing objects. In SCA ’04: Proceedings of the 2004 ACMSIGGRAPH/Eurographics symposium on Computer animation,pages 141–151, Aire-la-Ville, Switzerland, Switzerland, 2004.Eurographics Association.

[MMTD07] Patrick Mullen, Alexander McKenzie, Yiying Tong, and MathieuDesbrun. A variational approach to eulerian geometry process-ing. ACM Trans. Graph., 26(3):66, 2007.

[MN91] Severiano Toscano Melo and Francisco Moura Neto. Mecanicados Fluidos e Equacoes Diferenciais. 18o Coloquio Brasileiro de

90

Page 107: On the simulation of fluids for computer graphics - IMPA

Matematica, Instituto Nacional de Matematica Pura e Aplicada,1991.

[Mon92] J. J. Monaghan. Smoothed particle hydrodynamics. AnnualReview of Astronomy and Astrophysics, 30:543–574, 1992.

[Mon94] J. J. Monaghan. Simulating free surface flows with sph. J.Comput. Phys., 110(2):399–406, 1994.

[Mon05] J. J. Monaghan. Smoothed particle hydrodynamics. Rep. Progr.Phys., 68(8):1703–1759, 2005.

[MQ02] Robert I. McLachlan and G. Reinout W. Quispel. Splittingmethods. Acta Numer., 11:341–434, 2002.

[MSKG05] Matthias Muller, Barbara Solenthaler, Richard Keiser, andMarkus Gross. Particle-based fluid-fluid interaction. In 2005ACM SIGGRAPH / Eurographics Symposium on Computer An-imation, pages 237–244, July 2005.

[MST+04] Matthias Muller, Simon Schirm, Matthias Teschner, Bruno Hei-delberger, and Markus Gross. Interaction of fluids with de-formable solids. Computer Animation and Virtual Worlds, 15(3-4):159–171, 2004.

[MTPS04] Antoine McNamara, Adrien Treuille, Zoran Popovic, and JosStam. Fluid control using the adjoint method. In SIGGRAPH’04: ACM SIGGRAPH 2004 Papers, pages 449–456, New York,NY, USA, 2004. ACM.

[Nac01] Andre Nachbin. Aspectos de Modelagem Matematica emDinamica dos Fluidos. 23o Coloquio Brasileiro de Matematica,Instituto Nacional de Matematica Pura e Aplicada, 2001.

[Nac07] Andre Nachbin. Dinamica dos fluidos. Lecture Notes, 2007.

[Nak07] Fabio Issao Nakamura. Animacao interativa de fluido baseadaem partıculas pelo metodo SPH. Master’s thesis, Departa-mento de Informatica, Pontifıcia Universidade Catolica do Riode Janeiro, 2007.

91

Page 108: On the simulation of fluids for computer graphics - IMPA

[Net07] Afonso Paiva Neto. Uma abordagem Lagrangeana para simulacaode escoamentos de fluidos viscoplasticos e multifasicos. PhDthesis, Departamento de Matematica, Pontifıcia UniversidadeCatolica do Rio de Janeiro, 2007.

[NFJ02] Duc Quang Nguyen, Ronald Fedkiw, and Henrik Wann Jensen.Physically based modeling and animation of fire. In SIGGRAPH’02: Proceedings of the 29th annual conference on Computergraphics and interactive techniques, pages 721–728, New York,NY, USA, 2002. ACM Press.

[NMK+06] Andrew Nealen, Matthias Muller, Richard Keiser, Eddy Boxer-man, and Mark Carlson. Physically based deformable models incomputer graphics. Computer Graphics Forum, 25(4):809–836,2006.

[OD01] Carol O’Sullivan and John Dingliana. Collisions and perception.ACM Trans. Graph., 20(3):151–168, 2001.

[ODGK03] Carol O’Sullivan, John Dingliana, Thanh Giang, and Mary K.Kaiser. Evaluating the visual fidelity of physically based anima-tions. ACM Trans. Graph., 22(3):527–536, 2003.

[OF03] Stanley Osher and Ronald Fedkiw. Level set methods and dy-namic implicit surfaces, volume 153 of Applied MathematicalSciences. Springer-Verlag, New York, 2003.

[O’S05] Carol O’Sullivan. Collisions and attention. ACM Trans. Appl.Percept., 2(3):309–321, 2005.

[Pat87] Jorge Patino. Introducao a Teoria da Elasticidade. 16o ColoquioBrasileiro de Matematica, Instituto Nacional de MatematicaPura e Aplicada, 1987.

[PK05] Sang Il Park and Myoung Jun Kim. Vortex fluid for gaseousphenomena. In SCA ’05: Proceedings of the 2005 ACMSIGGRAPH/Eurographics symposium on Computer animation,pages 261–270, New York, NY, USA, 2005. ACM Press.

92

Page 109: On the simulation of fluids for computer graphics - IMPA

[PPLT06] Afonso Paiva, Fabiano Petronetto, Thomas Lewiner, and Geo-van Tavares. Particle-based non-newtonian fluid animation formelting objects. SIBGRAPI, pages 78–85, 2006.

[PTB+03] Simon Premoze, Tolga Tasdizen, James Bigler, Aaron Lefohn,and Ross T. Whitaker. Particle-based simulation of fluids. Com-puter Graphics Forum, 22(3):401–410, September 2003.

[PTVF92] William H. Press, Saul A. Teukolsky, William T. Vetterling, andBrian P. Flannery. Numerical recipes in C: The art of scientificcomputing. Cambridge University Press, Cambridge, second edi-tion, 1992.

[REN+04] N. Rasmussen, D. Enright, D. Nguyen, S. Marino, N. Sum-ner, W. Geiger, S. Hoon, and R. Fedkiw. Directable photo-realistic liquids. In SCA ’04: Proceedings of the 2004 ACMSIGGRAPH/Eurographics symposium on Computer animation,pages 193–202, Aire-la-Ville, Switzerland, Switzerland, 2004.Eurographics Association.

[RNGF03] Nick Rasmussen, Duc Quang Nguyen, Willi Geiger, and RonaldFedkiw. Smoke simulation for large scale phenomena. In SIG-GRAPH ’03: ACM SIGGRAPH 2003 Papers, pages 703–707,New York, NY, USA, 2003. ACM Press.

[Saa03] Yousef Saad. Iterative methods for sparse linear systems. Soci-ety for Industrial and Applied Mathematics, Philadelphia, PA,second edition, 2003.

[SB02] J. Stoer and R. Bulirsch. Introduction to numerical analysis,volume 12 of Texts in Applied Mathematics. Springer-Verlag,New York, third edition, 2002. Translated from the German byR. Bartels, W. Gautschi and C. Witzgall.

[SC91] Andrew Staniforth and Jean Cote. Semi-lagrangian integrationschemes for atmospheric models — a review. Monthly WeatherReview, 119(9):2206–2223, 1991.

[SCC04] C. Scheidegger, J. Comba, and R. Cunha. Navier-stokes on pro-grammable graphics hardware using SMAC. In Proceedings ofXVII SIBGRAPI – II SIACG, pages 300–307. IEEE Press, 2004.

93

Page 110: On the simulation of fluids for computer graphics - IMPA

[SCC05] C. Scheidegger, J. Comba, and R. Cunha. Practical CFD sim-ulations on the GPU using SMAC. Computer Graphics Forum,24(4):715–728, 2005.

[SCP+04] Maurya Shah, Jonathan M. Cohen, Sanjit Patel, Penne Lee,and Frederic Pighin. Extended galilean invariance for adap-tive fluid simulation. In SCA ’04: Proceedings of the 2004ACM SIGGRAPH/Eurographics symposium on Computer an-imation, pages 213–221, Aire-la-Ville, Switzerland, Switzerland,2004. Eurographics Association.

[SD06] Ari Stern and Mathieu Desbrun. Discrete geometric mechanicsfor variational time integrators. In SIGGRAPH ’06: ACM SIG-GRAPH 2006 Courses, pages 75–80, New York, NY, USA, 2006.ACM Press.

[SF93] Jos Stam and Eugene Fiume. Turbulent wind fields for gaseousphenomena. In SIGGRAPH ’93: Proceedings of the 20th annualconference on Computer graphics and interactive techniques,pages 369–376, New York, NY, USA, 1993. ACM.

[SF95] Jos Stam and Eugene Fiume. Depicting fire and other gaseousphenomena using diffusion processes. In SIGGRAPH ’95: Pro-ceedings of the 22nd annual conference on Computer graphicsand interactive techniques, pages 129–136, New York, NY, USA,1995. ACM Press.

[SMML07] Jason Sewall, Paul Mecklenburg, Sorin Mitran, and Ming Lin.Fast fluid simulation using residual distribution schemes. In Pro-ceedings of the Eurographics Workshop on Natural Phenomena,2007.

[SRF05] Andrew Selle, Nick Rasmussen, and Ronald Fedkiw. A vortexparticle method for smoke, water and explosions. ACM Trans.Graph., 24(3):910–914, 2005.

[Sta99] Jos Stam. Stable fluids. In SIGGRAPH ’99: Proceedings of the26th annual conference on Computer graphics and interactivetechniques, pages 121–128, New York, NY, USA, 1999. ACMPress/Addison-Wesley Publishing Co.

94

Page 111: On the simulation of fluids for computer graphics - IMPA

[Sta00] Jos Stam. Interacting with smoke and fire in real time. Com-munications of the ACM, 43(7):76–83, 2000.

[Sta01] Jos Stam. A simple fluid solver based on the FFT. J. Graph.Tools, 6(2):43–52, 2001.

[Sta03] Jos Stam. Flows on surfaces of arbitrary topology. In SIG-GRAPH ’03: ACM SIGGRAPH 2003 Papers, pages 724–731,New York, NY, USA, 2003. ACM Press.

[Str80] Gilbert Strang. Linear algebra and its applications. AcademicPress, New York, second edition, 1980.

[Str04] John C. Strikwerda. Finite difference schemes and partial differ-ential equations. Society for Industrial and Applied Mathematics(SIAM), Philadelphia, PA, second edition, 2004.

[SU94] John Steinhoff and David Underhill. Modification of the eu-ler equations for “vorticity confinement”: Application to thecomputation of interacting vortex rings. Physics of Fluids,6(8):2738–2744, 1994.

[SY05a] Lin Shi and Yizhou Yu. Controllable smoke animation withguiding objects. ACM Trans. Graph., 24(1):140–164, 2005.

[SY05b] Lin Shi and Yizhou Yu. Taming liquids for rapidly chang-ing targets. In SCA ’05: Proceedings of the 2005 ACMSIGGRAPH/Eurographics symposium on Computer animation,pages 229–236, New York, NY, USA, 2005. ACM.

[TB97] Lloyd N. Trefethen and David Bau, III. Numerical linear alge-bra. Society for Industrial and Applied Mathematics (SIAM),Philadelphia, PA, 1997.

[TDM96] M. F. Tome, B. Duffy, and S. McKee. A numerical techniquefor solving unsteady non-newtonian free surface flows. Journalof Non-Newtonian Fluid Mechanics, 62(1):9–34, 1996.

[TF88] Demetri Terzopoulos and Kurt Fleischer. Modeling inelasticdeformation: Viscoelasticity, plasticity, fracture. In ComputerGraphics (Proceedings of SIGGRAPH’ 88), pages 269–278, 1988.

95

Page 112: On the simulation of fluids for computer graphics - IMPA

[TFC+01] M. F. Tome, A. C. Filho, J. A. Cuminato, N. Mangiavacchi,and S. McKee. Gensmac3d: A numerical method for solving un-steady three-dimensional free surface flows. International Jour-nal for Numerical Methods in Fluids, 37(7):747–796, 2001.

[TGC+04] M. F. Tome, L. Grossi, A. Castelo, J. A. Cuminato, N. Man-giavacchi, V. G. Ferreira, F. S. deSousa, and S. McKee. A numer-ical method for solving three-dimensional generalized newtonianfree surface flows. Journal of Non-Newtonian Fluid Mechanics,123(2-3):85–103, 2004.

[Thu07] Nils Thuerey. Physically based Animation of Free Surface Flowswith the Lattice Boltzmann Method. PhD thesis, Friedrich-Alexander-Universitat Erlangen-Nurnberg, Institut fur Infor-matik, 2007.

[TKPR06] N. Thuerey, R. Keiser, M. Pauly, and U. Rude. Detail-preservingfluid control. In SCA ’06: Proceedings of the 2006 ACMSIGGRAPH/Eurographics symposium on Computer animation,pages 7–12, Aire-la-Ville, Switzerland, Switzerland, 2006. Euro-graphics Association.

[TLP06] Adrien Treuille, Andrew Lewis, and Zoran Popovic. Model re-duction for real-time fluids. ACM Transactions on Graphics,25(3):826–834, 2006.

[TM94] Murilo F. Tome and Sean McKee. Gensmac: A computationalmarker and cell method for free surface flows in general domains.Journal of Computational Physics, 110(1):171–186, 1994.

[TMPS03] Adrien Treuille, Antoine McNamara, Zoran Popovic, and JosStam. Keyframe control of smoke simulations. In SIGGRAPH’03: ACM SIGGRAPH 2003 Papers, pages 716–723, New York,NY, USA, 2003. ACM.

[TPBF87] Demetri Terzopoulos, John Platt, Alan Barr, and Kurt Fleischer.Elastically deformable models. In Computer Graphics (Proceed-ings of SIGGRAPH 87), pages 205–214, July 1987.

[Tre96] Lloyd N. Trefethen. Finite difference and spectral methodsfor ordinary and partial differential equations. Unpublished

96

Page 113: On the simulation of fluids for computer graphics - IMPA

manuscript avaliable at http://web.comlab.ox.ac.uk/oucl/work/nick.trefethen/pdetext.html, 1996.

[TRS06] Nils Thurey, Ulrich Rude, and Marc Stamminger. Animationof open water phenomena with coupled shallow water and freesurface simulations. In 2006 ACM SIGGRAPH / EurographicsSymposium on Computer Animation, pages 157–166, 2006.

[WB01] Andrew Witkin and David Baraff. Physicallybased modeling. In SIGGRAPH’01: ACM SIG-GRAPH 2001 Courses, 2001. Available athttp://www.pixar.com/companyinfo/research/pbm2001/.

[WBOL07] Jeremy D. Wendt, William Baxter, Ipek Oguz, and Ming C. Lin.Finite volume flow simulations on arbitrary domains. Graph.Models, 69(1):19–32, 2007.

[WG00] Dieter A. Wolf-Gladrow. Lattice-gas cellular automata and lat-tice Boltzmann models, volume 1725 of Lecture Notes in Mathe-matics. Springer-Verlag, Berlin, 2000. An introduction.

[WH91] Jakub Wejchert and David Haumann. Animation aerodynamics.In SIGGRAPH ’91: Proceedings of the 18th annual conferenceon Computer graphics and interactive techniques, pages 19–22,New York, NY, USA, 1991. ACM.

[Whi99] G. B. Whitham. Linear and nonlinear waves. Pure and AppliedMathematics (New York). John Wiley & Sons Inc., New York,1999.

[WLMK04] Xiaoming Wei, Wei Li, Klaus Mueller, and Arie E. Kaufman.The lattice-boltzmann method for simulating gaseous phenom-ena. IEEE Transactions on Visualization and Computer Graph-ics, 10(2):164–176, March/April 2004.

[YHK07] Cem Yuksel, Donald H. House, and John Keyser. Wave par-ticles. ACM Transactions on Graphics (Proceedings of SIG-GRAPH 2007), 26(3):to appear, 2007.

[ZB05] Yongning Zhu and Robert Bridson. Animating sand as a fluid.ACM Trans. Graph., 24(3):965–972, 2005.

97