We implemented a particle level set fluid simulation system that can handle both multiple fluids and rigid body interacting at once, based on the 2006 SIGGRAPH paper “Multiple Interacting Liquids” by Losasso et al. and “Impulse-based rigid body interaction in SPH” by Seungtaik Oh, Younghee Kim and Byung-Seok Roh.

Single fluid simulation systems is a technical problem with a well established body of work proposing a variety of solutions, but multiple interacting fluids is a significantly more complex problem that must be solved in order to achieve a variety of more interesting fluid effects, such as oil on water or having bubbles rise through a volume of liquid. Multiple interacting liquids could potentially also be used to approximate rigid body in fluid simulations through the use of ultra-high viscosity liquids. In “Multiple Interacting Liquids”, multiple fluids are handled by treating each fluid as its own “region”, with each region being treated as its own separate particle level set, and then a novel algorithm is used to map each regional particle level set onto a more standard single-valued level set [Losasso et al. 2006]. In such a system, other phenomena such as pockets of air in liquid can simply be treated as additional fluid regions.

**2. Approach**

We divided our task into three different parts which are fluid solver, rigid body interaction and surface mesh reconstruction. Xinjie Ma is responsible for the first part the particle based fluid solver. Zihao Feng completes the rigid body interacting simulation, and Wei-Chien Tu is responsible for surface mesh reconstruction.

**2.1 Particle-based SPH fluid solver**

The core of our framework is based on the Fluid V2.0 framework which was developed by Rama Hoetzlein. This framework takes a particle-based approach to solving the

Navier-Stokes equations and simulated fluids. This fluid solver use Langrangian viewpoint and store values like mass, velocity, position in particles. Particles concentrate mass at a point and represent a discretized continuous field. Smoothing kernel are used to describes distribution of attributes around particle. We have implement our own fluid feature upon this base.

To enable multiple fluids interact with each other, we defined two kinds of particles according to the paper: Multiple Interacting Liquids by Frank Losasso, et al. We tweak fluid properties like viscosity, density and mass to get interesting fluid interaction effects.

**2.2 Rigid Body Simulation**

Besides the multi fluids simulation, we also implemented the rigid body interaction. The simulation is based on a 2006 thesis “Rigid Body Simulation” by Rahil Baber.It deals with trying to model real world physical situations computationally by applying Newton’s laws of motion of perfectly rigid bodies. The two main features of the simulation are collision detection and collision response. The base code we applied is from Danny Chapman and the library Simple DirectMedia Layer(SDL). In the base code, Danny Chapman had implemented both collision detection and collision response with impulse-based method which is quite suitable for further interaction with fluids. We tweaked some settings, making the simulation to run faster and implemented obj file loader to quickly construct complex scenes.

Next, based on the paper “Impulse-based rigid body interaction in SPH” by Seungtaik Oh, Younghee Kim and Byung-Seok Roh, we implemented rigid body interaction with SPH fluids. A new boundary force was proposed to solve rigid body interaction in SPH. It gives more stable and accurate results in almost all kinds of rigid body interactions, and SPH fluid solver is capable of full two way interaction of fluid and rigid body and it turns to be a particle-based rigid body solver if only rigid bodies are simulated without fluid.There were many challenges, like mesh reconstruction, collision normal determination and high demand for simulation time and device. What we achieved eventually is realistic fluid and rigid body interaction simulation as you can see in the demo.

**2.3 Surface Reconstruction**

After we got the simulation result which is a data array stored all of the particle positions of each frame, we could construct the surface mesh from these data. We use the marching cube method as our base algorithm. The main idea of marching cube method is to determine whether a vertex is inside or outside of our surface and then we could find out the surface boundary which is located between inside vertex and outside vertex. However, what we only have is the position of each particle and the information is not enough for us to construct a surface. So we provide a virtual sphere for each particle which is showed as the blue dash circle in Fig. 1. Here we use 2D figure to explain a 3D method, however the concepts for 2D and 3D are identical. Every virtual circle enclosed several neighbor vertices. We assigned value for enclosed vertices according to their distance to the particle. The further distance is the smaller value was assigned. After we find out all of the surface boundary, then we could create a closed surface mesh like the red line in Fig 1. The radius of this virtual sphere is a critical factor which will influence our surface mesh result dramatically. From Fig 2, you could see the result of different virtual circle radius.

Fig. 1

Fig. 2

In order to let our surface mesh looks more smooth, we use level set method to do further calculation. We take the surface mesh which was constructed at last step and set a negative distance value to do level set method computation. Negative distance value represents the location inside the previous surface mesh. We could observe from Fig. 3, the green small rectangle represents locations inside the surface mesh. When we found out these locations, we could use marching cube method to construct a new surface. From Fig. 4 to Fig. 6, you could observe that Fig 5 is the first step result which only used marching cube method, and Fig 6 is the result after doing level set computation and second time marching cube method.

Fig. 3

Fig. 4 Fig. 5 Fig. 6