FLIP: turning water into light-weight, floating foam

   6080   6   3
User Avatar
Staff
4159 posts
Joined: Sept. 2007
Offline
I'm working on replicating this Naiad test (https://vimeo.com/25020677 [vimeo.com]), and after getting some help over on odforce (http://forums.odforce.net/topic/21936-varied-density-in-flip-low-density-not-rising/?p=130572 [forums.odforce.net], but I'm hitting two issues now:

- The foam doesn't collect together very well; I've got super high viscosity (both high point values, and a high multiplier on the solver), but there must be something else I'm missing?
- Although I can get the less dense foam to rise up, it's not very fast; but I can only get it to go slow, or shoot out like a cannon. Is there some way to direct the foam to float up to the top very quickly, but then just rest once it gets there?

Thanks!

Attachments:
foamy_flip_liquid.hipnc (1.7 MB)
2015-02-12--1423788226_screenshot.png (266.8 KB)

I'm o.d.d.
User Avatar
Member
30 posts
Joined: May 2012
Offline
You can volume sample SDF against each foam particle. Then you can get SDF value ant use it as multiplier to drive up vector to make particles go straight up. Now you can multiply this vector by value between 0-1 to decide how fast you want the foam to rise.
Check this for example:
https://www.sidefx.com/index.php?option=com_content&task=view&id=2157&Itemid=132 [sidefx.com]
User Avatar
Staff
809 posts
Joined: July 2006
Offline
Cool test.

You've got the right idea with your setup, but your Mix Method for Divergence and Viscosity attributes are set to Multiply, which I don't think is what you want. That method multiplies the particle attribute value with the default field value as specified on the FLIP Object's Physical tab. So in this case you're multiplying your density and viscosity attributes by the default values of 1000 and 0, respectively. You end up with very high density values and zero viscosity everywhere. With your setup just use Copy for both, since you're explicitly setting the particle values to represent the final density / viscosity values.

In general it's a *really* good idea with a complex setup like this to turn on the visualization for the Density and Viscosity fields, set the Guide Ranges appropriately, and inspect the field values directly. The field values are what the solvers actually use.

Some other notes:

- You likely won't need Stick on Collision; likely you had to turn it on since viscosity wasn't working.

- You don't need a mass attribute as it has no effect for FLIP.

- I turned off Particle Separate as I don't like the look, but of course that's subjective.

- With Reseeding you probably don't want to interpolate viscosity and density. For the most part this is a “two-phase” simulation of different liquids, so when new particles are created they should be one fluid or the other, not somewhere in between (unlike, for example, a melting simulation)

- Because it's a two-phase simulation, you might try decreasing the Grid Scale to 1.5 or so, which just makes it more likely a voxel is purely one fluid or the other. If you do that, likely change the Particles per Voxel to 4 (well, really pow(gridscale, 3) but 4 is close enough)

- For speed, I moved the bricker on your box option into the source geometry, changed substeps back to 2 and switched to 32-bit accuracy for viscosity.

- You don't need very high viscosity for this setup. I got decent results with density = 150, viscosity = 250 for the foam, but obviously you'll need to tweak.

- When tweaking your density and viscosity values, remember that we use dynamic viscosity units, which are then divided by density. So a given viscosity value will have a greater effect on less dense fluid. It might make sense to tweak kinematic viscosity values, then just set @viscosity = kvisc * @density;

- Finally this is another situation where you might want higher viscosity values but not want the foam to stick to the paddle that much. You can use the trick / hack / cheat I described here [sidefx.com] to make the foam stick to the paddle less.

I've attached a file with these changes as a start.

Attachments:
foamy_flip_liquid_copy.hipnc (1.7 MB)

User Avatar
Staff
4159 posts
Joined: Sept. 2007
Offline
Wow! That's exactly what I where I've been trying to go; and the explanations are extremely helpful, thank you johnr! I think that my block was diving too deep (deeper than jason's naiad test), so it was collecting way more foam than his. I tried animating it to be more shallow, but I suppose I could only transfer to points near the surface as well.

Just a couple of things I don't fully understand:

- Is kvisc an attribute the solver knows about? I thought the FLIP Solver had a chart of attributes it inherits (ala Bullet and POP Solvers), but maybe I'm imagining it?

- The optimization tips are great; for viscosity accuracy, is there a reason the default is 64-bit, and not 32-bit?

- For visualizing the different fields, is it possible those could get a 3d mode that isn't smoke? I'd really like to see it with a field of points changing color (or maybe even scaling up/down); it's so handy looking at vel this way, it'd be great to see scalars in 3d as well. I peaked inside, but couldn't find if those Visualizers could be modified…

I appreciate the detailed answers/help, it's really helped me get my head wrapped around this!

pavel, thanks for the suggestion and links! I'll check those out!

Attachments:
2015-02-13--1423816153_screenshot.png (188.0 KB)

I'm o.d.d.
User Avatar
Staff
809 posts
Joined: July 2006
Offline
goldleaf
- Is kvisc an attribute the solver knows about? I thought the FLIP Solver had a chart of attributes it inherits (ala Bullet and POP Solvers), but maybe I'm imagining it?

Sorry no, I just meant you might find a viscosity setting you like, but want the foam to float more. If you change the density you have to change the viscosity as well. So in your AttribWrangle it might be easier to do something like:

float kvisc = 1.5;
@density = 150;
@viscosity = @density * kvisc;


Then just tweak kvisc and not worry about it the viscosity behavior changing when you change density.

goldleaf
- The optimization tips are great; for viscosity accuracy, is there a reason the default is 64-bit, and not 32-bit?

It's more accurate for high viscosity (and matches cloth's similar default). But for low viscosity like this (and if you want to run the solver on the GPU) it can be a bit faster to run in 32-bit.

goldleaf
- For visualizing the different fields, is it possible those could get a 3d mode that isn't smoke? I'd really like to see it with a field of points changing color (or maybe even scaling up/down); it's so handy looking at vel this way, it'd be great to see scalars in 3d as well. I peaked inside, but couldn't find if those Visualizers could be modified…

That's an interesting RFE (please submit it), not sure how hard it would be. I usually just use planes and slide them around to see the parts I'm interested in.
User Avatar
Staff
4159 posts
Joined: Sept. 2007
Offline
Here's a little render: https://vimeo.com/119619724 [vimeo.com]

johner
Then just tweak kvisc and not worry about it the viscosity behavior changing when you change density.

Ah, got it! That makes sense

johner
It's more accurate for high viscosity (and matches cloth's similar default). But for low viscosity like this (and if you want to run the solver on the GPU) it can be a bit faster to run in 32-bit.

Great to know, thanks!

johner
That's an interesting RFE (please submit it), not sure how hard it would be. I usually just use planes and slide them around to see the parts I'm interested in.

Submitted via webform, I'll post an RFE number when I get one back from support.

Thanks!

*edit*

Attached my hip file that corresponds to the Vimeo movie.

Attachments:
foamy_flip_liquid_copy_351_modified.hipnc (3.4 MB)

I'm o.d.d.
User Avatar
Staff
4159 posts
Joined: Sept. 2007
Offline
RFE #67015: Visualize scalers with 3d point cloud

Thanks johner
I'm o.d.d.
  • Quick Links