Figure 1-1. Fluid flow around a circle
Overview
The repository contains two main files, the simulation in fluid.jl, and a script to read images and output a grid of cells, generate_cells.jl. The fluid simulation works by creating a grid of cells, with each assigned to a 1 (open) or 0 (closed). Along the edges of each cell is a single number that keeps track of flow across that edge. In a given time step, the simulation first advects the velocities to the new cells, then relaxes to ensure the field is divergence free. An additional smoke advection function is also run to pull smoke into new cells depending on the velocity field.
Grid Generation
To generate the grid of cells, you can either write your own method to assign values manually, or input a black and white image. Note that the resolution of the image will equal the resolution of the final simulation. Black cells are read as solid (0), while white cells are read as (1). The cutoff is at a brightness value of 0.5, so all cells below that are assigned a 0 and everything else is assigned a 1.
Figure 2-1. Image used to generate grid
Figure 2-2. Simulation run with the image from Figure 2-1
Here's a simulation run with a less streamlined object.
Figure 2-3. Fluid flow around a peep