Basic Scene Setup

We're going to start this tutorial with a new, blank scene. The first step will be to add the demo SimulationEngine prefab to the scene.

This is located under ClosedFlowSystem\Demo\Prefabs\SimulationEngine.
SimulationEngine prefab
SimulationEngine prefab

The SimulationEngine prefab has the FlowEngine and SimulationEngine scripts. The FlowEngine script is what does the flow simulation. The SimulationEngine script starts and stops the flow simulation, and keeps track of all of the flow nodes.

Next we'll add the flow nodes to the scene. In this example we'll just have one holding tank above another, with two pipes connecting them. Start by adding two instances of the HoldingTank4x6 prefab and two instances of the HorizontalStraightPipe prefab to the scene. Then arrange them to look roughly like the below image. Don't worry about getting very exact with your placement.

Approximately placed nodes
Approximately placed nodes

Once you have placed the flow nodes, go back and select the SimulationEngine prefab that was added earlier.  In the inspector, press the Gather Nodes button at the top of the SimulationEngine script area.  This should snap the roughly added nodes to the grid, and add them to the Nodes list on the SimulationEngine.  Your scene/inspector should look something like below.

After nodes have been gathered
After nodes have been gathered
Holding Tank data
Holding Tank data

Now you've got the nodes all set up, but no water.  In this example, we're going to fill the upper tank with water.  To do this, we first need to know where in the grid the upper tank is.  To find out, select the upper holding tank.  As you can see, the holding tank has a Lower Left, and a Width and Height.  In the example to the left, the lower left is (-5,-1), and it is 4 spaces wide and 6 spaces tall (hence the name HoldingTank4x6 ;)).    

We're now going to use that holding tank position data as input to the FlowEngine.  So first select the SimulationEngine GameObject.  In the FlowEngine section of the inspector, put in the holding tank's Lower Left corner as the Range Start, and the holding tank's upper right corner as Range End, then click Add Initial Spaces.  Note that the upper right coordinate is (left + width - 1, bottom + height - 1).  Before you click, it should look something like below, given the holding tank example above.

After clicking, Initial Water Spaces should now have a size of 24.  Now just click play, and watch water flow from one tank to the other!

Water flowing!
Water flowing!

Congratulations, you just finished setting up your first flow simulation!