A simple fluid simulator using physics-based method guided by these two tutorials: http://www.dgp.toronto.edu/people/stam/reality/Research/pdf/ns.pdf and https://www.cs.ubc.ca/~rbridson/fluidsimulation/fluids_notes.pdf.
-
Dependencies:
-
Compile instructions: In order to compile and execute the project correctly, you'll want to have the requirements above filled. Pay attention to the glad item, you SHOULD download the right
glad.cfile from the website according to your specific environment and modifyPATH_TO_FILE_glad.cinCMakeList.txtwith the correct path to it. The remaining part is quite simple. Suppose you are now in the directory containing theCMakeList.txtfile and all those source codes, just build the project with the following commands:mkdir buildcd buildcmake ..makeormake -jX(where X is the number of CPU cores you want to use)
Hopefully the executable file named
ToyFluidSimProjappears in the build directory. Click it and it will start simulating untilEsckey is pressed. -
Notes:
-
This project offers the flexibility to set some user-defined parameters: number of grid cells in x-direction (
Nx) and in y-direction (Ny), position of the inlets, fluid velocity at the inlet, and viscosity of the fluid(visc).NxandNyare global const variables at the top of themain.cppfile, while parameters concerning the inlets is set at the beginning of the main function (seesmlt.setInlet()), andviscis set throughsmlt.setVisc(). -
Some examples of simulation can be found in the
examplesdirectory. Their corresponding settings are listed below:-
fluid1: Nx=200, Ny=100, smlt.setInlet(3, {33, 33}, {3, 3}, 3, {33, 66}, {3, -3}), no viscosity
-
fluid2: Nx=200, Ny=100, smlt.setInlet(2, {33, 66}, {3, 0}, 2, {166, 66}, {-3, 0}), no viscosity
-
fluid3: Nx=200, Ny=100, smlt.setInlet(2, {33, 66}, {3, 0}, 2, {166, 66}, {-3, 0}), visc=0.07
-
fluid4: Nx=200, Ny=100, smlt.setInlet(2, {33, 66}, {3, 0}, 2, {166, 66}, {-3, 0}), visc=0.3
-
-