

(sorry for poor english use, if you will have problems with understand something - mail me)


Fluid v1.0 Source Code Documentation.


1. Something about source code.
2. How to compile it?
3. How to use compiled program?
4. Configuration file.
5. End Words.
6. Contact.

ad 1) Something about source code.

As you see source code is full c oriented (not object programming - no c++ classes inside). It's full ansi c, and can be compiled every systems which support ansi c compiler. I tested it on Silicon Graphics, PC (win, linux), Macintosh, and Amiga systems. It work perfectly everywhere, becouse it don't use (version 1.0) Graphics User Interface. When you compile program, and you will have fluid.exe file, it is ready to run from any text console. Program didn't show results - just write graphics files (.ppm - it's portable graphics format) to harddisk. I think that point of program is good, becouse it is portability. 

ad 2) How to compile it?

Remember, than main source file is fluid.c. Of course you must have other files compiled too. Best way is to use makefile included into src package. It's makefile for un*x oriented systems. When you want to compile it under windows big compilers (like visual c++, or Borland c++) - it is also possible. Load all files into project workspace and compile everything - there cannot be any problems. Anyway if you compile (to .o files) every .c files from src package, just link it into fluid.exe file. Easy? Yes!


ad 3) How to use compiled program?

Ok. You have fluid.exe file. If you will run it you will see text in standart output:

Option file not specified.
USAGE: fluid <file.opt>

That means - you must specify option file you want to render. Like "fluid.exe brokendamn.opt"


ad 4) How to built .opt file?


Option file contains:

a) info about size of output and grid
b) specify of fluid, physic properties, dt (delta time) size
c) graphics mode information
d) stability power info
e) configuration of particles
f) boundaries configuration

First - look for examples, try to use fluid with that examples. Now you see that some options are easy to understand. Anyway we will try together to built option file for situation like in image.jpg

/* Config file for "fluid" program. */

/* You Can use typical comments like in c languague */

/*
At the beginning we must specify size of output picture - values in pixels. 
*/

WIDTH = 320
HEIGHT = 200

/*

Now we specify how much cells in x and y direction we want to have. That is important - bigger NX,NY = more stability, accuracy result + longer time of animation rendering. 

*/

NX = 64
NY = 40

/* Physic property - gravity vector. You can give also gravity in x direction */

GX = 0.0
GY = -0.1

/* Time step dt */

DT = 0.5

/* Viscosity of the fluid. Remember, than accuracy and stability of real water (VIS=0.01) it's very low, but it's possible to simulate, but needs much computer time. */

VIS = 0.2


/* Stability criteria. If you don't want to change source code - there you can raise stability criteria. Lower value = more stability, much computer time.*/

STABILITY = 0.1

/* Graphics mode. At the moment possibly:

0 - particles with pressure field color
1 - particles one color set
2 - velocity vectors
3 - particles & vectors

*/

GMODE = 0

/* Particles configuration. At the moment you have 4 posiblities (write it always between "PARTICLES:" and "ENDPAR."):

a) PAR BOX x1,y1,x2,y2,dens,u0,v0 (int,int,int,int,float,float,float)
b) PAR BALL x,y,r,dens,u0,v0 (int,int,int,float,float,float)
c) PAR !BOX x1,y1,x2,y2,dens,u0,v0 (int,int,int,int,float,float,float)
d) PAR !BALL x,y,r,dens,u0,v0 (int,int,int,float,float,float)

ad a)

x1,y1,x2,y2	- screen coordinates. Remember that:

	- x1<x2 and y1<y2
	- x1,x2<WIDTH and y1,y2<HEIGHT

dens		- density of particles per pixel. Like dens=1 mean than there is one particle per pixel, dens = 0.1 mean there are 10 particles per screen pixel.

u0,v0 - beginning x and y direction velocities

*/


PARTICLES:
PAR BOX 1 1 80 130 1 0.0 0.0
PAR BOX 80 1 160 80 1 0.0 0.0
PAR BOX 160 1 240 40 1 0.0 0.0
PAR BOX 240 1 320 180 1 0.0 0.0
ENDPAR.


/*
  "fluid" will take here a cells coordinates for boundaries. Cells
  specify only one closed curve of boundaries. Remember - boundary
  MUST be specified as free slip or no slip boundary - rest as you want.
  You can use 5 types of boundaries.

  FRSLP        -       free slip cell
  NOSLP        -       no slip cell

  i,j are cartesian coordinates of cell (i=(1..nx), j=(1..ny))


You specify always closed curve (really? when you will do 2,3 option files - it will be very easy to use). Anyway you specify points which will be linked by curve. Remember you use [NX x NY] values, becouse you specify bounaries on cells, not on screen. You can use "NX", "NY" values - that is local variable.

*/

/* i j type */


 
BNDCELLS:

 1   1            FRSLP
 NX  1            FRSLP
 NX  NY           FRSLP

 48  NY           FRSLP
 48  7            FRSLP
 46  7            FRSLP
 46  NY           FRSLP
 
 32  NY           FRSLP
 32  7            FRSLP
 30  7            FRSLP
 30  NY           FRSLP
 
 16  NY           FRSLP
 16  7            FRSLP
 14  7            FRSLP
 14 NY            FRSLP

 1   NY           FRSLP
 1   1            FRSLP

ENDBND.


That's All. That and other examples of .opt files in src/opt drawer.

ad 5) End Words.

Some of .opt files examples or when you will start with making your own simulations you will see than something is not good. It's possibly to crash when you will try to make very low viscous value and big stability value. At the beginning try to make viscous bigger. Sometimes it's good to make bigger dt value and lower gy. You can also make lower stability value. Anyway - there is lot of possibilities to make accuracy better.

If you will have ANY problems with source code, or with .opt files don't hesitate to email me - I'll be happy if I will Can help you.

ad 6) Contact.

I will be very happy to receive any .opt files or animations (or screenshots) from you work with my program. It will be very nice if you will email me if you will devlop something with that code. Now it's yours, you can do with it everything you want. 

I have hope you will not release that code, (it was 7 month of hard work), thanx).

If you do something email me i'm very interesting (i wanna still develop my program).

Maciej Matyka

ul. Kielczowska 137/10
51-315 Wroclaw
Poland

mailto://maq@panoramix.ift.uni.wroc.pl
http://panoramix.ift.uni.wroc.pl/~maq


