Skip to content

Small improvements to PerturbationAdvectionOpenBoundaryCondition interface #4394

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

Merged
merged 23 commits into from
May 15, 2025

Conversation

tomchor
Copy link
Collaborator

@tomchor tomchor commented Apr 14, 2025

No description provided.

@tomchor
Copy link
Collaborator Author

tomchor commented Apr 18, 2025

@jagoosw can you please write a couple of sentences about inflow_timescale and outflow_timescale? Maybe expand a bit about the implications about the choice of backward vs forward stepping method?

@tomchor tomchor requested a review from jagoosw May 14, 2025 12:12
@jagoosw
Copy link
Collaborator

jagoosw commented May 14, 2025

Sorry it took me so long to get to this. I have added some sentences about the timescales but am not sure what to put for the stepping options. I think we should have removed the forward stepping before merging because I can't convince myself that it is valid.

@tomchor
Copy link
Collaborator Author

tomchor commented May 14, 2025

Sorry it took me so long to get to this. I have added some sentences about the timescales but am not sure what to put for the stepping options. I think we should have removed the forward stepping before merging because I can't convince myself that it is valid.

I'm okay with that. @glwagner are you okay with this?


Creates a `PerturbationAdvectionOpenBoundaryCondition` with a given `outflow_timescale` and
`inflow_timescale`. `backward_step` determines whether we assume a backward and forward time
discretization. For details about this method, refer to the docstring for `PerturbationAdvection`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the docstring doesn't describe what val is. I'm also confused, would a better name than val help?

Copy link
Collaborator Author

@tomchor tomchor May 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

val is the exterior value of the normal valocity. The one we're relaxing the flow to (with inflow_timescale during inflow and with outflow_timescale with during outflow). I agree it isn't a very intuitive name. Maybe just exterior_value?

@glwagner glwagner marked this pull request as ready for review May 14, 2025 15:51
@glwagner
Copy link
Member

I'm ok with any improvement. I don't know what "forward stepping" is but with more detail I can give feedback on that.

@jagoosw
Copy link
Collaborator

jagoosw commented May 15, 2025

I'm ok with any improvement. I don't know what "forward stepping" is but with more detail I can give feedback on that.

At the moment you can make the boundary do a forward or backwards Euler step and backwards is the default. I did some testing with forward stepping (I can't remember why) but I was never convinced that it was sound because we have the interior values at almost $t(n+1)$ not $t(n)$, but then I didn't remove it before we merged the PR (again, don't remember why).

@tomchor
Copy link
Collaborator Author

tomchor commented May 15, 2025

I'm ok with any improvement. I don't know what "forward stepping" is but with more detail I can give feedback on that.

At the moment you can make the boundary do a forward or backwards Euler step and backwards is the default. I did some testing with forward stepping (I can't remember why) but I was never convinced that it was sound because we have the interior values at almost t ( n + 1 ) not t ( n ) , but then I didn't remove it before we merged the PR (again, don't remember why).

I also did a bit of testing and (also don't remember why, but) ended up not liking the forward step too much. So I support removing it :)

Δt = ifelse(isinf(Δt), 0, Δt)

ūⁿ⁺¹ = getbc(bc, l, m, grid, clock, model_fields)

uᵢⁿ = @inbounds getindex(u, boundary_indices...)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jagoosw this isn't critical but I'd appreciate some clarity here. In your derivation you arrive at the equation

uⁿ⁺¹ = (uᵢⁿ + Ũuᵢ₋₁ⁿ⁺¹ + Uⁿ⁺¹τ̃) / (1 + τ̃ + U)

and from it, I understand that uᵢⁿ is the normal velocity at the previous time-step. However, here you're defining uᵢⁿ using the current time-step, no? Am I misunderstanding something?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is where we get the previous value of the boundary point since it hasn't been stepped yet so its still at the previous time step, and then put uⁿ⁺¹ in the same place to bring the whole field to the current time step.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see, thanks for the clarification. Just to clarify even further, the way time-stepping works is that the interior of the flow is time-stepped first, then we do the boundaries?

@tomchor tomchor merged commit 1f47ee0 into main May 15, 2025
58 checks passed
@tomchor tomchor deleted the tc/perturb-adv-obc-tweaks branch May 15, 2025 23:29
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

Successfully merging this pull request may close these issues.

3 participants