Fluid GitHub PixelPhysics ·

Eulerian (Grid-based) Fluid Simulation




Shareable URL :

Available variables:
nx (number) [read-only] : number of grid x direction (column)
ny (number) [read-only] : number of grid y direction (rows)
id(i,j) (Function(number, number) : number) : function that given the column and row index (i,j), will return the 1D index in the array.
Vx, Vy (Float32Array) : velocity in the x and y direction in a cell
RDye, GDye, BDye (Float32Array) : value (0.0 - 1.0) of each RGB component of the dye in a cell
initVx, initVy, initRDye, initGDye, initBDye (Float32Array) : initial value of each field. values from init field will only be applied as initial condition, and the value will change and evolve naturally. (While the value from (normal) field will be fixed.)
S (Float32Array) : information about obstacle, S = 0.0 mean obstacle, S = 1.0 mean free, S = 0.5 mean half of the flow will be transferred. (you can also think of S as fraction of the flow that is transfered through a cell)

Objects:
utils.hex2rgb(hex) (Function(number) : number[4]) : function that given a number, will return array containing RGBA values (0-255) corresponding to that number (ex: utils.hexrgb(0xE022E0) : [224,34,224, 255])
utils.sceneReset (Function(void) : void) : reset the values of all field
utils.addCircularObstacle(xpos, ypos radius) (Function(number, number, number) : void) : function that generate a circular obstacle
Math (object) : "library" of mathematical functions (javascript)