# Fluid Implict Particles on Coadjoint Orbits

[Mohammad Sina Nabizadeh](https://sinabiz.github.io/)
[Ritoban Roy-Chowdhury](https://scholar.google.com/citations?user=jSueleoAAAAJ&hl=en)
[Hang Yin](https://yhesper.github.io/)
[Ravi Ramamoorthi](https://cseweb.ucsd.edu/~ravir/)
[Albert Chern](https://cseweb.ucsd.edu/~alchern/)

*ACM Transaction on Graphics (Proceedings of SIGGRAPH Asia 2024), 43, 6, 270:1-270:38, 2024*

![Alt text](Images/teaser.jpg)

## Abstract
We propose Coadjoint Orbit FLIP (CO-FLIP), a high order accurate, structure preserving fluid simulation method in the hybrid Eulerian-Lagrangian framework. We start with a Hamiltonian formulation of the incompressible Euler Equations, and then, using a local, explicit, and high order divergence free interpolation, construct a modified Hamiltonian system that governs our discrete Euler flow.  The resulting discretization, when paired with a geometric time integration scheme, is energy and circulation preserving (formally the flow evolves on a coadjoint orbit) and is similar to the Fluid Implicit Particle (FLIP) method.  CO-FLIP enjoys multiple additional properties including that the pressure projection is exact in the weak sense, and the particle-to-grid transfer is an exact inverse of the grid-to-particle interpolation. The method is demonstrated numerically with outstanding stability, energy, and Casimir preservation.  We show that the method produces benchmarks and turbulent visual effects even at low grid resolutions.

## Acknowledgements
This codebase is forked and modified from the Covector Fluids paper's codebase.

## Compile and Run
To build this project, you will need tbb, openvdb, and boost as dependencies.
```
sudo apt-get install libtbb-dev libopenvdb-dev libboost-all-dev
```
This code is built and tested on Ubuntu 22.04 and Mac OS.

I ran into an issue where libopenvdb-dev is NOT up-to-date when installed from apt. Instead, go to OpenVDB repository and build it straight from source for your computer.

2D code and 3D code are separated, you can execute them separately.

You should specify the simulation method as the second input parameter. 0-4 are Polynomial PIC (POLYPIC), Polynomial FLIP (POLYFLIP), Reflection + POLYFLIP (R+POLYFLIP), Covector Fluids + POLYFLIP (CF+POLYFLIP), and Fluid Implict Particles on Coadjoint Orbits (CO-FLIP) methods, respectively.
The third parameter is the example case you wish to run, 0-3 represents Leapfrogging Marathon, Rayleigh-Taylor Instability, Smoke Plume, and Vortex Sheet, respectively.
```
mkdir build
cd build && cmake ..
make
./COFLIP2D sim_method sim_setup
```
For 3D experiments, the setup is similar to 2D.
You should specify the simulation method as the second input parameter. 0-4 are Polynomial PIC (POLYPIC), Polynomial FLIP (POLYFLIP), Reflection + POLYFLIP (R+POLYFLIP), Covector Fluids + POLYFLIP (CF+POLYFLIP), and Fluid Implict Particles on Coadjoint Orbits (CO-FLIP) methods, respectively.
The third parameter is the example case you wish to run, 0-8 represents Trefoil Knot, Vortex Leapfrogging, Twisted Vortex, Unknot Vortex, Smoke Plume, Pyroclastic, Rocket, Spot Obstacle, respectively.
```
./COFLIP3D sim_method sim_setup
```
Generated .vdb file will be located in `Out_2D` and `Out_3D` folders, you can use any software(e.g. Houdini) to visualize.

## BibTex 

Please cite the following paper if it helps. 

```
@article{nabizadeh2024cofip,
  title={Fluid Implict Particles on Coadjoint Orbits},
  author={Nabizadeh, Mohammad Sina and Roy-Chowdhury, Ritoban and Yin, Hang and Ramamoorthi, Ravi and Chern, Albert},
  journal={ACM Transactions on Graphics (TOG)},
  volume={43},
  number={6},
  pages={270:1--270:38},
  year={2024}
  publisher={ACM New York, NY, USA}
}  
```
