From BlenderWiki

Jump to: navigation, search

[edit] Fluid Simulation

The following chapter describes how to animate liquids using the fluid simulator integrated in Blender since version 2.40.


A breaking dam example animation.

[edit] Workflow Overview

  • While modeling a scene with blender certain objects can be marked to participate in the fluid simulation, e.g. as fluid or as an obstacle. The bounding box of another object will be used to define a box-shaped region to simulate the fluid in.
  • The global simulation parameters such as viscosity and gravity can be set for this domain object.
  • Using the "bake" button geometry & settings are exported to the simulator and the fluid simulation is performed, generating a surface mesh together with a preview for each animation frame, and saving them to hard disk.
  • The appropriate fluid surface for the current frame is loaded from disk and displayed or rendered in Blender.

The two pictures above and below this paragraph are an example of fluid animations created with the El'Beem simulator in Blender (and rendered using Yafray).

Another example animation of a falling drop.



[edit] Explanation of GUI-Settings:

The basic (and frequently needed) fluid simulation options
Less frequentrly needed advanced options

Screenshot of the current gui for a domain object. After enabling the fluid simulation for an object, the type can be chosen (domain,fluid,obstacle,...) yielding further settings for each type.

After enabling the fluid simulation for a mesh object, the following five object types are available.

  • Domain: the bounding box of this object will be the boundary of the simulation. Note that the shape of the object does not matter (so usually there won't be a reason to use any other shape than a box). If you need obstacles or other boundaries than a box you need to insert additional obstacle objects. Currently there should be only a single fluid simulation domain object. The lengths of the bounding box sides can be different.
    • Resolution: The resolution at which the actual fluid simulation is performed. This is probably the most important setting for the simulation as it determines the amount of detail in the fluid, the memory and disk usage as well as computational time. Note that the amount of required memory quickly increases: a resoltion of 32 requires ca. 5MB, 64 requires ca. 40MB, while 128 already needs more than 250MB. Make sure to set the resolution low enough, depending on how much memory you have, to prevent Blender from crashing or freezing. If the domain is not cubic, the resolution will be taken for the longest side. The resolutions along the other sides will be reduced according to their lengths.
    • Preview-Res.: This is the resolution at which the preview surface meshes will be generated. So it does not influence the actual simulation, and even if there is nothing to see in the preview, there might a thin fluid surface that cannot be resolved in the preview.
    • Start time: Simulation time (in seconds) of the first blender frame. So this option makes the animation in Blender start later in the simulation.
    • End time: Simulation time of the last blender frame.
    • Disp.-Qual.: How to display a baked simulation in the Blender GUI (first pulldown menu) and for rendering (second one): original geometry, preview mesh or final mesh. When no baked data is found, the original mesh will be displayed by default.
    • Bake directory: Directory and file prefix to store baked surface meshes with. This is similar to the animation output settings, only selecting a file is a bit special: when you select any of the previously generated surface meshes (e.g. untitled_OBcube_fluidsurface_final_0132.bobj.gz) the prefix will be automatically set (untitled_OBcube_ for this example). This way the simulation can be done several times with different settings, and allows quick changes between the different sets of surface data.
    • Bake-Button: Perform the actual fluid simulation. The blender GUI will freeze and only display the current frame that is simulated. Pressing ESCAPE will abort the simulation. Afterwards two .bobj.gz will be in the selected output directory for each frame.

    • Advanced-Button: Clicking this button will show some more advanced options, that usually don't have to be modified often.
    • Gravity vector: Strength and direction of the gravity acceleration. Currently the main component should be along the negative z-axis [m/s^2]. Currently this should not be all zero (at least some small number).
    • Viscosity: Viscosity, meaning "thickness" of the fluid. You can either enter a value directly of use one of the presets. For manual entry, the value is specified by a floating point number that should be aroung 1.0, and a negative exponent. This simplifies entering very small numbers, as the viscosity of e.g. water is around 10 to the minus six.
    • Real-World size: Size of the domain object in the real world in meters. If you want to create a glass of water, this might be 0.2 meters, while for a single drop a centimeter (thus 0.01m) will be more suitable. The size set here is for the longest side of the domain bounding box.
    • Gridlevel: How many adaptive grid levels to be used during simulation - setting this to -1 will perform automatic selection.
    • Compressibillity: If you have problems with large standing fluid regions at high resolution, it might help to reduce this number (note that this will increase computation times).

  • Fluid: All regions of this object that are inside the domain bounding box will be used as actual fluid in the simulation. If you place more than one fluid object inside the domain, they should currently not intersect. Also make sure the surface normals are pointing outwards. In contrast to domain objects, the actual mesh geometry is used for fluid objects.
    • Initial velocity: Speed of the fluid at the beginning of the simulation in meters per second.

  • Obstacle: This object will be used as obstacle in the simulation. As with fluid object, obstacle objects should currently not intersect. As for fluid objects, the actual mesh geometry is used for obstacles.
    • No settings as of now...

  • Inflow: This object will put fluid into the simulation (think of a water tap).
    • Initial velocity: Speed of the fluid that is created inside of the object.

  • Outflow: Any fluid that enters the region of this object will be deleted (think of a drain). This can be useful in combination with an inflow to prevent the whole domain from filling up.
    • No settings here...


[edit] Some Background Information

Fluid animation can take a lot of time - the better you understand how it works, the easier it will be to estimate how the results will look. The algorithm used for this project is the Lattice Boltzmann Method (LBM), other approaches are Navier-Stokes (NS) solvers and Smoothed Particle Hydrodynamics (SPH) methods. LBM can be imagined to lie somewhere between those two. In general it is really hard for current computers to correctly simulate even a 1-meter tank of water. For simuatling a wave crashing through a city, you would probably need one of the most expensive supercomputer you could get, and it might still not work properly - no matter which of the 3 algorithms above you're using.

But, similar to what film makers have been doing in "analogue" movies for years, you can pretend to have a wave in a city by building a smaller model, have a small wave in the model, and hope that nobody will notice the difference between a 100m and a 1m wave. For the LBM solver, the following things will make the simulation harder to compute:

  • large domains
  • long duration
  • low viscosities
  • and high velocities.

The viscosity of water is already really low, so especially for low resoltuions, the turbulence of water can not be correctly captured. If you look close, most simulations of fluids in computer graphics do not yet look like real water as of now. Generally, don't rely on the physical settings too much (such as physical domain size or length of the animation in seconds). Rather try to get the overall motion right with a low resolution, and then increase the resolution as much as possible or desired.


[edit] Notes / FAQ / Known problems

  • Don't be surprised, but you'll get whole bunch of mesh (.bobj.gz) files after a simulation... basically 2 for each frame, they contain the simulation result - so you'll need them. Currently these files will not be automatically deleted, so it is a good idea to e.g. create a dedicated directory to keep simulation results. Doing a fluid simulation is similar to clicking the ANIM button - you currently have to take care of organizing the fluid surface meshes in some directory yourself. If you want to stop using the fluid simulation, you can simply delete all the *fluid*.bobj.gz files.
  • If the setup seems to go wrong make sure all the normals are correct (hence enter edit mode, select all, recalculate normals once in a while).
  • Before running a high res simulation that might take hours, check the overall timing first by doing lower resultion runs.
  • Only the bounding box of the domain object is used, but fluid and obstacle objects can be meshes with complex geometries. Very thin might not appear in the simulation, though, if the chosen resolution is too coarse to resolve them (increasing it might thus solve this problem).
  • Currently there's a problem with zero gravity simulation - simply select a very small gravity until this is fixed.
  • Note that all animated parameters or objects are not taken into account during the simulation. Only the inital setup at frame 1 is used, but this will be possible in future versions.
  • Blender freezes after clicking BAKE, pressing Escape makes it work again after a while - this can happen if the resolution is too high and memory is swapped to hard disk, making everything horribly slow. Reducing the resolution should help in this case.
  • Blender crashes after clicking BAKE - this can happen if the resolution is really high and more than 2GB are allocated, causing Blender to crash. Reducing the resolution should also help...
  • The meshes should be closed, so if some parts of e.g. a fluid object are not initialized as fluid in the simulation check that all parts of connected vertices are closed meshes. Unfortunately, the Suzanne (monkey) mesh in Blender is not a closed mesh (the eyes are separate).
  • If you're having trouble, or something isn't working as you think it should - just let me know: send the .blend file and a problem description to =nils at thuerey dot de=.


Another fluid simulation example created with Blender and Yafray


[edit] Further Information


[edit] Acknowledgements

The integration of the fluid simulator was done as a Google Summer-of-Code project. More information about the solver can be found at www.ntoken.com. These Animations were created with the solver before its integration into blender: Adaptive Grids, Interactive Animations. Thanks to Chris Want for organizing the Blender-SoC projects, and to Jonathan Merrit for mentoring this one! And of course thanks to Google for starting the whole thing... SoC progress updates were posted here: SoC-Blenderfluid-Blog at PlanetSoC.

The solver itself was developed with help and supervision of the following people: U. Ruede, T. Pohl, C. Koerner, M. Thies, M. Oechsner and T. Hofmann at the Department of Computer Science 10 (System Simulation, LSS) in Erlangen, Germany.

http://www10.informatik.uni-erlangen.de/~sinithue/img/lsslogo.png       http://www10.informatik.uni-erlangen.de/~sinithue/img/unierlangenlogo.png









Redirects to fix

  • Manual/PartX/Hard Bodies → Manual/Rigid Bodies
  • Manual/PartX/Soft Bodies → Manual/Soft Bodies
  • SoCFluidDevelDoc → Dev:Ref/GSoC/2005/FluidAnimation/Development
  • SoCFluidTutorial1 → Dev:Ref/GSoC/2005/FluidAnimation/Tutorial 1
  • SoCFluidTutorial2 → Dev:Ref/GSoC/2005/FluidAnimation/Tutorial 2
  • SoCFluidTutorialChanges → Dev:Ref/GSoC/2005/FluidAnimation/Tutorial Changes