As a reminder, flow routing involves computing the discharge for a cell resulting from the accumulation of precipitation over a stream tree. This tree is implicitly defined by the relationship between a cell and its downstream recipient . We can also travel upstream by defining a donor of as a node , such that . We write the set of up to 4 donors of as . In practice, we store the donors in an matrix, with an accompanying list of the number of donors per cell. This matrix is derived by parsing the cells in parallel. Each cell increases the donor count of its recipient with atomic operations and adds its position to the donors of .
4. Flow routing
Water flows downstream from donor cells to recipients, and therefore the flow routing problem consists of accumulating all of the upstream precipitation:
Note that this is a recursive definition so that the discharge at a cell is the sum of the precipitation falling on the cell and the discharge from all donor cells.