the lattice-boltzmann model for the visual...

76
THE LATTICE-BOLTZMANN MODEL FOR THE VISUAL SIMULATION OF SMOKE by Usman Raza Alim B.S., University of Rochester, 2001 a thesis submitted in partial fulfillment of the requirements for the degree of Master of Science in the Department of Computer Science c Usman Raza Alim 2007 ROCHESTER INSTITUTE OF TECHNOLOGY Spring 2007 All rights reserved. This work may not be reproduced in whole or in part, by photocopy or other means, without the permission of the author.

Upload: others

Post on 07-Feb-2021

1 views

Category:

Documents


0 download

TRANSCRIPT

  • THE LATTICE-BOLTZMANN MODEL FOR THE

    VISUAL SIMULATION OF SMOKE

    by

    Usman Raza Alim

    B.S., University of Rochester, 2001

    a thesis submitted in partial fulfillment

    of the requirements for the degree of

    Master of Science

    in the Department

    of

    Computer Science

    c© Usman Raza Alim 2007ROCHESTER INSTITUTE OF TECHNOLOGY

    Spring 2007

    All rights reserved. This work may not be

    reproduced in whole or in part, by photocopy

    or other means, without the permission of the author.

  • APPROVAL

    Name: Usman Raza Alim

    Degree: Master of Science

    Title of thesis: The Lattice-Boltzmann Model for the Visual Simulation of

    Smoke

    Examining Committee: Dr. Joe Geigel

    Chair

    Dr. Sidney Marshall, Reader

    Prof. Sean Strout, Observer

    Dr. Hans-Peter Bischoff, Graduate Coordinator

    Date Approved:

    ii

  • Abstract

    The modeling and simulation of smoke, like other fluid phenomena, is an important and

    challenging problem in Computer Graphics. In order to achieve high levels of visual realism,

    physically based methods are usually used. Smoke is treated as a non-reactive substance

    that is transported by an incompressible fluid. The dynamics of such a fluid is described by

    a set of non-linear partial differential equations known as the Navier-Stokes (NS) equations.

    Numerical methods for solving the NS equations can broadly be classified into two

    categories, top-down and bottom-up. Top-down methods are well-studied and have been

    successfully used in Computer Graphics to produce highly realistic animations of smoke

    and other fluid phenomena. On the other hand, bottom-up methods such as the Lattice-

    Boltzmann Method (LBM) are still being improved and have only been recently investigated

    by the Computer Graphics community.

    In this thesis, we adapt the Lattice-Boltzmann Method for the purpose of smoke simu-

    lation in both two and three dimensions, and qualitatively compare the simulation results

    with those obtained through a top-down method. In order to achieve visual realism, we

    use physically based buoyancy and vorticity forces to drive the flow and employ a semi-

    Lagrangian method to advect smoke densities along the flow. Our simulation results reveal

    that the LBM retains much of the realism characteristic of the top-down methods, and at

    the same time, offers considerable advantages in terms of simplicity and efficiency.

    iii

  • To the memory of my grandfather, Muhammad Alimuddin

    iv

  • Acknowledgments

    The journey to the culmination of this work has been a long and intersting one. Along the

    way, many people extended their support in various ways and my gratitude goes to them.

    I would like to thank:

    • Dr. Joe Geigel, my supervisor in Rochester, for his continued support and guidanceand for introducing me to the fascinating area of Computer Graphics.

    • Dr. Torsten Möller, my supervisor in Vancouver, for his cooperation and understand-ing, for proofreading the manuscripts and for providing an excellent workspace.

    • All the students at SFU with whom I had some very fruitful discussions, in particular,Yonas Tesfezghi Weldesselassie and Alireza Entezari.

    • Sadia, my wife, for her unending and unflinching support.

    • Dr. Nabila Babur, my mother, for teaching me to be patient during stressful times.

    • Dr. Babur Zahiruddin, my father, for his financial support. My brothers, Salman andZeeshan, for their camaraderie.

    • Dr. Muhammad Alimuddin, my late grandfather whose spirit thrives in me and con-tinues to provide ecouragement and inspiration.

    v

  • Contents

    Approval ii

    Abstract iii

    Dedication iv

    Acknowledgments v

    Contents vi

    List of Tables ix

    List of Figures x

    1 Introduction 1

    1.1 Previous Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

    1.1.1 Procedural Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

    1.1.2 Top-down Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

    1.1.3 Bottom-up Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

    1.2 Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

    1.3 Evaluation Criteria . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

    1.4 Thesis Organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

    2 Top-down Model 7

    2.1 Fluid Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

    2.1.1 Assumptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

    2.1.2 Euler equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

    vi

  • 2.1.3 Advection of Smoke . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

    2.2 External Forces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

    2.2.1 Buoyancy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

    2.2.2 Vorticity Confinement . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

    3 The Lattice-Boltzmann Model 12

    3.1 The Boltzmann Equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

    3.1.1 The BGK Approximation . . . . . . . . . . . . . . . . . . . . . . . . . 14

    3.2 The Lattice-Boltzmann Equation . . . . . . . . . . . . . . . . . . . . . . . . . 15

    3.2.1 Discrete Boltzmann Equation . . . . . . . . . . . . . . . . . . . . . . . 15

    3.2.2 LBGK Equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

    3.2.3 Macroscopic Quantities . . . . . . . . . . . . . . . . . . . . . . . . . . 17

    3.2.4 Initial and Boundary Conditions . . . . . . . . . . . . . . . . . . . . . 17

    3.2.5 Advection of Scalar Fields . . . . . . . . . . . . . . . . . . . . . . . . . 18

    3.2.6 External Forces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

    3.3 Two and Three Dimensional Lattices . . . . . . . . . . . . . . . . . . . . . . . 20

    3.3.1 D2Q7 and D2Q9 Lattices . . . . . . . . . . . . . . . . . . . . . . . . . 20

    3.3.2 D3Q15, D3Q19 and D3Q27 Lattices . . . . . . . . . . . . . . . . . . . 21

    3.3.3 Computing the Equilibrium Distributions . . . . . . . . . . . . . . . . 22

    3.4 Limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

    3.4.1 Solution to Navier-Stokes equations . . . . . . . . . . . . . . . . . . . 24

    3.4.2 Viscosity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

    3.4.3 Stability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

    4 Implementation 27

    4.1 The Method of Projection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

    4.1.1 A note on Boundary Conditions . . . . . . . . . . . . . . . . . . . . . 30

    4.1.2 Computing the Intermediate Velocity Field . . . . . . . . . . . . . . . 31

    4.1.3 Solving the Discrete Poisson Problem . . . . . . . . . . . . . . . . . . 33

    4.2 Physically Based Rendering . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

    4.2.1 Scattering Media . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

    4.2.2 Phase Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

    4.2.3 Volumetric Photon Mapping . . . . . . . . . . . . . . . . . . . . . . . 40

    vii

  • 5 Results and Discussion 42

    5.1 The Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

    5.2 2D Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

    5.2.1 Top-Down . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

    5.2.2 Bottom-Up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48

    5.3 3D Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53

    5.3.1 Top-Down . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53

    5.3.2 Bottom-Up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56

    6 Conclusion and Future Work 61

    Appendices 63

    A Supplemental Material 63

    Bibliography 64

    viii

  • List of Tables

    3.1 Coefficients for the D2Q9 Lattice . . . . . . . . . . . . . . . . . . . . . . . . . 24

    3.2 Coefficients for the D3Q15 Lattice . . . . . . . . . . . . . . . . . . . . . . . . 24

    3.3 Coefficients for the D3Q19 Lattice . . . . . . . . . . . . . . . . . . . . . . . . 25

    3.4 Coefficients for the D3Q27 Lattice . . . . . . . . . . . . . . . . . . . . . . . . 25

    5.1 2D simulation parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

    5.2 2D LBM simulation parameters . . . . . . . . . . . . . . . . . . . . . . . . . . 48

    5.3 3D simulation parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53

    5.4 3D LBM simulation parameters . . . . . . . . . . . . . . . . . . . . . . . . . . 56

    ix

  • List of Figures

    3.1 The D2Q7 and D2Q9 lattices . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

    3.2 Three Dimensional Sublattices . . . . . . . . . . . . . . . . . . . . . . . . . . 23

    4.1 The halfway boundary ∂Ω . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

    4.2 A schematic representation of the method of projection . . . . . . . . . . . . 32

    5.1 2D top-down results with no vorticity confinement . . . . . . . . . . . . . . . 46

    5.2 2D top-down results with vorticity confinement . . . . . . . . . . . . . . . . . 47

    5.3 2D LBM results with no vorticity confinement, RE = 50 . . . . . . . . . . . . 50

    5.4 2D LBM results with no vorticity confinement, RE = 100 . . . . . . . . . . . 51

    5.5 2D LBM results with vorticity confinement, RE = 100 . . . . . . . . . . . . . 52

    5.6 3D top-down results with vorticity confinement . . . . . . . . . . . . . . . . . 55

    5.7 D3Q19 results with vorticity confinement, RE = 100 . . . . . . . . . . . . . . 57

    5.8 D3Q27 results with vorticity confinement, RE = 100 . . . . . . . . . . . . . . 58

    5.9 D3Q19 results with vorticity confinement, RE = 400 . . . . . . . . . . . . . . 59

    5.10 D3Q27 results with vorticity confinement, RE = 400 . . . . . . . . . . . . . . 60

    x

  • Chapter 1

    Introduction

    The level of realism found in computer generated imagery nowadays is stunning. Anima-

    tion studios, movie directors, video game developers and artists are increasingly relying on

    computers to create breath-taking visual effects. Their goal is to achieve a degree of realism

    that makes their imagery virtually indistinguishable from reality. Bringing digital imagery

    to life is a challenging task and has been the focus of research in Computer Graphics (CG)

    for the past couple of decades or so. In particular, the modeling and simulation of fluid

    phenomena such as fire, water and smoke has received a great deal of attention. In this

    thesis, we wish to explore one such problem namely, the visual simulation of smoke.

    Smoke is an amorphous substance with a highly complex and turbulent fluid motion.

    Producing animation sequences of smoke is a two-stage process. The first stage models the

    geometry and motion of smoke while the second stage renders the smoke onto the screen. In

    order to produce realistic visual simulations, it is important that a physically-based model

    be employed for the two stages. This implies that both the dynamics of smoke and its

    interaction with light must be accurately modeled.

    In this chapter, we shall present an overview of some of the methods that have already

    been used to address this problem and discuss how they motivate the goals of this thesis.

    The organization of the rest of the thesis is described at the end of this chapter.

    1.1 Previous Work

    A good model for the simulation of fluid phenomena such as smoke must be efficient, easy

    to use and be capable of producing highly realistic results. However, there is a tradeoff

    1

  • 1.1. PREVIOUS WORK

    between these goals and it is no surprise that most of the existing simulation strategies have

    concentrated on one goal while compromising on the others. The different approaches that

    have so far been used to animate gaseous phenomena can be broadly classified into three

    different categories: procedural, top-down and bottom-up.

    1.1.1 Procedural Methods

    In the early days when the problem of the simulation of gaseous phenomena started gaining

    interest, researchers were concerned more with the appearance of smoke than with accuracy.

    Consequently, these models were not physically-based and did not account for the dynamics

    of fluid flow. Both the geometry and the motion of smoke were procedurally generated.

    Ebert et al. used solid spaces to animate gaseous phenomena [9]. A solid space is a

    three dimensional space that associates with each point, one or more attributes. In their

    work, the density of the gas is represented as a procedurally generated solid space. In order

    to mimic the small scale turbulent detail that exists within the geometry of smoke, they

    used a turbulence function [22] that computes a pseudorandom noise value for a point. The

    motion of the gas is also procedurally generated by animating the solid space that the gas

    resides in. They made use of helical paths to create interesting visual effects. In order to

    render the volume densities, they employed a volume rendering procedure that accounted

    for the attenuation of light as it traverses a gas volume.

    Procedural methods, while being simple in their description, have the obvious drawback

    that they fail to capture the physical dynamics of fluid flow. The procedures are dependent

    on a set of parameters which can be hard to fine tune as they don’t have any physical

    counterparts.

    1.1.2 Top-down Methods

    The dynamics of smoke and other gaseous phenomena is governed by the Navier-Stokes (NS)

    equations of fluid flow. At any instant, the dynamics of an incompressible fluid (constant

    mass density) in two or three dimensions can be described by a velocity field and a pressure

    field. Smoke is described as a scalar density field that is injected into the fluid and is

    advected by it. Advection is the name given to the motion of a non-reactive substance

    along the velocity field. Provided that the initial velocity and pressure fields are known, the

    dynamics of these fields over time is completely determined by the Navier-Stokes equations.

    2

  • 1.1. PREVIOUS WORK

    Navier-Stokes equations and other non-linear partial differential equations are usually

    solved through a top-down approach where the spatial domain is discretized through finite

    difference, finite volume or finite element methods. This is the conventional way fluid

    flow problems are solved and there is immense literature on these methods in the field of

    Computational Fluid Dynamics (CFD).

    The goal of a simulation in Computer Graphics is visual realism rather than physical

    accuracy. For this reason, computational grids are coarse as compared to their CFD coun-

    terparts and time steps are usually taken to be large in order to reduce the complexity

    of the simulation. Foster et al. [14] provided a finite difference solution to the NS equa-

    tions. Because of the coarse discretization and an explicit integration scheme, their work

    was prone to instabilities at large time steps. Later, Stam proposed a fluid solver based on

    a semi-Lagrangian numerical scheme [26]. This method is unconditionally stable and can

    incorporate large time steps.

    Smoke in air is an example of turbulent flow where small scale vorticity (curl of the

    velocity field) features are prominent. A coarse spatial sampling is unable to capture these

    small scale details and any turbulence that is initially present quickly decays over time.

    In order to remedy this problem, Fedkiw et al. [12] proposed the addition of a physically

    consistent vorticity confinement force that injects small scale turbulent details back into the

    velocity field. They also used a physically-based photon map renderer to produce highly

    detailed and realistic animations of smoke. This model is considered to be the state of the

    art top-down model for smoke simulation.

    1.1.3 Bottom-up Methods

    Recently, bottom-up approaches have been introduced and consist of the Lattice Gas Cel-

    lular Automata (LGCA) and the Lattice Boltzmann Method (LBM). The starting point of

    these approaches is a discrete microscopic model which by construction, yields the Navier-

    Stokes equations of fluid flow. LGCA consist of a discrete lattice in two or three dimensions.

    Fluid behavior is a self-organizing process that evolves according to microscopic collisions of

    particles. These collisions are defined so that, in the macroscopic limit, the fluid conserves

    mass and momentum. In LGCA, the collisions are described as boolean operations. This

    all-or-none nature of the collisions can give rise to statistical noise in the computed flows.

    The Lattice-Boltzmann Method remedies this problem by replacing the boolean operations

    with real-valued particle distributions that move along each link of the lattice. The LBM

    3

  • 1.2. OBJECTIVES

    updates these ddistributions at each node based on two simple and local rules: collision

    and propagation. Collision describes the redistribution of particle packets at each node.

    Propagation describes the motion of the particle packets to the nearest neighbors along the

    velocity directions. Macroscopic quantities such as density and velocity are calculated as

    ensemble averages from the packet distributions. A significant advantage that the LBM has

    over the top-down approaches is its simplicity. Computation of the LBM consists of inex-

    pensive addition, subtraction and multiplication operations. Furthermore, these operations

    are performed locally which can potentially improve calculation speed by parallelization.

    Both LGCA and the LBM have recently been introduced to computer graphics as an

    alternative to the top-down CFD based techniques. Dobashi et al. [8] have used LGCA

    to produce realistic animations of clouds. The LBM has been used successfully to com-

    pute velocity fields for the purpose of fire simulation [29], creating wind fields [30] and the

    simulation of gaseous phenomena [32].

    The LBM based simulation of gaseous phenomena [32] is largely aimed at producing

    real-time fluid effects. For this reason, the authors have used relatively low resolution grids

    which are unable to simulate small scale turbulent details. Real-time computation speed is

    achieved by texture hardware acceleration which is readily available in modern GPUs. Small

    scale turbulent details are added by employing high resolution textures which attempt to add

    the vortices and swirls that are characteristic of smoke. These textures are then rendered

    by texture mapping hardware available in the GPU. Even though this method achieves real-

    time computation speeds, the low resolution lattices and texture mapping greatly limit its

    visual realism.

    1.2 Objectives

    The focus of this thesis is the improvement of the LBM used in [32] to simulate smoke. The

    goal is to incorporate sufficient detail in the model so that the resulting simulation possesses

    a level of visual realism that is qualitatively comparable to the top-down approach of Fedkiw

    et al. [12]. In particular, the following three aspects will be considered.

    1. Lattice Geometry

    Wei et al. [32] use the D3Q19 lattice which is a three dimensional lattice consisting

    of 19 discrete velocity vectors. According to the authors, this lattice structure is

    4

  • 1.3. EVALUATION CRITERIA

    a compromise between computational efficiency and reliability. A denser lattice with

    more velocity vectors will be better able to simulate the effects of a continuous velocity

    field. We hope to improve their results by incorporating the D3Q27 lattice.

    2. Small Scale Detail

    Real smoke swirls and curls in air because of the vorticity of the flow field. Coarse CG

    grids and the even coarser lattices in the LBM are unable to capture these small scale

    details. The LBM can be improved by including a vorticity confinement force similar

    to the one proposed by Fedkiw et al. [12].

    3. Physically-Based Rendering

    Since our goal is visual realism, it is important that the rendering algorithm takes

    into account, the physical interaction of light with smoke. We will therefore employ a

    photon map based renderer so that the resulting animation sequences are as realistic

    as possible.

    1.3 Evaluation Criteria

    The top-down approach described in [12] is considered to be the best technique for the simu-

    lation of smoke. In order to evaluate the effectiveness of our improved LBM, we will compare

    and contrast it with this top-down approach. For this purpose, the simulation technique

    outlined in [12] will be implemented so that it can be used as a basis for comparison.

    Since the top-down and bottom-up approaches differ only in the first stage of the simu-

    lation, i.e the stage that solves the NS equations, we shall use the same rendering algorithm

    for both methods. Our evaluation consists of a qualitative comparison of the visual realism

    of the two different approaches. We hope that our model will be simpler to implement, will

    be highly comparable to the top-down approach and will produce results with a similar or

    greater level of visual realism.

    1.4 Thesis Organization

    The remainder of this thesis is organized as follows. In chapter 2, we describe the top-down

    model in detail and discuss how the equations of fluid flow can be used to simulate the

    5

  • 1.4. THESIS ORGANIZATION

    dynamics of smoke. Chapter 3 is devoted to a detailed discussion of the bottom-up Lattice-

    Boltzmann method. Chapter 4 describes some implementation specific details pertinent to

    our evaluation system. In particular, it describes the photon-map algorithm used. Results

    are provided in chapter 5 while the concluding remarks are presented in chapter 6.

    6

  • Chapter 2

    Top-down Model

    At the microscopic level, smoke is a particulate matter that consists of tiny solid particles

    suspended in a gas such as air. The concentration of these particles is described by a density

    field and their motion is dependent on the motion of the gas that they are suspended in. As

    the gas flows, particles of smoke are hurled along the flow, a process known as advection.

    The motion of the smoke particles in turn influences the motion of the gas, giving rise

    to a complex smoke-air dynamical system. A visually realistic simulation must take into

    consideration, the dynamics of fluid flow as well as the interaction of smoke with air. In this

    chapter, we shall take a look at the CFD based top-down model that attempts to capture

    this complex dynamics of smoke [12].

    2.1 Fluid Flow

    Fluid dynamics is a rich and well-established field and numerous journals and books are

    dedicated to it (see e.g [5]). The flow of a Newtonian fluid is described by the Navier-Stokes

    (NS) equations which characterize the dynamics in terms of macroscopic fluid properties

    such as density, viscosity, velocity and pressure. Like other classical dynamical systems,

    these equations are based on conservation laws namely, the conservation of mass and the

    conservation of momentum. The law of conservation of mass states that mass is neither

    created nor destroyed during the process of fluid flow. The law of conservation of momentum

    is nothing but Newton’s second law of motion and states that the change in momentum in

    any portion of the fluid is proportional to the applied forces.

    7

  • 2.1. FLUID FLOW

    2.1.1 Assumptions

    The NS equations describe the motion of a general class of fluids. For the purpose of smoke

    simulation, the fluid we are concerned with is air. There are certain assumptions that we

    can make regarding air that will enable us to simplify the equations. In particular, we

    assume that the fluid velocity is well below the speed of sound. Under this assumption,

    compressibility of the fluid becomes negligible allowing us to treat air as a constant density

    fluid. Also, we shall assume that the fluid has negligible viscosity, i.e it is inviscid .

    2.1.2 Euler equations

    When the fluid is inviscid and incompressible, the NS equations reduce to the incompressible

    Euler equations , which are:

    ∇ · u = 0 (2.1)∂u

    ∂t= −(u ·∇)u−∇p + G (2.2)

    In the above equations, u is the velocity of the fluid in two or three dimensions, p is its

    pressure and G accounts for external body forces acting on the fluid. All of these quantities

    are in general time-dependent.

    Equation (2.1) is a mathematical formulation of the principle of conservation of mass.

    It states that the fluid velocity is solenoidal (divergence-free) at all times. The solenoidal

    nature of the velocity field ensures that there is no change in the density of the fluid within

    any infinitesimal volume. Equation (2.2) is a restatement of the principle of conservation

    of momentum. The interested reader is referred to [5] for the derivation of these equations.

    Note that the density of the fluid does not explicitly appear in the equations. Since the

    fluid is incompressible, the constant mass density is taken to be one.

    In order to completely specify the dynamics of the fluid, we also need to supplement

    the Euler equations with initial and boundary conditions. Let us suppose that the above

    equations are defined on the domain Ω ⊂ Rd, d ∈ {2, 3}. The fluid velocity and pressureas well as the external body forces are given by the time-dependent real valued functions

    u : Ω × R+ → Rd, p : Ω × R+ → R and G : Ω × R+ → Rd respectively. These functionssatisfy the Euler equations alongwith the initial condition

    u(x, 0) = u0, x ∈ Ω (2.3)

    8

  • 2.2. EXTERNAL FORCES

    and the boundary condition

    u(x, t) · n̂ = 0, x ∈ ∂Ω, t ∈ R+ (2.4)

    where u0 is a given functions,∂Ω ⊂ Rd is the boundary of the domain Ω and n̂ is the unitoutward normal to the boundary. Equation (2.4) is a a natural boundary condition for the

    Euler equations in the sense that it guarantees that the problem is well-posed. Physically,

    it corresponds to the scenario that the fluid is not allowed to leak through the boundary.

    However, the fluid is free to move tangential to the boundary. For this reason, this boundary

    condition is also sometimes known as the free-slip boundary condition.

    2.1.3 Advection of Smoke

    We assume that smoke is injected into the fluid as a non-reactive substance that is advected

    by the flow. The density and temperature of the smoke are given by the scalar fields

    P (x, y, z, t) and T (x, y, z, t) respectively. The motion of these two scalar fields is governed

    by the advection-diffusion equation:

    ∂P

    ∂t= −u ·∇P (2.5)

    ∂T

    ∂t= −u ·∇T (2.6)

    Another simplification that has been incorporated into the model is that the diffusion

    term is set to zero in the above equations. Since the smoke particles are much bigger as

    compared to the molecules of air, their diffusive behavior can be ignored. The model also

    assumes that heat flow is described entirely by advection (equation 2.6). Even though

    this assumption is not physically sound, it is adequate for our purposes since we are more

    interested in a visual simulation rather than a physical one.

    2.2 External Forces

    As smoke moves through air, it interacts with it causing the flow to change. Hot smoke is

    buoyant and tends to rise while heavy smoke tends to fall due to gravity. In reality, this

    behavior is quite complex. It is not just the smoke exerting a force on the fluid, the fluid,

    by virtue of its pressure is also exerting a force on the smoke. Fedkiw et al. ( [12]) have

    9

  • 2.2. EXTERNAL FORCES

    used a simple linear equation to model this behavior as an external force acting on the fluid.

    Their results show that a linear model gives convincing results. They have also proposed

    the addition of a vorticity confinement force that attempts to preserve small scale details.

    2.2.1 Buoyancy

    Simply stated, the force of buoyancy used in this model is proportional to the temperature

    and density of smoke, two quantities that are treated as being mutually independent. This

    can be translated into the following linear equation:

    fbuoy = [−αρ + β (T − Tamb)] k̂ (2.7)

    Here, k̂ is the unit vector that points in the upward direction, Tamb is the temperature

    of the ambient air and α and β are proportionality constants that control the amount of

    upward or downward force to exert. This is a plausible model since when T = Tamb and

    ρ = 0, the force exerted is zero, what we would expect when there is no smoke present.

    2.2.2 Vorticity Confinement

    In fluid mechanics, vorticity is defined as the curl of the velocity field (∇×u) and describesthe rotational behavior of a fluid. A flow with a high degree of vorticity is said to be

    turbulent. Anyone who has carefully observed smoke in air knows that the flow is turbulent

    and contains fine vortex structures. As the smoke rises, it swirls and curls because of the

    vorticity of the flow. A good model for smoke simulation should attempt to preserve the

    turbulent structures. Unfortunately, the grids used in Computer Graphics simulations are

    usually coarsely sampled. Any vorticity that may be initially present in the flow decays

    over time as a result of numerical dissipation. In order to preserve vortex structures, very

    high resolution grids must be used so that the discrete solution to the fluid flow equations

    is close to the continuous one. This, however, is not a practical solution as we would like to

    maintain the efficiency of the simulation.

    Fedkiw et al. [12] have remedied this problem by borrowing from CFD, a technique

    known as vorticity confinement. It attempts to locate areas in the flow where small scale

    vorticity features should be generated. The vorticity of an incompressible flow is given by:

    ω = ∇× u (2.8)

    10

  • 2.2. EXTERNAL FORCES

    The magnitude of the vorticity field gives a measure of the amount of turbulence present

    in the flow. From this field, normalized vorticity location vectors N , that point from lower

    vorticity concentrations to higher vorticity concentrations, are computed.

    η = ∇ ||ω|| (2.9)

    N =η

    ||η|| (2.10)

    The vorticity confinement force is finally computed as

    f conf = ǫh (N × ω) (2.11)

    The positive parameter ǫ is used to control the amount of the confinement force to add

    and h is the spatial discretization of the grid. As the resolution of the grid is increased, h

    becomes less guaranteeing that the confinement force would be zero when the resolution is

    infinite, thus giving the correct solution.

    So, in summary, the top-down model attempts to simulate the dymanics of smoke by solving

    the incompressible Euler equations. These equations assume that air is an inviscid and

    incompressible fluid. Smoke is present in air as a particulate substance that is simply

    advected by the flow. The model also incorporates a temperature field that is advected in a

    similar manner. The interaction of smoke with air is modelled as a simple linear body force

    that is added externally to the euler equations. The problem of numerical dissipation due

    to coarse discretizations is solved by employing a physically consistent vorticity confinement

    force. We have not described how the euler equations are discretized and numerically solved,

    nor have we talked about the interaction of light with smoke. These two topics are the

    subject of chapter 4.

    11

  • Chapter 3

    The Lattice-Boltzmann Model

    In contrast to the top-down Computational Fluid Dynamics models that describe macro-

    scopic fluid properties, the Lattice-Boltzmann Model (LBM) is a bottom-up approach that

    describes the behavior of a fluid at a mesoscopic level. At the microscopic level, fluid flow

    is described in terms of molecular dynamics. The particles of a fluid move about freely and

    interact with each other giving rise to properties such as velocity, vorticity and pressure

    that are observed at macroscopic scales. It is quite a challenging task to model the complex

    molecular interactions that take place at microscopic scales. Since most applications of fluid

    flow in Computer Graphics are concerned with the average behavior of a fluid, top-down

    models are usually preferred over the microscopic ones.

    Mesoscopic models such as the LBM lie in between the microscopic and the macroscopic

    levels. They attempt to describe the behavior of a fluid by modelling the evolution of

    averaged distributions of particles. This has the advantage that the complex motion of

    individual fluid particles is replaced with averaged quantities that are much simpler to deal

    with and yet accurately predict the macroscopic behavior of the fluid. As compared to

    top-down models, the LBM has the advantage that the evolution rules are linear and local

    thus making the method simpler and faster. The LBM is therefore a well-suited candidate

    for solving fluid flow problems in Computer Graphics.

    This chapter is intended to be a self-contained introduction to the Lattice-Boltzmann

    Model as it pertains to the problem of visual simulation of smoke. A detailed derivation

    of the model and the recovery of the incompressible Navier-Stokes equations is beyond

    the scope of this thesis. Where appropriate, references to more thorough treatments shall

    be provided for the sake of the interested reader. Since the LBM is a relatively recent

    12

  • 3.1. THE BOLTZMANN EQUATION

    contribution to CFD, it has has its limitations which we shall point out as necessary.

    3.1 The Boltzmann Equation

    As the name suggests, the LBM has its roots in the kinetic theory of gases where distribution

    functions such as the Maxwell-Boltzmann distribution ( [31]) play a key role. Consider a

    domain Ω ⊂ Rd where d ∈ {2, 3}. A single species distribution function f(x,v, t) is afunction of the form

    f : Ω× Rd × R+ → R+ (3.1)

    and gives the continuous time-dependent probability of finding a particle within an in-

    finitesimal volume located at x and having velocity v. It is assumed that all particles are

    identical and have the same mass which is chosen to be unity for the sake of simplicity.

    The kinetic theory of gases deals with the time evolution of such distribution functions and

    relates macroscopic quantities such as fluid density, velocity and pressure to the underlying

    microscopic particle distributions.

    Under constant temperature conditions and when no external forces are acting on the

    fluid, the distribution function evolves according to the Boltzmann Equation

    ∂f

    ∂t+ v ·∇f = Q(f, f) (3.2)

    Here v is the velocity of a particle at the location x and at time t. The gradient term ∇f

    is the spatial gradient of f given by:

    ∇f =d∑

    i=1

    ∂f

    ∂xi(3.3)

    The Boltzmann Equation (3.2) might seem daunting at first glance but is quite intuitive

    when one considers the underlying particle dynamics. Essentially, there are two processes

    that govern the evolution of the distribution function namely collision and propagation.

    The term Q(f, f) on the right hand side term of (3.2) is a two particle collision term and

    models the way in which the distribution changes as a result of two particles colliding at

    the location x at time t. The incoming velocities {v,v1} of the two particles are changed tothe outgoing velocities {v′,v′

    1} as a result of the collision thereby causing an overall change

    in the distribution function.

    The term v·∇f on the left side of (3.2) says that the the distribution function at the location

    13

  • 3.1. THE BOLTZMANN EQUATION

    x changes due to the propagation of particles. Within an infinitessimal time interval dt,

    a particle at the location x having velocity v propagates to the new location x + vdt and

    hence changes the overall distribution function.

    The behavior of the fluid at the macroscopic level can be recovered by ensemble averaging

    the underlying particle dynamics. In particular, the fluid density at the location x at time

    t is given by averaging the distribution function over the entire microscopic velocity space

    ρ(x, t) =

    ∫f(x,v, t)dv (3.4)

    whereas the fluid velocity is recovered through the first velocity moment of the distribution

    function.

    u(x, t) =1

    ρ

    ∫vf(x,v, t)dv (3.5)

    The Boltzmann Equation therefore completey describes the dynamics of a fluid both

    at the microscopic as well as the macroscopic scales. In order to numerically solve for

    the distribution function, the equation is discretized in the spatial, velocity and temporal

    domains and an appropriate choice for the collision term is made.

    3.1.1 The BGK Approximation

    The collision term in the countinuous Boltzmann equation (3.2) in general has a complex

    integral form. In most applications of Kinetic theory to fluid dynamics, the collision integral

    is approximated by simpler expressions. One such approximation is the BGK approximation

    proposed by Bhatnagar, Gross and Krook and incorporated into the so-called Lattice BGK

    models by Qian et al. [25].

    The BGK approximation is motivated by the fact that the large amount of detail of the

    two-particle collision integral Q(f, f) does not significantly influence the values of quantities

    at the macroscopic scale. Consequently, the two-particle term Q(f, f) is replaced by the

    simpler term J(f) which models the affect of collisions as a relaxation of the distribution

    towards a Maxwellian equilibrium distribution f eq(x,v, t):

    J(f) =1

    τ[f eq(x,v, t)− f(x,v, t)] (3.6)

    The parameter τ has dimensions of time and controls the frequency with which the distri-

    bution function relaxes to equilibrium. The BGK approximation is also sometimes referred

    to as the single time relaxation approximation and is quite popular in the LBM literature.

    14

  • 3.2. THE LATTICE-BOLTZMANN EQUATION

    Although there are other forms of the collision integral in use, our present work employs

    the BGK approximation and we shall not be making use of any other approximations of the

    collision term. Lattice BGK models are suitable for use in Computer Graphics since they

    satisfy the incompressible Navier-Stokes equations within appropriate macroscopic limits.

    3.2 The Lattice-Boltzmann Equation

    In computational applications, a discrete form of the continuous Boltzmann equation (3.2)

    is used. Since the contiuous distribution function depends on space, velocity and time, the

    velocity space is first truncated to a discrete lattice leading to the discrete Boltzmann equa-

    tion which is then spatially and temporally discretized giving rise to the Lattice Boltzmann

    Equation.

    3.2.1 Discrete Boltzmann Equation

    In the continuous version of the Boltzmann equation, the velocity space of a particle (the

    space of all allowable velocities that a particle can have) is also continuous. The first

    step towards a discrete approximation to the Boltzmann equation is a truncation of the

    continuous velocity space to a finite set of velocities {ci} (i ∈ {0, 1, 2, ..., n − 1}). Thismeans that a particle located at x that was previously allowed to move about freely with

    any velocity v is now restricted to have one of the n velocities ci. With the truncated

    velocity space, the distribution function reduces from a function that describes distributions

    over arbitrarily many velocities (f(x,v, t)) to a function that describes distributions over a

    finite lattice (fi(x, t)). The Boltzmann equation with the BGK approximation becomes the

    discrete Boltzmann equation given by:

    ∂fi∂t

    + ci ·∇fi =1

    τ(f eqi − fi) (3.7)

    3.2.2 LBGK Equation

    The discrete Boltzmann equation (3.7) is still not suitable for computational use since it is

    continuous is space and time. When this equation is discretized spatially and temporally, the

    domain spacing ∆x and the time step ∆t are chosen such that the lattice velocity ci =∆x∆t .

    This ensures that particles located at the lattice location x move within a time step ∆t to

    a neighboring location x + ci∆t. With this discretization scheme, the discrete Boltzmann

    15

  • 3.2. THE LATTICE-BOLTZMANN EQUATION

    equation with the BGK approximation (3.7) becomes the lattice BGK equation:

    fi(x + ci∆t, t + ∆t)− fi(x, t) =1

    τ(f eqi (x, t)− fi(x, t)) (3.8)

    A simpler interpretation of this equation over a two or three dimensional discrete lattice

    is as follows:

    1. Collision

    At time t, particles at lattice location x collide with each other and in the process,

    change the distribution function to f∗i (x, t) where:

    f∗i (x, t) = fi(x, t) +1

    τ(f eqi (x, t)− fi(x, t)) (3.9)

    The equilibrium particle distribution f eqi (x, t) is actually an implicit function of space

    and time. Its value depends on the fluid density and velocity and is of the form

    f eqi (ρ(x, t),u(x, t)). It is computed by taking the velocity moments of the Maxwell-

    Boltzmann distribution and equating it with the respective moments of the equilib-

    rium distribution f eqi (ρ,u) [16]. For certain two and three dimensional lattices, this

    procedure results in closed form expressions for the equilibrium particle distribution

    in terms of the fluid density and velocity (section 3.3). This particular form of the

    collision step also ensures that mass and momentum are locally conserved.

    2. Propagation

    After the collision step, the new distribution values f∗i (x, t) simply propagate to their

    neighboring lattice locations within a time step ∆t. More formally:

    fi(x + ci∆t, t + ∆t) = f∗

    i (x, t) (3.10)

    This step does not alter the distributions as they are propagating. Therefore, by

    construction, mass is conserved.

    Equations (3.9) and (3.10) are also sometimes written in a combined form eliminating the

    intermediate post-collisional distribution function f∗i (x, t).

    fi(x + ci∆t, t + ∆t) = (1−1

    τ)fi(x, t) +

    1

    τf eqi (x, t) (3.11)

    It is worth pointing out that the collision and propagation rules are simple and linear.

    The collision step at a particular lattice site is entirely local and does not need information

    16

  • 3.2. THE LATTICE-BOLTZMANN EQUATION

    from any other lattice sites. During the propagation step, distribution values propagate

    to the lattice neighbors. This step therefore updates the distribution function at atmost n

    lattice sites. Owing to the simplicity and locality of these rules, the LBM is readily amenable

    to parallelization.

    3.2.3 Macroscopic Quantities

    Analogous to the continuous case, the density and velocity of the fluid are given as ensemble

    averages of the distribution function. Integrals over the velocity space (equations (3.4) and

    (3.5))become summations over the truncated velocities:

    ρ(x, t) =

    n−1∑

    i=0

    fi(x, t) (3.12)

    u(x, t) =1

    ρ

    n−1∑

    i=0

    fi(x, t)ci (3.13)

    3.2.4 Initial and Boundary Conditions

    Since the variables of interest are the macroscopic quantities, the LBM needs be able to

    handle initial and boundary conditions that are prescribed in terms of the fluid density and

    velocity. The general approach for handling initial conditions is to set the initial distribution

    function f0i (x) equal to the Maxwellian distribution that satisfies the initial fluid density

    ρ0(x) and the initial fluid velocity u0(x).

    f0i (x) = feqi (ρ0(x),u0(x)), x ∈ Ω (3.14)

    Starting from an initial particle distribution over the lattice, the system evolves accord-

    ing to the collision and propagation rules defined by equations (3.9) and (3.10). While the

    collision rule is well-defined for all lattice sites, the propagation rule is not well-defined for

    lattice sites that have one or more neighbors outside the domain Ω. In order to satisfy

    Dirichlet boundary conditions (fluid velocity ub specified on the boundary ∂Ω), the prop-

    agation rule has to be modified at lattice sites close to the boundary so that the velocity

    obtained as a result of averaging the propagated distributions equals the Dirichlet boundary

    value ub. This can be a hard problem for boundaries with complex geometry but for some

    simple boundaries, a straightforward bounce back scheme has been proposed that is capable

    of satisfying a Dirichlet boundary condition up to a second order accuracy [2, 18]. Since

    17

  • 3.2. THE LATTICE-BOLTZMANN EQUATION

    our domains are simple, we have made use of the bounce-back scheme to satisfy a no-slip

    boundary condition.

    3.2.5 Advection of Scalar Fields

    Our discussion so far has dealt with fluids in general. In order to make use of the LBM for

    the purpose of simulating smoke, we also need a way to transport scalar quantities that are

    injected into the fluid. This can be achieved in one of two different ways.

    1. Bottom-Up

    For a scalar field that is advected by the fluid, we can define a distribution function

    similar to the fluid distribution function. This distribution function is then propa-

    gated between different lattice sites in a manner akin to the propagation step of the

    LBM. The scalar value at each node is then recovered by an ensemble average of the

    distribution function corresponding to the scalar field. This procedure is known as the

    Moment-Propagation Method and has been used in the LBM community for solving

    the scalar transport problem [19,21].

    As shown in [21], the moment propagation method approximates to second order, the

    advection-diffusion equation

    ∂S

    ∂t= −u ·∇S + µ∇2S (3.15)

    where S(x, t) is the scalar field being transported and µ is the coefficient of diffusion.

    Compare these equation with the temperature and density advection equations (2.5

    and 2.6). The equations are the same in the limit µ→ 0.

    2. Top-Down

    The top-down approach solves the advection equation directly using a semi-Lagrangian

    integration scheme. Once the velocity field u has been computed by the LBM, it can

    be used to advect scalar quantities such as smoke density and temperature. This

    method is direct and does not make use of the underlying distribution functions.

    We prefer to employ the more direct top-down approach for the following reasons. There

    is extra computation overhead involved in keeping track of additional distribution functions

    in the moment propagation method. It is also not possible to completely eliminate the

    diffusion of scalar quantities in the moment propagation method. As the diffusion coefficient

    18

  • 3.2. THE LATTICE-BOLTZMANN EQUATION

    is lowered, the method becomes more and more unstable giving rise to negative values of

    the scalar field P . On the other hand, a direct semi-Lagrangian solution of the advection

    equation does not suffer from these problems and is unconditionally stable. A direct solution

    will also ensure that any differences in the visual simulation of smoke between the top down

    model (chapter 2) and the LBM are entirely due to the stages that solve for the unknown

    fluid velocity. This will further ensure a more faithful comparison between the two models.

    3.2.6 External Forces

    The scalar fields injected into the fluid exert forces on it thus causing the flow to change.

    The buyonacy of hot air pushes air upwards while heavy smoke tends to fall due to gravity.

    Small scale details are added into the fluid in the form of a vorticity confinement force that

    cause the flow to swirl. Wei et al. [32] have used a simple and linear temperature field

    to model the effect of a buoyancy force acting on the display primitives. Their force term

    only changes the motion of the display primitives, it does not affect the underlying fluid

    particle distributions or the flow field. This approach might be sufficient for an interactive

    simulation on graphics hardware. However, it is inadequate for our purposes since our aim

    is to produce visually realistic simulations of smoke. For this reason, we need to incorporate

    the effect of external forces into the LBM.

    When there are external forces acting on a fluid, a new force term appears in the Boltz-

    mann equation (3.2). The external forces do not alter the collision operator Q(f, f) but

    they do change the distribution function such that particles tend to get more concentrated

    in the direction of the force. This redistribution must also satisfy the laws of conservation

    of mass and momentum so that the appropriate macroscopic equations of fluid flow can be

    receovered.

    Various methods have been proposed for incorporating external forces into the LBM

    (see e.g [3, 33]). Researchers in the LBM community seem to favor those methods that are

    second order accurate, satisy the Navier-Stokes equations and don’t require a modification

    of the ensemble averages for fluid density and velocity (equations (3.12) and (3.13)). Since

    these factors are also in line with our goals, we shall employ the force model used by Junk

    et al. [18]. According to this model, an external force term G(x, t) influences the collision

    step as follows:

    f∗i (x, t) = fi(x, t) +1

    τ(f eqi (x, t)− fi(x, t)) + 3h3Wici ·G(x, t) (3.16)

    19

  • 3.3. TWO AND THREE DIMENSIONAL LATTICES

    The factor h is related to the lattice spacing and the time step (∆t = h2 = ∆x2). This

    particular relation between the space and time is necessary to obtain convergence towards

    the incompressible Navier-Stokes equations. The factor Wi is a lattice dependent quantity

    that is also used in the computation of the equilibrium distribution function. It will be

    introduced in section 3.3.3.

    The propagation step remains unchanged, i.e after collision and forcing, the new distribution

    values f∗i propagate along the lattice velocities ci to their respective neighboring lattice sites.

    The fluid density and velocity are still given by the ensemble equations (3.12) and (3.13).

    3.3 Two and Three Dimensional Lattices

    The notation DdQn is usually used to refer to LBM lattices where d is the spatial dimension

    and n is the number of velocities in the truncated velocity space. The arrangement of the

    lattice velocities must respect certain isotropy and symmetry requirements [31], so that the

    lattice can yield the Navier-Stokes equations in the macroscopic limit. In practice, the D2Q7

    and the D2Q9 lattices are commonly used in two dimensions and the D3Q15, D3Q19 and

    D3Q27 lattices are used in three dimensions.

    In the remainder of this thesis, the base unit for lattice spacing and the time step are

    taken to be unity (∆x = 1,∆t = 1). This is merely a notational convenience, the lattice

    spacing and the time step can be scaled to any appropriate units.

    3.3.1 D2Q7 and D2Q9 Lattices

    The lattice sites in the D2Q7 lattice are arranged in a triangular fashion giving the lattice

    hexagonal symmetry. Each lattice site (or node) is connected to six other nodes that are

    arranged in a regular hexagon around the node (Fig. 3.1). The lattice velocities are:

    c0 = (0, 0)

    ci =

    (cos

    2πi

    6, sin

    2πi

    6

    )i ∈ {1, ..., 6}

    c0 corresponds to the distribution of particles that are at rest at the node while the other

    velocities correspond to particles moving with unit speed in six different directions around

    the node. The D2Q7 lattice is included in our discussion for the sake of completeness. Our

    two dimensional simulations are performed on the D2Q9 lattice which has the geometry of

    20

  • 3.3. TWO AND THREE DIMENSIONAL LATTICES

    a regular cartesian grid (Fig. 3.1). Each node has a rest velocity c0 and is connected to eight

    nearest neighbors along the remaining eight lattice velocities. The nine lattice velocities are

    given by:

    c0 = (0, 0) (3.17)

    ci =

    (cos

    2π(i − 1)8

    , sin2π(i − 1)

    8

    )i ∈ {1, 3, 5, 7} (3.18)

    ci =√

    2

    (cos

    2π(i− 1)8

    , sin2π(i− 1)

    8

    )i ∈ {2, 4, 6, 8} (3.19)

    In comparison to the D2Q7 lattice, D2Q9 is a multispeed lattice. Particles moving horizon-

    tally or vertically have unit speed whereas particles moving diagonally travel with a speed

    of√

    2.

    b

    c0

    bb

    b

    b b

    b

    c1c2

    c3

    c4 c5

    c6

    (a) The D2Q7 Lattice

    b

    c0b

    bbb

    b

    b b b

    c1

    c2c3c4

    c5

    c6 c7 c8

    (b) The D2Q9 Lattice

    Figure 3.1: Two dimensional lattices. The arrows indicate the different lattice velocities.Both lattices have a rest velocity c0. (a) The D2Q7 lattice has hexagonal symmetry. Eachnode has six neighbors. (b) The D2Q9 lattice has eight neighbors and possesses rectangularsymmetry. It is geometrically similar to a regular cartesian grid.

    3.3.2 D3Q15, D3Q19 and D3Q27 Lattices

    The three dimensional lattices D3Q15, D3Q19 and D3Q27 have cubic symmetry and there-

    fore have the same geometry as a regular three dimensional cartesian grid. On a 3D grid,

    the velocity space can be truncated to four different speeds, each speed defining its own

    sublattice (Fig. 3.2).

    21

  • 3.3. TWO AND THREE DIMENSIONAL LATTICES

    • Sublattice 0This sublattice consists of the zero velocity particles (0, 0, 0) that stay at the lattice

    site during the propagation step.

    • Sublattice 1This consists of particles moving with unit speed given by the 6 nearest neighbors

    (±1, 0, 0), (0,±1, 0) and (0, 0,±1).

    • Sublattice 2This is formed by the 12 second-nearest neighbors given by (±1,±1, 0), (±1, 0,±1)and (0,±1,±1). Particles in this sublattice move with a speed of

    √2.

    • Sublattice 3Finally sublattice 3 is composed of the 8 third-nearest neighbors given by (±1,±1,±1).This corresponds to particles moving with speed

    √3.

    The D3Q15 lattice is made up of sublattices 0, 1 and 3 having a total of (1 + 6 + 8)

    fifteen velocity directions. The D3Q19 lattice consists of sublattices 0, 1 and 2 having a

    total of (1 + 6 + 12) nineteen velocities. The D3Q27 lattice consists of all four sublattices

    and propagates distributions to all 26 neighbors of a node. As pointed out by Mei et al. [20],

    D3Q15 is the least isotropic and more vulnerable to numerical instabilities. D3Q19 is more

    efficient as compared to D3Q27 and has better stability than D3Q15. Although D3Q27

    is the most isotropic, it does not always give the best results. We shall not be making

    use of the D3Q15 lattice. Wei et al. [32] have favored the D3Q19 lattice for all their tests

    because of its computational efficiency. Since our aim is visual realism, we shall use both

    the D3Q19 and D3Q27 lattices in our simulations and compare the results in terms of their

    visual quality.

    3.3.3 Computing the Equilibrium Distributions

    In order to compute the equilibrium distribution of particles, it is assumed that particles

    relax towards a Maxwellian equilibrium which is a function of fluid density and velocity

    alone. It is derived by applying the maximum entropy principle under the constraints of

    mass and momentum conservation [16, 31]. For a multi-speed LBM lattice, this procedure

    22

  • 3.3. TWO AND THREE DIMENSIONAL LATTICES

    z

    y

    x

    b

    b

    b

    b

    b

    b

    b

    b

    b

    b

    b

    b

    b

    b

    b

    b

    b

    b

    b

    b

    b

    b

    b

    b

    b

    b

    b

    Figure 3.2: The four cubic sublattices. Sublattice 0 consists of the rest velocity and is shownas a black node in the center. Sublattice 1 consists of the 6 unit speed velocity vectors formedby the blue nodes. The 12 green nodes form the velocity vectors of sublattice 2 (speed

    √2)

    while the 8 red nodes form the velocity vectors of sublattice 3 (speed√

    3).

    yields the following expression for the equilibrium distribution function:

    f eqi (ρ,u) = ρWi

    [1 + 3ci · u +

    9

    2(ci · u)2 −

    3

    2u · u

    ](3.20)

    The coefficients Wi are obtained by taking the velocity moments of the continuous Maxwell-

    Boltzmann distribution and setting them equal to the corresponding discrete velocity mo-

    ments. For a multi-speed LBM lattice, particle distributions having the same speed have

    the same value of Wi. Equation (3.20) can be used to compute the equilibrium distributions

    for the lattices D2Q9, D3Q15, D3Q19 and D3Q27. The different values of the coefficients

    Wi are tabulated below along with the ordering of the velocity vectors ci.

    23

  • 3.4. LIMITATIONS

    Speed Velocity Vectors ci Wi0 0 4/91 1,3,5,7 1/9√2 2,4,6,8 1/36

    Table 3.1: Coefficients for the D2Q9 Lattice

    Speed Velocity Vectors ci Sublattice Wi0 0 0 2/91 1,. . . ,6 1 1/9√3 7,. . . ,14 3 1/72

    Table 3.2: Coefficients for the D3Q15 Lattice

    3.4 Limitations

    The Lattice Boltzmann Model with the BGK approximation imposes some limitations on

    the kinds of flows that can be accurately simulated. Even though the LBM is a second-order

    method and recovers the Navier-Stokes equations, it does so under some constraints.

    3.4.1 Solution to Navier-Stokes equations

    Through an analytical technique known as the Chapman-Enskog expansion [25, 31], it can

    be shown that the fluid density (3.12) and fluid velocity (3.13) obtained through the LBM

    solve the incompressible Navier-Stokes equations

    ∇ · u = 0 (3.21)∂u

    ∂t= −u ·∇u + ν∇2u−∇p + G (3.22)

    where ν is the viscosity of the fluid, p is the scalar pressure and G is an external body

    force. Note that the constant mass density of the fluid is taken to be unity and does

    not appear in the Navier-Stokes equations. The LBM on the other hand explicitly keeps

    track of the evolution of the mass density ρ as other quantities such as the equilibrium

    distribution function depend on it. The BGK approximation to the collision operator and

    the propagation rules of the LBM are designed to ensure that the density of the fluid does not

    deviate much from its initial value. The LBM therefore solves the Navier-Stokes equations

    24

  • 3.4. LIMITATIONS

    Speed Velocity Vectors ci Sublattice Wi0 0 0 1/31 1,. . . ,6 1 1/18√2 7,. . . ,18 2 1/36

    Table 3.3: Coefficients for the D3Q19 Lattice

    Speed Velocity Vectors ci Sublattice Wi0 0 0 8/271 1,. . . ,6 1 2/27√2 7,. . . ,18 2 1/54√3 19,. . . ,26 3 1/216

    Table 3.4: Coefficients for the D3Q27 Lattice

    in the incompressible limit. More formally, when the fluid speed |u| is sufficiently small ascompared to the speed of sound, the velocity field computed through the LBM converges to

    the velocity field that solves the incompressible Navier-Stokes equations. The incompressible

    limit is also sometimes known as the small Mach number limit and is forumalted as

    Ma :=|u|cs≪ 1 (3.23)

    where cs is the speed of sound of the lattice. For the D2Q9 lattice, cs = 1/√

    2 whereas for

    the 3D D3Q15, D3Q19 and D3Q27 lattices, cs = 1/√

    3 [20].

    3.4.2 Viscosity

    Since the LBM solves the Navier-Stokes equations in the incompressible limit, diffusion

    phenomena that give rise to viscosity cannot be ignored. The viscosity parameter ν appear-

    ing in equation (3.22) is related to the relaxation time scale τ that appears in the BGK

    approximation (3.6) as follows:

    ν =1

    3(τ − 1

    2) (3.24)

    Since the viscosity cannot be negative, τ must always be greater than 12 . This relationship

    between the relaxation time and the fluid viscosity gives the LBM the flexibility to simulate

    flows with varying degrees of turbulence. Highly viscous flows are in general less turbulent

    25

  • 3.4. LIMITATIONS

    than less viscous ones. The degree of turbulence in a flow is characterized by a dimensionless

    constant known as the Reynolds Number (Re := vsLν

    where vs is the average fluid speed, L

    is the characteristic length and ν is the viscosity). The Reynolds number of the flow can

    therefore be controlled by adjusting the relaxation time τ . Lattice Boltzmann models tend

    to be more stable at low Reynolds numbers thus limiting the degree of turbulence that can

    be achieved.

    3.4.3 Stability

    As a final remark, we would like to mention that the stability of Lattice Boltzmann methods

    is very much an active area of research (see e.g [1, 6]). Like any other numerical scheme,

    there is a certain region in parameter space where the LBM is stable. Stability decreases

    as we go closer to the boundary of the parameter space. As a rule of thumb, the LBM

    is stable as long as we are close to the incompressible limit (3.23). Increasing the fluid

    velocity or the magnitude of the external force decreases stability. Stability also decreses

    with increasing Reynolds numbers. The structure of the lattice also affects stability in the

    sense that more isotropic lattices tend to be more stable than less isotropic ones for the

    same set of parameter values.

    26

  • Chapter 4

    Implementation

    The Euler equations are usually solved using finite difference, finite element or finite volume

    methods. In most applications of fluid dynamics in Computer Graphics, finite difference

    methods are largely used [12, 14, 26]. This particular discretization scheme is inline with

    our goals since the spatial discretization of the discrete Boltzmann equation (3.7) is also

    based on finite differences. We shall therefore conduct our simulations on regular two and

    three dimensional grids where the grid spacing h is the same in all directions. This also

    ensures that, within the domain of interest Ω, there is a one-to-one correspondence between

    a Cartesian grid point and an LBM lattice node.

    Our domain Ω is taken to be a rectangle in two dimensions and a hexhadron in three

    dimensions. The following description applies to a square in 2D and a cube in 3D but can

    easily be generalized to axis aligned domains.

    The location of a grid point x is given by x := (xi, yj) = (ih, jh) in two dimensions and

    x := (xi, yj, zk) = (ih, jh, kh) in three dimensions where h is the spacing in each direction

    and i, j, k ∈ {1, 2, . . . ,M − 1,M}. The boundary ∂Ω is located halfway between the interiorgrid points defined by i, j, k ∈ {1, 2, . . . ,M − 1,M} and the exterior points defined byi, j, k = 0 and i, j, k = M +1. It corresponds to the four sides of a square in two dimensions

    and the six faces of a cube in three dimensions (Figs. 4.2(a) and 4.2(b)). As we shall see

    later, a halfway boundary is a useful construct and simplifies the handling of boundary

    conditions in numerical methods. The exterior points are actually outside the domain and

    are not included in the simulations. They are also sometimes referred to as dry points. The

    interior therefore has a resolution of M2 in 2D and M3 in 3D. We denote the total number

    of interior grid points as N irrespective of the dimensionality. Quantities such as velocity

    27

  • 4.1. THE METHOD OF PROJECTION

    and smoke density are defined at the grid points and interpolation is used to approximate

    their values at non-grid locations.

    b b b b

    b b b b

    b b b b

    b b b b

    bc

    bc

    bc

    bc

    bc

    bc

    bc bc bc bc bc bcbc

    bc

    bc

    bc

    bc

    bcbc bc bc bc bc bc

    (a) 2D domain (b) 3D domain

    Figure 4.1: A schematic representation of the simulation domains and their boundaries.The interior points are indicated in blue, the dry points are indicated by dashed lines. Theboundary resides halfway between the interior points and the dry points.

    In this chapter, we describe the top-down method of projection that is commonly used

    in Computer Graphics to solve fluid flow problems. An important step in this method is

    the solution of a Poisson problem. Computer Graphics literature often tends to gloss over

    this step and we have tried to provide a detailed analysis of the problem. The outputs of

    both the top-down and bottom-up procedures consist of two and three dimensional smoke

    density grids. While displaying 2D grids is straightforward, it is not a trivial task to obtain

    realistic 2D projections from 3D smoke density grids. In the latter part of this chapter, we

    describe how photon-mapping can be used to render 3D smoke datasets.

    4.1 The Method of Projection

    One of the popular numerical methods for solving the Euler equations as well as the incom-

    pressible Navier-Stokes equations is based on the method of projection that was proposed

    by Chorin in 1967 [4]. At the core of this method is the Helmholtz-Hodge Decomposition

    Theorem which states that:

    Helmholtz-Hodge Decomposition Theorem. Let Ω be a region in space with a smooth

    28

  • 4.1. THE METHOD OF PROJECTION

    boundary ∂Ω. A vector field w on Ω can be uniquely decomposed in the form

    w = u + ∇p (4.1)

    where u has zero divergence and is parallel to ∂Ω; i.e u · n̂ = 0 on ∂Ω.

    We shall not prove this theorem here and refer the reader to [5] for an elegant proof. It

    is a very powerful theorem in the area of vector calculus and is also sometimes known as

    the fundamental theorem of vector calculus. It allows any smooth vector field to be broken

    up into its constituents, a solenoidal vector field that is tangential to the boundary and a

    scalar function p.

    Let us denote the operator that orthogonally projects a vector field w onto its divergence-free

    part as P. If w is as given in (4.1), then the operator P acts on w as follows:

    Pw = u, (4.2)

    where u is divergence-free and parallel to ∂Ω. Also, given a vector field u that is divergence-

    free and parallel to ∂Ω, it projects onto itself, i.e.

    Pu = u. (4.3)

    Furthermore, if p is a scalar function that satisfies (4.1), then

    P(∇p) = 0. (4.4)

    The projection operator allows one to eliminate the pressure term from the momentum

    equation (2.2) yielding a partial differential equation that is easier to solve. Applying P to

    both sides of (2.2) gives

    P

    (∂u

    ∂t

    )= P [−(u ·∇)u−∇p + G] . (4.5)

    Since we are dealing with the incompressible Euler equations, the fluid velocity u is always

    divergence-free. If we further impose the boundary condition that u always remains parallel

    to the boundary ∂Ω, then (4.5) reduces to

    ∂u

    ∂t= P [−(u ·∇)u + G] , (4.6)

    owing to the facts that P(∂u∂t

    ) = ∂u∂t

    and P(∇p) = 0.

    29

  • 4.1. THE METHOD OF PROJECTION

    Equation (4.6) expresses the momentum equation in terms of the fluid velocity u alone

    and allows one to devise a method to solve for the unknown fluid velocity without having to

    factor the fluid pressure into the partial differential equation. Suppose that the fluid velocity

    is known at a time t and one is interested in finding the velocity at a later time t+∆t. One

    first solves for an intermediate velocity field w according to (4.6) and then projects it onto

    its divergence free part. The intermediate velocity field w satisfies the differential equation

    ∂w

    ∂t= −(w ·∇)w + G, (4.7)

    with the initial condition that w = u at time t. It is not necessarily divergence free and has

    to be projected according to (4.1) to obtain the divergence free velocity that is a solution

    to the Euler equations at time (t + ∆t).

    Let w(x, t + ∆t) be the velocity field that has been computed to satisfy (4.7). A

    divergence-free velocity field u(x, t + ∆t) is obtained from w by taking the divergence

    of both sides of (4.1),

    ∇ ·w = ∇ · u + ∇ ·∇p.

    Since u is divergence-free, this reduces to a Poisson equation for the pressure p.

    ∇2p = ∇ ·w. (4.8)

    Thus, applying the projection operator P to the intermediate velocity field w is tantamount

    to solving a Poisson equation for pressure. Once the pressure p has been computed, the

    divergence-free velocity field u(x, t + ∆t) is given by

    u = w −∇p. (4.9)

    4.1.1 A note on Boundary Conditions

    The Poisson equation for pressure (4.8) is an elliptic partial differential equation whose so-

    lution depends on the nature of boundary conditions. In most fluid dynamics problems,

    boundary conditions for the velocity field u are known and an appropriate boundary condi-

    tion for the pressure p is derived from them so that the velocity field computed through (4.9)

    satisfies the given boundary conditions. It is important to handle boundary conditions cor-

    rectly since solid boundaries often give rise to rotational and turbulent behavior.

    In our simulations, we have imposed the free-slip boundary condition (2.4) on u. As

    mentioned earlier, this is a natural boundary condition for Euler equations and ensures that

    30

  • 4.1. THE METHOD OF PROJECTION

    the fluid is not allowed to move orthogonal to the walls. The portion of the fluid in contact

    with the walls is free to move in a tangential direction. When the walls of the container are

    stationary (which is the case we are considering), the free-slip boundary condition can be

    formulated as

    u(x, t) · n̂ = 0, x ∈ ∂Ω, (4.10)

    where n̂ is the unit outward normal to the wall. The free-slip boundary condition is also

    needed to satisfy the requirements of the Helmholtz-Hodge decomposition theorem (4.1).

    A boundary condition for the Poisson equation (4.8) in terms of the intermediate velocity

    field w can be obtained by applying the free-slip condition to (4.9). Thus, on the boundary

    ∂Ω,

    ∇p · n̂ = w · n̂, (4.11)

    which means that the boundary condition for w governs the boundary condition for p. Since

    w(x, t) is initially equal to u(x, t), it is natural to impose the condition that w remains

    parallel to the boundary, i.e. w ·n̂ = 0 on ∂Ω. Under this condition, the boundary conditionfor p becomes a Neumann boundary condition and the complete Poisson problem (4.8) is

    given by {∇2p = ∇ ·w in Ω

    ∇p · n̂ = 0 on ∂Ω.(4.12)

    The solution 1 to the Poisson problem (4.12) ensures that the resultant velocity u(x, t+

    ∆t) is divergence-free and satisfies the free-slip boundary condition. A numerical method

    for solving the discretized Poisson problem is presented in Section 4.1.3.

    4.1.2 Computing the Intermediate Velocity Field

    The intermediate velocity field w(x, t + ∆t) is a solution to the partial differential equa-

    tion (4.7) over a time step ∆t with the initial condition that w0(x) = u(x, t) and the

    boundary condition that w · n̂ = 0. It is computed using a two step procedure (Fig. 4.2) asexplained by Stam [26].

    1. Adding Forces

    In the first step, the forces acting on each grid point (buoyancy, vorticity etc.) at

    1 In general, the Neumann problem for Poisson’s equation (∇2p = f in Ω, ∇p · n̂ = g on ∂Ω) has asolution unique up to a constant if and only if the compatibility condition

    R

    Ωf dx =

    R

    ∂Ωg dS is satisfied. In

    our case, f = ∇ ·w and g = w · n̂ = 0; and the divergence theorem ensures thatR

    Ω∇ ·w dx =

    R

    ∂Ωw · n̂ dS.

    31

  • 4.1. THE METHOD OF PROJECTION

    u(x, t) = w0(x)add force︷︸︸︷

    =⇒ w̃(x)advect︷︸︸︷=⇒ w(x)

    project︷︸︸︷=⇒ u(x, t + ∆t)

    Figure 4.2: The Method of Projection for solving the incompressible Euler equations. Theknown velocity at time t sequentially undergoes three steps, namely, the addition of forces,advection and projection to yield the velocity field at a later time (t + ∆t).

    the current time t are computed through the corresponding force equations (2.7 and

    2.8). Assuming that the time step ∆t is sufficiently small so that the force G(x, t) is

    effectively constant over the time interval, it can be added to the velocity field through

    a simple first-order Euler integration scheme, giving the resulting velocity field

    w̃(x) := w0(x) + G(x, t)∆t. (4.13)

    2. Advection

    The second step accounts for the advection term −(w ·∇)w. This is done through aLagrangian approach based on the method of characteristics. The effect of advection

    is to transport a quantity along the velocity field of the fluid. In this case, the quantity

    being transported is the fluid velocity itself; i.e. each component of the fluid velocity

    is transported along the vector field. Assuming that the time step is sufficiently small

    so that the fluid velocity does not change much, the method of characteristics reveals

    that information is propagated along the streamlines of the vector field.

    A streamline of the velocity field w̃ is given by the parametric curve that is a solution

    to the system of ordinary differential equations given by

    d

    ds(x(s)) = w̃(x(s)). (4.14)

    Let r(x0, s) denote the parameterized streamline that starts at location x0 when

    s = 0 and solves the above system of ordinary differential equations. The method

    of characteristics tells us that the velocity at x0 at time (t + ∆t) is the same as the

    velocity at the location given by r(x0,−∆t). The advected velocity field w that solvesequation (4.7) is therefore given by:

    w(x) = w̃ (r(x,−∆t)) . (4.15)

    32

  • 4.1. THE METHOD OF PROJECTION

    In order to compute the new velocity at a grid location x, we perform a second-order

    Runge-Kutta particle trace to obtain the location r(x,−∆t) of the particle a time ∆t ago.We do this at each of the N interior grid points. The velocity is taken to be zero at the

    boundary ∂Ω so that it satisfies the free-slip condition. As a result of this integration, the

    particle might end up either in a non-grid location or completely outside the domain Ω.

    In the former case, we use interpolation to determine the velocity value at the non-grid

    location. Linear interpolation is a good choice since it is fast and gives reasonable results.

    For better results, cubic interpolation can be used but it is much more expensive. In the

    latter case, we clip the trace against the boundary and set the velocity equal to zero to

    ensure that the free-slip boundary condition is satisfied. Both Runge-Kutta integration and

    interpolation are standard numerical schemes and we refer the reader to [24] for details.

    4.1.3 Solving the Discrete Poisson Problem

    The Poisson problem (4.12) when spatially discretized over the domain Ω becomes a sparse

    linear system. There are many methods for solving such systems of linear equations (see

    e.g. [7,24]), each with its pros and cons depending on the nature of the sparse matrix. These

    methods can broadly be classified into two categories, direct and iterative. Direct methods

    get an exact solution to the linear system whereas iterative methods refine a solution at

    each step of the iteration until some convergence criterion is met. For arbitrary domains,

    these methods are often quite expensive but when the domains are simple, fast and direct

    solvers can be used. In fact, using rectangular domains in our simulations allows us to use a

    rapid fast Fourier transform (FFT) based solver that has a time complexity of O(N log N).

    We shall first describe how the FFT based method solves a one-dimensional Poisson

    problem and then generalize the recipe to two and three dimensions. Let us consider the

    following 1D Poisson problem

    − d2p(x)

    dx2= f(x),

    1

    2≤ x ≤M + 1

    2, (4.16)

    with the Neumann boundary conditions that px(12 ) = px(M +

    12 ) = 0. As mentioned before,

    we discretize the interior of the interval into M equally spaced points xi,

    (xi = ih, i ∈ {1, 2, . . . ,M−1,M}) with the grid spacing h being unity. With this discretiza-tion, a second-order central difference approximation to the Poisson equation (4.16) is given

    bypi+1 − 2pi + pi−1

    h2= fi, (4.17)

    33

  • 4.1. THE METHOD OF PROJECTION

    where pi = p(xi) and fi = f(xi). When we evaluate the above equation (4.17) at all M grid

    points, we get the matrix equation

    −1 11 −2 1

    . . .. . .

    . . .

    1 −2 1. . .

    . . .. . .

    1 −2 11 −1

    p1...

    pi−1

    pi

    pi+1...

    pM

    = h2

    f1...

    fi−1

    fi

    fi+1...

    fM

    , (4.18)

    which can also be written as

    TM · p = h2f . (4.19)

    The M ×M sparse matrix TM is tridiagonal (consists of zeros everywhere except for thediagonal and off-diagonal entries), the M × 1 column vector p is made up of the unknownvalues of the function p(x) at the discretized locations; and the M × 1 column vector fconsists of the known values of the function f(x).

    The Neumann boundary conditions cause the first and last entries of the main diagonal to

    be -1. From (4.17), the equation for p1 is

    p2 − 2p1 + p0h2

    = f1.

    Since the Neumann boundary condition is specified at the halfway grid point, a central

    difference approximation to the first derivative gives the relation

    px(1

    2) =

    p1 − p0h

    = 0,

    from which we can conclude that p0 = p1. Substituting this back into the equation for p1

    above, we getp2 − p1

    h2= f1.

    A similar reasoning applies to the other boundary location and explains why the first and

    last entry on the main diagonal of TM is -1 and not -2. This also explains our motivation

    behind using a halfway boundary at the beginning of this chapter.

    The sparse matrix TM has a special form that allows us to use the FFT to solve the linear

    system (4.19). In the continuous realm, the eigenfunctions of the second derivative operator

    34

  • 4.1. THE METHOD OF PROJECTION

    ( d2

    dx2) are sines are cosines. As one would expect, the matrix TM also has eigenvalues and

    eigenvectors that are trigonometric functions. In particular, the eigenvalues of TM are given

    by

    λj := 2− 2 cos[π(j − 1)

    M

    ], j ∈ {1, . . . ,M}, (4.20)

    and the corresponding eigenvectors are

    zj(i) := aj cos

    [(2i− 1)(j − 1)π

    2M

    ], (4.21)

    aj =

    √1M

    if j = 1√2M

    if j 6= 1.

    Note that when j = 1, λ1 = 0. This makes the matrix singular with a null-space of dimension

    one spanned by the eigenvector z1 = (1, . . . , 1)T . Consequently, the solution p is unique

    upto a constant, i.e. if p is a solution to (4.19), then so is p + c(1, . . . , 1)T . This comes as

    no surprise since the solution to the continuous Poisson problem with Neumann boundary

    conditions is also unique upto a constant. In practice, the zero eigenvalue λ1 is usually

    replaced by a small positive number ǫ to avoid division by zero.

    Let Z = {z1, . . . , zM} be the orthogonal matrix formed by the eigenvectors and Λ bethe diagonal matrix formed by the corresponding eigenvalues. An eigen-decomposition of

    TM is given by

    TM = ZΛZT , (4.22)

    which when applied to (4.19) gives the solution to the discrete Poisson problem as

    p = (ZΛ−1ZT ) · (h2f). (4.23)

    There is a very close connection between the eigenvector matrix Z and the fast Fourier

    transform [7]. In fact, multiplication by ZT is the same as computing the discrete cosine

    transform (DCT). Similarly, multiplication by Z computes the inverse discrete cosine trans-

    form (IDCT).

    Let us denote the discrete cosine transform of a column vector f as f̂ and its individual

    components as f̂i. The right hand side of (4.23) can be computed using the following simple

    algorithm.

    35

  • 4.1. THE METHOD OF PROJECTION

    Algorithm 1: 1D discrete Poisson problem with Neumann boundary conditions.Input: The column vector f .

    Output: The solution p to the 1D Poisson problem.

    1DPoisson(f)

    (1) f̂ ← DCT(h2f).(2) for i = 1 to M

    (3) f̂i ← (f̂i)/(λi).(4) p← IDCT(̂f ).(5) return p

    The discrete cosine transform can be computed from the fast Fourier transform in con-

    stant time. Since the above algorithm makes use of the transform twice (once forward

    and once backward), the overall time complexity of this algorithm is the same as the time

    complexity of FFT, i.e. O(M log M).

    Extension to Higher Dimensions

    The above recipe can easily be extended to two and three (and possibly higher) dimensions.

    In two or three dimesions, a central difference approximation to the Laplacian operator (∇2)yields a linear system similar to (4.18). The analog of the matrix TM can be obtained by

    using matrix Kronecker products as explained in [7]. We follow a slightly different approach

    that is a generalization of the 1D DCT based algorithm presented above.

    Let us remind the reader that the Poisson problem we are interested in solving is given

    by: {−∇2p = f in Ω

    ∇p · n̂ = 0 on ∂Ω,(4.24)

    which is the same as the original problem (4.12) when f = −∇ · w. Suppose that thediscretized function is given by f which has the components fi,j in 2D and fi,j,k in 3D

    (i, j, k ∈ {1, . . . ,M}). Again, let us denote the discrete cosine transform (which is now twoor three dimensional) of f as f̂ and its individual components as f̂i,j in 2D (or f̂i,j,k in 3D).

    The eigenvalues of the 2D linear system that arises as a result of the discretization

    of (4.24) are

    λi,j := λi + λj = 4− 2 cos[π(i− 1)

    M

    ]− 2 cos

    [π(j − 1)

    M

    ]. (4.25)

    36

  • 4.1. THE METHOD OF PROJECTION

    In 3D, the eigenvalues are

    λi,j,k := λi + λj + λk = 6− 2 cos[π(i− 1)

    M

    ]− 2 cos

    [π(j − 1)

    M

    ]− 2 cos

    [π(k − 1)

    M

    ]. (4.26)

    Denoting a d-dimensional discrete cosine transform as DCTd (d ∈ {2, 3}), and the corre-sponding inverse cosine transform as IDCTd, Algorithms 2 and 3 listed below are the two

    and three dimensional analogues of Algorithm 1.

    Algorithm 2: 2D discrete Poisson problem with Neumann boundary conditions.Input: A 2D grid f .

    Output: The 2D grid p that is a solution to the 2D Poisson problem (4.24).

    2DPoisson(f)

    (1) f̂ ← DCT2(h2f).(2) for i = 1 to M

    (3) for j = 1 to M

    (4) f̂i,j ← (f̂i,j)/(λi + λj).(5) p← IDCT2(̂f ).(6) return p

    Algorithm 3: 3D discrete Poisson problem with Neumann boundary conditions.Input: A 3D grid f .

    Output: The 3D grid p that is a solution to the 3D Poisson problem (4.24).

    3DPoisson(f)

    (1) f̂ ← DCT3(h2f).(2) for i = 1 to M

    (3) for j = 1 to M

    (4) for k = 1 to M

    (5) f̂i,j,k ← (f̂i,j,k)/(λi + λj + λk).(6) p← IDCT3(̂f ).(7) return p

    Algorithm 2 has a time complexity of O(M2 log M2) while Algorithm 3 has a time

    complexity of O(M3 log M3). In general, if the total number of grid points is N , a solution

    to a d-dimensional Poisson problem with Neumann boundary conditions can be computed

    in O(N log N) time. With minor modifications, this recipe can also be used for grids with

    37

  • 4.2. PHYSICALLY BASED RENDERING

    unequal number of grid points in each dimension as well as for the Poisson problem with

    Dirichlet 2 boundary conditions.

    4.2 Physically Based Rendering

    The top-down Euler equations as well as the bottom-up LBM simulate the complex motion

    of smoke in two and three dimensions. In order to achieve visual realism, the density grids

    must be rendered using an algorithm that takes into account, the physical interaction of light

    with smoke. Gaseous phenomena such as smoke do not interact with light the same way

    opaque surfaces do. They are transparent substances that allow light to pass through and at

    the same time, cause it to attenuate and scatter. The name, participating media, is usually

    used in Computer Graphics to refer to such substances. Photon mapping, an extension

    of ray tracing, is a photorealistic rendering technique that makes it possible to efficiently

    simulate global illumination in scenes with participating media. We have therefore made

    use of photon mapping to render the three dimensional smoke datasets generated through

    the top-down and bottom-up approaches. In this section, we present the relevant equations

    that model the interaction of light with smoke. A detailed account of how photon mapping

    is used to solve the rendering problem can be found in [17,23].

    4.2.1 Scattering Media

    Smoke, like other participating media, scatters and attenuates an incident beam of light.

    This means that a ray of light that has travelled a certain distance through smoke in a

    straight line, will have its intensity reduced because of the interaction of