Fluid Initial Velocity 'Source' incorrect when enabling Inflow #80833

Closed
opened 2020-09-16 12:19:40 +02:00 by Rich Sedman · 10 comments

System Information
Operating system: Windows-10-10.0.19041-SP0 64 Bits
Graphics card: Intel(R) HD Graphics 5500 Intel 4.4.0 - Build 20.19.15.4835

Blender Version
Broken: version: 2.91.0 Alpha, branch: master, commit date: 2020-09-11 09:14, hash: 1b6dd42803
Worked: N/A

Short description of error
When enabing the 'Use Flow' of an Inflow Liquid mesh, the initial velocity of the fluid is incorrectly calculated.

Exact steps for others to reproduce the error
Use Quick Liquid to create the domain around the default cube. Set the cube to 'Inflow'. Enable Initial Velocity with Source set to 1.0 (the default). Animate the cube moving around the domain. Keyframe Use Flow to start with the inflow disabled. Enable the inflow while the inflow mesh is in motion. The initial frame of fluid has the wrong starting velocity (typically zero for the first frame). If the Use Flow is disabled and re-enabled later in the animation the next frame of fluid seems to have a velocity determined by the difference in position between the current location and that where the inflow was last 'switched off'.

Blend file provided containing an animated inflow fluid inflow switching on initial velocity error.blend
The inflow is switched on at various points - first at 90 degrees into the animation where the fluid is initially stationary (but should be travelling to the left), then at 270 degrees where the fluid is travelling allong the y-axis (but should be travelling parallel to the x-axis as that's the direction of travel of the mesh - it would appear to be following a line between its current position and that where it was last 'switched off') and finally at the 'start point' of the animation - where the fluid should travel parallel to the y-axis - but actually travels diagonally.
fluid initial velocity.gif

**System Information** Operating system: Windows-10-10.0.19041-SP0 64 Bits Graphics card: Intel(R) HD Graphics 5500 Intel 4.4.0 - Build 20.19.15.4835 **Blender Version** Broken: version: 2.91.0 Alpha, branch: master, commit date: 2020-09-11 09:14, hash: `1b6dd42803` Worked: N/A **Short description of error** When enabing the 'Use Flow' of an Inflow Liquid mesh, the initial velocity of the fluid is incorrectly calculated. **Exact steps for others to reproduce the error** Use Quick Liquid to create the domain around the default cube. Set the cube to 'Inflow'. Enable Initial Velocity with Source set to 1.0 (the default). Animate the cube moving around the domain. Keyframe Use Flow to start with the inflow disabled. Enable the inflow while the inflow mesh is in motion. The initial frame of fluid has the wrong starting velocity (typically zero for the first frame). If the Use Flow is disabled and re-enabled later in the animation the next frame of fluid seems to have a velocity determined by the difference in position between the current location and that where the inflow was last 'switched off'. Blend file provided containing an animated inflow [fluid inflow switching on initial velocity error.blend](https://archive.blender.org/developer/F8888651/fluid_inflow_switching_on_initial_velocity_error.blend) The inflow is switched on at various points - first at 90 degrees into the animation where the fluid is initially stationary (but should be travelling to the left), then at 270 degrees where the fluid is travelling allong the y-axis (but should be travelling parallel to the x-axis as that's the direction of travel of the mesh - it would appear to be following a line between its current position and that where it was last 'switched off') and finally at the 'start point' of the animation - where the fluid should travel parallel to the y-axis - but actually travels diagonally. ![fluid initial velocity.gif](https://archive.blender.org/developer/F8888658/fluid_initial_velocity.gif)
Author

Added subscriber: @BaldingWizard

Added subscriber: @BaldingWizard

Added subscriber: @iss

Added subscriber: @iss

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'

I can confirm inconsistency here.

I am not sure how object velocity is calculated internally, but it will be likely between 2 discrete steps, so you will never get truly tangential trajectory. How off you will be depends on granularity of steps (this may be from one frame to another). In this case you may be better off with invisible individual flow objects correctly aimed and just trigger them at right time.

I can confirm inconsistency here. I am not sure how object velocity is calculated internally, but it will be likely between 2 discrete steps, so you will never get truly tangential trajectory. How off you will be depends on granularity of steps (this may be from one frame to another). In this case you may be better off with invisible individual flow objects correctly aimed and just trigger them at right time.
Author

The example (using a rotating inflow) is just to demonstrate the problem - I wasn't actually aiming for realistic tangential flow. The point is that the inflow isn't using the previous frame to determine the velocity but is actually using the last frame that the inflow was switched on. So in the first 'emission' in the above case (in the "12-o'clock" position) the fluid has no velocity - not because the inflow wasn't moving but purely because it's the first frame of emission of fluid (so it seems the calculation doesn't have a 'start' position to determine the offset).

In the second case (at "6-o'clock" position) the emission is moving southwards - not because of the inflows current motion but purely because the last frame it emitted was directly to the "north" of its current position. Similarly for the "3-o'clock" position, it's only emitting diagonally because the last time it emitted it was at the "6-o'clock" position.

If you take the above example and add an additional 1-frame emission of fluid at, say, "9-o'clock", the direction of the next emission ("6-o'clock") changes - purely due to the "last frame of fluid emission" being in a different location. The historic state of emission or not should not affect the velocity when the inflow is next switched on.

It's difficult to explain. I could add another animated GIF to demonstrate the above change in behaviour (adding a 9-o'clock emission) if that would make things clearer.

In summary, pulsing an inflow on/off should not be affected by the location of the last time it was pulsed on/off - and the first pulse should not be always zero velocity (due it it never having been 'on' before).

The example (using a rotating inflow) is just to demonstrate the problem - I wasn't actually aiming for realistic tangential flow. The point is that the inflow isn't using the previous frame to determine the velocity but is actually using the *last frame that the inflow was switched on*. So in the first 'emission' in the above case (in the "12-o'clock" position) the fluid has no velocity - not because the inflow wasn't moving but purely because it's the first frame of emission of fluid (so it seems the calculation doesn't have a 'start' position to determine the offset). In the second case (at "6-o'clock" position) the emission is moving southwards - not because of the inflows current motion but purely because the last frame it emitted was directly to the "north" of its current position. Similarly for the "3-o'clock" position, it's only emitting diagonally because the last time it emitted it was at the "6-o'clock" position. If you take the above example and add an additional 1-frame emission of fluid at, say, "9-o'clock", the direction of the next emission ("6-o'clock") changes - purely due to the "last frame of fluid emission" being in a different location. The historic state of emission or not should not affect the velocity when the inflow is next switched on. It's difficult to explain. I could add another animated GIF to demonstrate the above change in behaviour (adding a 9-o'clock emission) if that would make things clearer. In summary, pulsing an inflow on/off should not be affected by the location of the last time it was pulsed on/off - and the first pulse should not be **always** zero velocity (due it it never having been 'on' before).
Member

Added subscribers: @sebbas, @JacquesLucke

Added subscribers: @sebbas, @JacquesLucke
Member

I can see and reproduce the issue. This is another well-intentioned optimization with unexpected consequences (@sebbas). The issue is that escape_flowsobject tells the simulation to completely skip inflow objects that have their inflow disabled. However, this also skips storing the current vertex positions so that the velocity can be computed next frame.
I can think of two possible solutions:

  • Store the current vertex positions of inflow objects in every frame, regardless of whether inflow is enabled or not.
  • Evaluate the vertex positions from the previous frame/subframe in the current frame. This way we would not have to store the previous vertex positions at all. Another advantage of this is that we do not depend on the previous frames information. Disadvantages are that it might be slower (although that might be negligible compared to the actual simulation) and it might not work in some cases that are not supported by `BKE_object_modifier_update_subframe.

A hybrid approach might work as well: In the normal case we store the current vertex positions for the next frame. With that we can also store the frame these positions come from. If they are too old, we can use BKE_object_modifier_update_subframe to compute the vertex positions at a previous frame on the fly.

I can see and reproduce the issue. This is another well-intentioned optimization with unexpected consequences (@sebbas). The issue is that `escape_flowsobject` tells the simulation to completely skip inflow objects that have their inflow disabled. However, this also skips storing the current vertex positions so that the velocity can be computed next frame. I can think of two possible solutions: * Store the current vertex positions of inflow objects in every frame, regardless of whether inflow is enabled or not. * Evaluate the vertex positions from the previous frame/subframe in the current frame. This way we would not have to store the previous vertex positions at all. Another advantage of this is that we do not depend on the previous frames information. Disadvantages are that it might be slower (although that might be negligible compared to the actual simulation) and it might not work in some cases that are not supported by `BKE_object_modifier_update_subframe. A hybrid approach might work as well: In the normal case we store the current vertex positions for the next frame. With that we can also store the frame these positions come from. If they are too old, we can use `BKE_object_modifier_update_subframe` to compute the vertex positions at a previous frame on the fly.

Yes, that was too much optimization.

I am trying out an approach of idea (1) as getting vertex velocities is not the expensive part. If I remember correctly BKE_object_modifier_update_subframe should just be used if it is really needed. It was invoking quite a chain of calls ..

Also, a similar fix will be needed for escape_effectorobject to prevent issues with Use Effector.

Yes, that was too much optimization. I am trying out an approach of idea (1) as getting vertex velocities is not the expensive part. If I remember correctly `BKE_object_modifier_update_subframe` should just be used if it is really needed. It was invoking quite a chain of calls .. Also, a similar fix will be needed for `escape_effectorobject` to prevent issues with `Use Effector`.

This issue was referenced by bda274d1fe

This issue was referenced by bda274d1fef8774383d7e89847726e7dc7b3a9a3

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Sebastián Barschkis self-assigned this 2020-09-23 15:54:56 +02:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
5 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#80833
No description provided.