Vic2d
Vic2d is a multithreaded two-dimensional fluid simulator. It uses a vortex-in-cell velocity solver with a 4th-order semi-Lagrangian method-of-characterstics and 4th-order interpolation scheme for advection. A similar method was mentioned in a 1969 paper, but does not appear to have been used since then. Unlike Stam's stable fluids method, it is not unconditionally stable, but it does have the ability to take large time steps with very little numerical diffusion and subsequent loss of energy (which can't be said of the popular "Stable Fluids" method). Vic2d is a collection of C and Fortran files and requires only gcc, gfortran, and the PNG libraries to compile. I wrote the base code in 2004 and have been using and updating it since then.
Files
You should get the current version of vic2d from the github page. You will need a C compiler and a Fortran compiler. If you are not using gcc and gfortran (because you are building on OSX or using MinGW), you will need to edit Makefile accordingly. On most Unixes, the following is all that should be necessary:
% git clone https://github.com/markstock/vic2d.git
% cd vic2d
% make
% vic2d -help
Features
Vic2d supports the following options (and more):
- -help Dump a full list of command-line options
- -x [val] -y [val] Set resolution of simulation
- -px -py Set periodic boundaries (default is viscous wall)
- -open Set open boundaries
- -fs [val val] Set freestream (forces open boundaries)
- -grav [val val] Set gravity vector
- -vd [val] Set momentum diffusivity (1/Reynolds)
- -vf [name] Read a PNG and use it to set vorticity
- -td [val] Set temperature/density diffusivity
- -tf [name] Read a PNG and use it to set temperature/density
- -b [val] Sets Boussinesq number
- -qf [name] Read a PNG and use it to set heat flux field
- -cd [val] Set color scalar diffusivity
- -cf [name] Read a PNG and use it to set color scalar
- -mf [name] Read a PNG and use it to set flow mask field
- -dt [val] Set time step size
- -cn [val] Set Courant Number (overrides -dt)
- -step [val] Sets number of steps to run
- -16 All PNG output uses 16bpp instead of 8bpp
- -stam Uses Stam's Stable Fluids for velocity calculation instead of VIC
12GB of RAM will allow you to run vic2d on domains up to 12288 x 12288 or 16384 x 9216 with full-color scalar tracking. Reynolds numbers can exceed 1B and Courant Numbers can exceed 20 easily.
Images
Simple random vorticity, runs with CN~=12
vic2d -x 512 -y 512 -randvortscale 100.0 -vd 1.e-5 -vprint -dt 0.1 -every 10 -step 100
Square RTI in B/W, showing simple buoyancy, Re=100M
vic2d -x 4096 -y 4096 -t -tf sin_4097.png -td 1.e-8 -b -1 -vd 1.e-8 -dt 0.001
Movie at YouTube
Flow over cylinder at Re=9500
vic2d -x 512 -y 512 -dt 0.005 -vd 0.000105263158 -open -fs 1. 0. -vprint -vscale 100.
Movie at YouTube
Flow over cylinder at Re=1000
vic2d -x 1024 -y 1024 -dt 0.005 -vd 1.e-3 -open -fs 1. 0. -vprint
Movie at YouTube
Flow over cylinder at Re=140
vic2d -x 1024 -y 1024 -dt 0.005 -vd 0.00714285714 -open -fs 1. 0. -vprint
Movie at YouTube
Buoyant simulation, RTI-like, very high resolution, Re=100M
vic2d -x 12288 -y 12288 -vd 1.e-8 -t -tf run19_12289_bwspread5.png -td 1.e-8 -c -cf run19_12289.png -cd 1.e-8 -cn 50 -every 20
Magma 19, at markjstock.com
Future plans
Future versions of vic2d may include the following:
- Validated wall-vorticity flux terms
- Variable viscosity
- Faster solutions when a mask is used
- Divergence fields
- Faster solutions for open boundaries
Please e-mail me if you'd like to see some particular feature in vic2d, or if you use it to make something creative.
Vic2d in practice
Vic2d is being used to generate Povray image maps for gas giant planets for the open-source space game Oolite.
Thanks
I would like to thank John Adams, Paul Swarztrauber and Roland Sweet for FISHPACK 4.0, John Adams for MUDPACK 5.0, all the developers of libpng, and N. Bin Zafar for countless discussions.