I think I've had something of a breakthrough on this project. Think about this for a bit:
Ultimately, the simulation is just a kind of inefficient sorting operation. Fluids travel from higher places to lower places. Other things get in the way. If things aren't falling, then they might migrate side to side.
Sorting is a hard problem, but it's one that a lot of effort has been poured into. Python particularly has some good sorts written in optimized C.
We already use Python's sort functions in the code, to arrange the positions of different slices of liquid in a single cell. My idea is to extend it beyond that cell -- to sort whole columns of fluid at once.
The biggest problem with this is that sorting works too well -- heavy fluid will transmigrate from the top of a column to the bottom instantly, with no possibility of affecting anything along the way. There needs to be some way to limit how far an individual slice of fluid can travel in its passage. There are no sorts that I'm aware of that support this kind of travel limiting, but it might be doable using a Python trick more frequently used back in older versions, called Decorate-Sort-Undecorate. That is, you first modify the contents to encode additional information into it that weights each item in the sort by some variable, in this case that would be initial position in the column. The weights would have to be chosen in such a way that the fluid weights would overpower the positional weights over short distances but not long ones. Then we sort the column, then remove the extra information (or in our case, overwrite it with new positional information the next time we do a sort).
Another problem is that we would still need to make another pass through each column to handle sideways motion.
How does that sound to you folk?