Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Applying free stream boundary condition #152

Open
KarlisFre opened this issue Jan 31, 2024 · 3 comments
Open

Applying free stream boundary condition #152

KarlisFre opened this issue Jan 31, 2024 · 3 comments

Comments

@KarlisFre
Copy link

Hi,
Many thanks for implementing Free stream boundary condition #138. It works nicely on scalar fields. But how to use it on the velocity field?
I am willing to set up the velocity field and apply advection on it, something like this:

v = StaggeredGrid(Noise(vector='x,y'), InOutConditionalExtrapolation(???),x=32, y=32)
v = advect.semi_lagrangian(v, v, dt=0.1)
v, p = fluid.make_incompressible(v)

Unfortunately there is no way to get velocity values to construct the InOutConditionalExtrapolation.
The idea is that when the velocity leaves the boundary, it should be able to do it freely (like zero_gradient), but when is pointed inside, the velocity outside the boundary is treated as zero and the solver inside the make_incompressible decreases the pressure near boundary to be able to drag the flow inwards.
Any suggestions how to make it work?

@holl-
Copy link
Collaborator

holl- commented Feb 5, 2024

Hi @KarlisFre, that is a bit tricky because in that case the extrapolation requires all values of the field it's used for. I see two ways of doing this:

  • Either we create the field first and then do something like v.with_extrapolation(InOutExtrapolation(v)) or
  • We amend the extrapolation system to handle this sort of dependency natively, then the extrapolation would not require any external dependencies, i.e. StaggeredGrid(..., InternalInOutConditionalExtrapolation(in, out)). This would only be available for Φ-Flow version 3.0 and above.

Let me know what you think!
Cheers

@KarlisFre
Copy link
Author

If I do v.with_extrapolation(InOutExtrapolation(v)), would it work correctly in v = fluid.make_incompressible(v)? Velocity is changed inside it and will the result correctly conform to boundary condition that is dependent on v?

@holl-
Copy link
Collaborator

holl- commented Feb 6, 2024

I think the InOutExtrapolation I sent is not compatible with staggered grids yet. I can look into this but there may be some difficulties when it comes to which values actually need to be stored. Performing the pressure solve on a centered grid may be easier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants