= Fluid density and distance fields = == Overview == NOTE: Houdini also supports [particle fluids|pfluid_solver], which is an entirely different way of simulating fluids using particles, and [ripples|ripple_solver], which simulate wave propagation across a surface. See [choosing between liquid simulation types|choosefluid]. This type of simulation uses a notional box, called a _field_, which is divided into a three dimensional grid of smaller boxes (sometimes called _voxels_). Each point in this grid stores a piece of data -- an integer, a floating point number, a vector, or other datatype. This kind of fluid simulation is always bounded by the box (the fluid can never go outside the box, though you can set it to disappear if it reaches the boundaries of the box), and the accuracy of the simulation is limited by the resolution of the field (how many sub-boxes the field is divided into). [Image:/images/dynamics/field.png] Houdini's dynamics engine can interpret the values at the points of the field in different ways. === Density field === This type of simulation uses a [Icon:DOP/smokeobject] [Smoke Object|Node:dop/smokeobject] with a [Smoke Solver|Node:dop/smokesolver] in the dynamics network. The value at each point indicates the _density_ of some substance at that point. This is useful for simulating smoke and gases. You can import simulated density fields into geometry networks using the [volume primitive|/model/volumes], which is the geometry equivalent of the dynamics density field. See [input and output of fluid fields|io#fluids]. === Sign distance field === This type of simulation uses a [Icon:DOP/fluidobject] [Fluid Object|Node:dop/fluidobject] with a [Icon:DOP/fluidsolver] [Fluid Solver|Node:dop/fluidsolver] in the dynamics network. The value at each point indicates the _distance to the closest point on the surface_ of a fluid, with the sign of the number (positive or negative) indicating whether the point is inside or outside of the fluid. The fluid's surface connects all points in the field where the "distance to the surface" is 0. This is useful for simulating liquids with surface tension, such as water. [Image:/images/dynamics/sign_distance.png] This is similar to how the [Iso surface node|Node:sop/iso] creates a surface from the boundaries where the value of a 3D formula is 0, and in fact you can use the Iso surface node to import sign distance fields as surface geometry (see [input and output of fluid fields|io#fluids]). == Shelf tools == === Creating field objects === - [Icon:SHELF/box_smoke] [Smoke container|/shelf/smokebox] -- Creates an empty density field. - [Icon:SHELF/box_fire] [Fire container|/shelf/firebox] -- Creates an empty density field set up for burning. - [Icon:SHELF/box_fluid] [Liquid container|/shelf/liquidbox] -- Creates an empty sign distance field. === Adding density/fluid === - [Icon:SHELF/fluid_source] [Source from objects|/shelf/sourcefromobjects] -- Turns an object into a density or liquid generation source. - [Icon:SHELF/convert_to_smoke] [Smoke from object|/shelf/smokefromobject] -- Creates smoke in the shape of an object inside a density field. - [Icon:SHELF/convert_to_fire] [Burst into flames|/shelf/burstintoflame] -- Creates fuel in the shape of an object for burning inside a density field. - [Icon:SHELF/convert_to_fluid] [Liquid from object|/shelf/liquidfromobject] -- Creates liquid surface in the shape of an object in a sign distance field. === Moving and removing density/fluid === - [Icon:SHELF/fluid_sink] [Sink from objects|/shelf/sinkfromobjects] -- Turns an object into a density or liquid removal sink. - [Icon:SHELF/fluid_pump] [Pump from objects|/shelf/pumpfromobjects] -- Turns an object into a pump, which adds velocity to any density or liquid that touches it. - [Icon:SHELF/seedvorticles] [Seed vorticles|/shelf/seedvorticles] -- Creates a large number of tiny invisible paddle-wheels that move with the fluid and push it around inside the box. == Manipulating fluids == - Density and liquid are affected by dynamics forces such as [Gravity|/shelf/gravityforce], [Uniform force|/shelf/uniformforce], [Fan|/shelf/fanforce], and [Wind|Node:dop/windforce]. See [external forces|forces]. - When you use [Icon:SHELF/fluid_source] [Source from objects|/shelf/sourcefromobjects] or [Icon:SHELF/convert_to_smoke] [Smoke from object|/shelf/smokefromobject] to create density from an object, you can select the object in the dynamics network and set the __Temperature__ parameter on the __Physical__ tab in the parameter editor to control the temperature of the birthed smoke (increase the temperature to make the smoke rise). - The [Icon:SHELF/fluid_source] [Source from objects|/shelf/sourcefromobjects] shelf tool adds a [Motion node|Node:dop/motion] called `setsourcevelocity` after the source object. This node is created _bypassed_ (the yellow flag is on, meaning the node has no effect), but you can go into the dynamics network and turn off the bypass flag and use the node to set the initial velocity of the smoke created. - When the [Icon:SHELF/fluid_source] [Source from objects|/shelf/sourcefromobjects] shelf tool sets up an object as a source, it uses a Merge node to create a [source relationship|relationships] between the source object and the fluid object. You can use __Activation__ parameter on this Merge node to animate the source off (Activation = 0) and on (Activation = 1). - If you [set up collision relationships|relationships] between a fluid field and [rigid body objects|rbd_solver], you can push the density/liquid around with the RBD objects. RBD objects with displace sign distance liquid, and push and drag smoke density. If you are using the shelf tools, they usually automatically create collision relationships for you. - Use the shelf tools to set up objects as [sources|/shelf/sourcefromobjects], [sinks|/shelf/sinkfromobjects], and/or [pumps|/shelf/pumpfromobjects] to add, remove, and move density/liquid. - Use [Icon:SHELF/seedvorticles] [Seed vorticles|/shelf/seedvorticles] or add noisy [Wind|Node:dop/windforce] to mix up and add turbulence to smoke. == Visualizing fluid forces == See [fluid visualization|visualization#fluids]. == Velocity and other fields == A fluid object can actually store many different types of information at the points of the field. Houdini itself will store the velocity of the contained fluid at each point for use in calculating the simulation, along with other fields that affect and/or are calculated from the contained fluid. You can see the _velocity field_ using the visualization controls on the fluid object (see [visualization|visualization]). The velocity field and other fields are available as [data|about] attached to the fluid object. The velocity field is named `vel`. Because fields such as velocity are just data on the fluid object, you can copy them _to_ other parts of the simulation, or copy them _from_ other parts of the simulation. See [how to move data around the network|networks]. See the [Gas Advect|Node:dop/gasadvect] solver for how to use the velocity field from one fluid sim to push around another field or points in a piece of geometry. == Tips == - Fluid will not move other dynamic objects via a collision relationship. You must use a [Icon:SHELF/fluid_force][Fluid Force|Node:dop/fluidforce] node. - A good high resolution for fields (for offline/overnight beauty simulations) is about 120 divisions per side. More than 250 divisions per side is probably overkill. - The main output of a fluid simulation is the changing velocity field, which records the motion of the contained fluid. You can run an overnight simulation to "bake out" velocity fields, and then use the baked velocities to use the simulated smoke without actually running the simulation. # Set up an offline (i.e. overnight) simulation of the fluid object. # As part of the offline simulation, [write out|io] the fluid object's velocity field (`vel`) using a [File|Node:dop/file] or [File Data|Node:dop/filedata] node. # Start a separate fluid object simulation and [read in|io] the "baked" velocity data written out by the overnight process.