CPSC641 Computer Graphics

Final Project Report

DEC. 2003 By Zhang Xiao

 

2D Incompressible Fluid Interact with Soft Body

 

ABSTRACT:

          For this project, a 2D basic simulation of incompressible fluid interacting with the soft body has been developed. The fluid and soft body use different physically based computational model, fluid simulation use traditional CFD marker and cell finite difference method, soft body use simple spring mesh method. Then at the final stage, a simple rule combine these two model together to give a interaction effects by using Stokes equation.

 

Problem Summary:

          Fluid and Soft body simulation both has a ‘long’ history in computer graphics field and engineering field, there are several computational models exist for each of them, which make trade off between accuracy and computational speed. But the interaction between fluid and soft body is a relatively new research area, especially for computer graphics community. However, it’s a fairly interesting phenomena and worth to develop a realistic and efficient model to combine this two different simulation together. It’s also an complicate topic, since we need to deal with complex boundary condition and stability issues. By successfully solving this problem, not only we can extend the range of computer graphics natural phenomena simulation, but also have very practical application value in science and engineering, such as VR surgery, material science and engineering etc.

 

Previous Work:

          In computer graphics community, the first physically based simulation of complex water effects using the full 3D Navier-Stokes equations has been based upon the large amount of research done by the computational fluid dynamics community(CFD) over the past 50 years, [Foster and Metaxas 1996] utilized the work of [Harlow and Welch 1965] in developing a 2D and 3D Navier-Stokes methodology for the realistic animation of liquids. Further CFD enhancements to the traditional marker and cell method of Harlow and  Welch which allow one to place particles only near the surface can be found in [Chen et al. 1997]. A semi-Lagrangian “stable fluids” treatment of the convection portion of the Navier-Stokes equations was introduced to the computer graphics community by [Stam 1999] in order to allow the use of significantly larger time steps without losing stability. [Foster and Fedkiw 2001] made significant contributions to the simulation and control of three dimensional fluid simulations through the introduction of  a hybrid liquid volume model combining implicit surfaces(Level Set) and massless marker particles; the formulation of  plausible boundary conditions for moving objects in a liquid; the use of an efficient iterative method to solve for the pressure(CG technique); and a time step subcycling scheme(CFL condition) for particle and implicit surface evolution equations in order to reduce the amount of visual error inherent to the large semi-Lagrangian “stable fluid” time step used for time evolving the fluid velocity and the pressure, by using Level Set method, they generated and rendered a very realistic dynamic water surfaces. [Enright, Marschner, Fedkiw 2002] presented a new method for animation and rendering of water effects by introducing a “thickened” front tracking technique to accurately represent the water surface and a new velocity extrapolation method to move the surface in a smooth, water-like manner.

          Among the first to present a soft object model were Wyvill et al [Wyvi86]. Wyvill et al represent a soft object using a combination of an implicit function and a particle system. A simple approach is to use an explicit mass-spring system, representing the object as a lattice of mass elements linked with springs, Such a technique is used by Miller [Mill88] to animate the soft bodies of snakes and worms. There are other more advanced and complex computational model, FEM, FEV, and LEM,  [Teran, Blernker, Ng, and Fedkiw 03] use the FVM and a quasi-incompressible, transversely isotropic, hyperelastic constitutive model to simulate contracting muscle tissue. [James and Pai 01] decribe a real-time physically-based simulation algorithms for haptic interaction with elastic objects by using LEM method and pre-computed Green’s functions. Some attempts with FEM in real time simulations have been made in [Cani and Barr 00]. [Gidbson and Mirtch 97] did a good survey of deformable modeling in computer graphics

          There are few research has been done on combine fluid and soft body computational model together. [Costa, Balaniuk 01] presents LEM-Long Elements Method, for physically based simulation of deformable objects, they implements a static solution for elastic global deformations of objects filled with fluid based on Pascal’s principle and volume conservation.[Nixon,D and Lobb.R 02] developed a new model to simulate soft, deformable objects, the model is physically based, and making use of results from fluid dynamics and classical Newtonian mechanics. Both of them focus on modeling the Soft Body by taking merit from fluid computational model, the interaction between fluid and soft body hasn’t been addressed yet.

 

Description of Work:

          For the project, I implemented a hybrid 2d incompressible fluid  2d spring-mesh based           soft body simulator, and 3d version of  the simulator is in progress now. I started with 3d version fluid solver, but since the boundary condition is much more complicate than 2d, and hard to track. In order to able get a simulation result in time, I turn into 2d version, no only I achieved the final goal of the project, but also I gained more experience which can help me a lot when working on 3d solver later.

          The overall structure layout of my simulator can be shown in below figure:

Fluid  Class

 

Spring mesh class

 

Marker Particle Class

 
 


 

 

 

 

 

 

 

 


                     Fig 1. Simulator Structure Layout

         

          Fluid:

          The majority fluid simulation in computer graphics has always been using traditional CFD MAC(marker and cell) method, I made the same choice. The fluid simulator is implemented by mainly following [Foster96] paper, use a MAC(marker and Cell) method to simulate 2d incompressible fluid.

The entire fluid domain is defined in a 2D rectangular grids aligned with Cartesian coordinate system, each cell in the domain can be classified as full fluid cell, surface fluid cell on the boundary between the liquid and surrounding medium, empty cell and solid cell, each cell has velocity u, v defined on the center of each face, and pressure p defined on its center. The following figure gives a illustration of 3D cell, the same configuration goes for 2D cell as well.

Fig 2. 3D cell structure

 

 The space discretization leads to an explicit finite difference approximation of the N.S equation. Then by given a certain initial condition, we can numerically solve the N.S equation for all the cells in the domain, get new surface velocity for each fluid cell, and move marker particles by interpolating the surface velocity. That’s the basic idea behind MAC method. Please refer Foster’s paper for more detailed explanation, since the paper covers most of details on numerical techniques, I won’t address those issues here.

The rough procedure for one time of the fluid solver goes like:

 

          cell_type();                      // configure the cell type

          set_boundary();               // set the boundary condition for surface and solid cell

          solver_ns();                     // solving the NS equation numerically

          relaxation_p();                 // relax the pressure on fluid cell

          recal_boundary();            // recalculate the boundary condition for surface and solid cell

          CFL_timestep();              // CFL condition to calculate the stable time step

update();                         //update the markers

 

          my solver can handle slip and non-slip boundary condition, a image based scene importing scheme has been designed, user can draw any picture in Photoshop, then the simulator can read in the image file and configure the 2d fluid scene by color coding the pixel: yellow-solid cell, blue-fluid cell, white-empty cell. It makes it a lot easier to test any interesting new scene. A simple surface tracking has also been achieved by the same color coding scheme. User can define all the parameters for the 2d fluid environment and properties, include the size of the domain, the cells in X and Y direction, the gravity, environment pressure, fluid density and viscosity, time step. A CFL condition checking routine has also been implemented to improve the stability of the solver. By using marker particles, every fluid cell keep a linked list of the particles inside it, then it becomes very easy to advance and track the markers so as to reconfigure the cells in every time step.

          The 2D fluid simulator can run realtime with modest markers and grids amount, with 50 by 50 grids, 5000 markers, it can get smooth run time simulation.

          It took me some time to get all the boundary condition correctly, it is also the most important part in fluid solver, you won’t have good fluid surface motion without correct boundary conditions. In 2D there are 15 cases of surface cell condition, in 3D there are 63 cases, each of them need unique treatment. Also there are still other numerical issues for implementing a correct fluid solver,  but I spent major efforts on the boundary cognition part.

         

          Soft Body:

          The soft body use mass-spring model, The particle class serves as markers in fluid simulation and as mass node of spring in soft body simulation. There are two reasons for choosing this model instead of other computational model, the first is computational speed, the mass-spring model can be computed in real time, but other model(FEM, LEM, FVM) will take much more computational time. The second reason is that mass-spring makes us easy to handle the interaction between fluid and soft body, at least in one direction(fluid -> soft body), but other finite numerical method have their own computational grid space, it’s not very easy and intuitive to cope with fluid solver.

          The major drawback of mass-spring model is they are not very accurate, more specifically, it can not keep the volume of the deformable object, which is very important when dealing with interaction with fluid. Since for this project, I only need to simulate fluid acting on the soft body, not the other way around, we can ignore this for the time being, but it will definitely become an issue in future research.

          The user can define the soft body pretty much like the way to define a fluid grids: the initial size of the soft body, the number of nodes in X and Y direction, and program will automatically generate underline spring structure for the mass nodes. Each node has properties of mass and radius, the radius is used when we calculate the fluid force acting on the node.

          The simulation of the soft body is using a Euleur integration method, it’s stable enough for small mass-spring objects.

          I also implement a collision detection between the soft body and fluid domain solid cell by using the SLAB method from “real time rendering” book, it works for some situations, but when there is a multiple collision, it will fail, I didn’t figure out the problem yet unfortunately, but I will keep working on this issue.

 

          Interaction Between Fluid and Soft Body:

          For this project, I implement the basic interaction between fluid and soft body by using Stokes equation and a simple checking routine.

          For each time step, we check which cell the soft body mass node locate in, if it’s a fluid cell, first I calculate the buoyancy based on the equation:

          F = rou * V * g;

          Rou is the fluid density, V is the node’s bounding volume which we can calculate from the radius of the node, g is gravity.

         

          Next I use Stokes equation to calculate the force generated by the relative velocity between the nodes and fluid. The equation is:

          F = 6 * Pi * Vrel * V;

          Pi is angle constant, Vrel is the relative velocity between the node and fluid velocity at the position of the node, V is again the node’s bounding volume.

          Add these two force to the total force of each mass node of the soft body, we can get an realistic effect that fluid acts on a soft body.

          Currently soft body won’t have effects on fluid motion, it’s also the direction for future research.     

 

Results:

          Fluid:

          The following figures will show one arbitrary scene from original design to the final simulation. I tested many scenes, I thought this one is more interesting since it really shows very nice fluid motion.

         

          Fig 3. Initial Scene Designed in Photoshop

 

         

          Fig 4. Initial Scene File read in and configured in Fluid simulator

                   Automatically(50 by 50 grids, 5000 markers, time step 0.015,

Nonslip boundary condition)

 

         

         

         

          Fig 5 - 10. Real time simulation sequence of the 2D fluid

                  

          From above images, it shows that my 2d simulator can take any arbitrary user defined scene image and  correctly simulate all the details of 2d incompressible flow, and also it can handle arbitrary static solid boundary. It can achieve real time display without decreasing the too much simulation accuracy.

         

          Fluid plus Softbody:

          The following images will show the same fluid scene interact with a soft body, the soft body is a simple spring quad with 4 mass node and 6 springs, 4 edge springs, 2 diagonal springs, only edge springs is drawn with Opengl.

         

         

         

         

          Fig 11 - 16. Real time simulation sequence of the 2D fluid interact with soft body

         

          From above images, it clearly shows that how the soft body can flow along with the fluid motion realistically, and still keep its own elasticity, the last three images show that the collision detection has been handled correctly for this situation.

         

Analysis of work:

          For this project, I implemented a simple but effective dynamic model of the interaction between incompressible fluid flow and mass-spring soft body by using Stokes Equation, it can be easily extended to compressible flow region also. By taking advantage of mass-spring soft body model, a real time simulation has been achieved. A foundation of further research has been well established. A new attempt of trying to combine fluid and soft-body simulation has been successfully made. As far as I know the interaction between soft body and  incompressible fluid hasn’t been addressed yet in computer graphic society. The original goal of the project has been met.

          Since the model is still naïve and incomplete, there is a lot of directions to make further research.

First is more accurate and fast soft-body model, accurate means it can preserve the volume of soft body, fast means it can be simulated in real time. If we can preserve the volume of soft body, not only we can get more realistic soft body motion, but also we can use volume to calculate correct buoyancy, furthermore, the change of volume can be served as a pressure force to the fluid domain, then we can simulate effects of soft body acts on the fluid also, but still we want to keep our simulation running in real time. Just till the end of the project, I found out a paper by Maciej Matyka and Mark Ollila, they implemented a pressure model of mass-spring based soft body, it may serve well for my goal.

Second is of course extend my simulator to 3D domain.

Third is making a better collision detection and response routine that can handle most of collision situations.

         

PS. I will upload some video clip later, if you have any question and like to take a reference of my source code, please contact me with xiao@viz.tamu.edu.