Statistical Fluid Flow Synthesis Mauricio Vines* Won-Sook Lee† University of Ottawa fluid behavior in real-time. Composing fluid behavior from a set ABSTRACT of simulation components or tiles has been applied with model We present our ongoing work on developing techniques for real- reduction [6]. Here each component contains a base of possible time simulation and visualization of fluids. We propose fluid velocities. In our scenario, we do not use model reduction synthesizing fluid motion from simulation examples obtained with for our simulations, but synthesize motion from examples a full numerical solver. We segment our simulation data in order obtained by numerically solving the Navier-Stokes equations. to capture the properties of local fluid behavior and apply statistical techniques to obtain the main modes of variation of the flow interacting with solid obstacles. Most research in fluid simulation has been focused on techniques for solving the Navier- Stokes equations for fluid motion, obtaining physically accurate simulations. We aim to obtain visually plausible flows by combining the results of physically accurate simulations preserving the general flow behavior. Our technique is suitable to be applied for visual effects design in movies as well as real-time applications such as videogames and virtual environments with haptic interaction, where efficient computations are required. KEYWORDS: Fluid simulation, principal component analysis, visualization. Figure 1. Schema of our approach INDEX TERMS: I.3.7 [Computer Graphics]: Three-Dimensional Graphics and Realism—Virtual Reality; I.6.8 [Simulation and 2 METHODOLOGY Modeling]: Types of Simulation—Animation In this section we discuss the two stages of our simulation 1 INTRODUCTION framework: the construction of the examples database and the synthesis of new fluid motion from these examples. We represent Simulating fluids remains one of the most challenging problems the fluid using an Eulerian approach, both in the preprocessing in computer graphics. Recent advances in computer applications and motion synthesis stages. The simulation space is divided into demand more realism and interactivity. Several techniques have a regular grid of cells. In each cell the fluid velocity and pressure been developed to provide accurate and realistic fluid simulations, are stored. Solid objects are assumed to be static and they are however, at a great computational cost. This is due to the interplay voxelized as in [2], conforming to the simulation space of different complex phenomena involved, such as advection, configuration. In the preprocessing stage simulation examples are diffusion and turbulence, which are difficult to simulate. Fluid produced and analyzed. In the synthesis stage we find velocity behavior is characterized by the well known Navier-Stokes values for each grid cell to approximate fluid behavior by equations which are a system of partial differential equations for combining the flow information from the simulation examples. A which no analytical solution is known. schema of our approach is shown in Figure 1. In computer graphics, the main goal is to achieve visual plausibility, even at the cost of physical accuracy. Several 2.1 Database construction approximations to fluid behavior have been developed, including Fluid flow examples are obtained from simulating the fluid on the particle-based simulations [4] and height field approximations for grid in the pre-processing stage. For simulating the fluid we liquid surfaces [3]. Applications of fluid simulations include employ a finite difference method based on operator splitting and visual effects in movies and videogames, as well as real-time semi-Lagrangian advection [5]. We run several simulation rounds interaction with virtual environments [1][7]. for different solid configurations in order to have a rich set of We propose a different method to efficiently obtain visually fluid motion examples. In a simulation round the obstacle plausible simulations using fluid motion examples. These geometry is defined, and the fluid is simulated under different examples are obtained by running a standard fluid simulation flow conditions, varying the direction and magnitude of the fluid under different flow conditions and the resulting motion data is velocity. Velocity values for each time step of simulation are spatially partitioned into different fragments. We apply principal stored for segmenting and statistical analysis. component analysis (PCA) on the fragments and we employ this Once the examples have been obtained, the results of each time information to synthesize new fluid motion. Fluid motion step are segmented in fragments of equal size. A fragment databases have been used in the past for computing fluid forces on consists on several grid cells, each storing velocity and pressure immersed solid objects [1], however we focus on visualizing the values. For each fragment we keep track of its neighboring fragments as well as the corresponding fragment in the next time * e-mail: mvine059@uottawa.ca step. As we consider only the case of static solids, the velocities in † e-mail: wslee@uottawa.ca the grid cells occupied by a solid are zero. An example of the fluid examples generated and its fragments is shown in Figure 2. 4 We apply PCA on the fragments to capture the main modes of definition of a free surface. A non-mass conserving fluid will variation of the fluid velocity. We construct a covariance matrix appear as evaporating, hence losing mass. To properly simulate from the fluid velocity data in each fragment and we obtain the liquids using our technique, examples of the free surface have to eigenvectors and eigenvalues of this matrix. Then we transform be generated and statistically analyzed as well. our simulation data into the PCA space, this is, we represent the data in terms of the principal components, which are the eigenvectors with highest eigenvalues associated. The fragments spatial and temporal associations are stored, enabling to quickly determine the local evolution of the fluid for a specific fragment. 2.2 Flow synthesis Synthesizing new fluid motion in the simulation grid is performed using the data from the examples and the current velocity in the grid. A specific velocity field may be defined by the user as initial conditions for the simulation, or as result of real-time interaction. The new simulation data is segmented into fragments the same way as the examples and the velocity data for each fragment is translated into the PCA space. For fragments that contain solid cells, or that share a boundary with a solid, a pattern matching Figure 2. Frames of fluid simulation examples and a detail of step is performed in order to determine the best example fragments for each fragments that resemble the specific local solid geometry. Let f be a fragment in the new simulation and S the set of We note as well that the different visual effects that can be example fragments that are geometrically compatible with f. The obtained by this technique are limited to the fluid motion fluid velocity in f is determined by finding a combination of variations in the database. Extending the examples database examples such that it matches the behavior observed in f. would allow simulating more diverse solid-fluid interactions. Formally, let e1, e2,,…,en be the first n principal components derived from the examples, and let B=[b1, b2,…bn]T be the vector 4 CONCLUSION of coefficients corresponding to f in the PCA space. For each We present an approach to synthesize fluid motion from example si∈S, let Ci=[ci1,…, cin]T be the vector of coefficients in examples. Statistical analysis is performed on the examples and the PCA space. Then synthesizing new motion reduces to solving they are combined in order to approximate fluid behavior. This the following system: approach is suitable to be used for real-time applications such as videogames and interaction with virtual environments. In the [C ] future we aim to extend our method to properly simulate fluid 1 L Ck ⋅ x = B (1) interaction with moving solids. Also we aim to provide more animation control by allowing the user to specify the velocity in specific fragments in different locations and times, so fluid motion The coefficients of vector x indicate how the samples must be must be synthesized to match the user constraints. combined to match the current motion in the current time step. As the matrix in equation (1) may not be square, the system may have REFERENCES to be solved in the least squares sense. If no external force is [1] Y. Dobashi, M. Sato, S. Hasegawa, T. Yamamoto, M. Kato and T. added by the user, then solving the fluid velocity in f for the next Nishita. A fluid resistance map method for real-time haptic time step consists on finding the corresponding fragments in S for interaction with fluids. In Proceedings of the ACM Symposium on the next time step and combining them using the coefficients in x. Virtual Reality Software and Technology VRST’06 (Limassol, When an external force is added, it is necessary to solve the Cyuprus, November 1–3, 2006), pages 91–99, November 2006. system in equation (1) as the fluid motion may have drastically [2] N. Foster and D. Metaxas. Realistic animation of liquids. In changed. Notice that as we assume the solid objects are static, Graphical Models and Image Processing, volume 58, issue 5, pages determining the set S of geometrically compatible fragment 471–483, 1996. examples for each new fragment is performed just once at the [3] M. Kass and G. Miller. Rapid, stable fluid dynamics for computer beginning of the simulation. Using this simple technique we can graphics. In ACM SIGGRAPH Computer Graphics, volume 24, issue simulate fluids interacting with static rigid solids. 4, pages. 49-57, 1990. [4] M. Müller, D. Charypar and M. Gross. Particle-Based Fluid 3 DISCUSSION Simulation for Interactive Applications. in Proceedings of ACM Our approach may be used to simulate fluids at different detail SIGGRAPH Symposium on Computer Animation (SCA) 2003, pages scales, depending on the size of the simulation fragments. Smaller 154–159, 2003. fragments will provide more detailed information, at a higher [5] J. Stam. Stable fluids. In Proceedings of the 26th annual conference computational cost. We must note that the flow results in general on Computer Graphics and Interactive Techniques SIGGRAPH ’99, will not be mass-conserving in the strict sense. The mass pages 121–128. ACM Press/Addison-Wesley Publishing Co. 1999. conservation principle expresses that any change in fluid mass in a [6] A. Treuille, A. Lewis and Z. Popović. Model reduction for real-time region depends only on the net flux of mass in that region. This is fluids. In Transactions on Graphics, volume 25, issue 3, pages 826– usually enforced as an additional constraint when solving the 834. ACM Press, July 2006. Navier-Stokes equations. Although the examples used to construct [7] M. Vines, J. Mora and W.-S. Lee. Haptic Display of 3D Liquids for our database are mass-conserving, linear combinations of these Interactive Applications. In IEEE Consumer Electronics Games examples may not. While this is not a big problem when Innovation Conference ICE-GIC 2009 (London, United Kingdom simulating a gas, care must be taken when simulating liquids from August 25-28), 2009. using our technique. Liquid simulation requires the proper 5