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

Default free surface for distributed grids #4061

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

simone-silvestri
Copy link
Collaborator

This PR proposes a default free surface for distributed grids.

A distributed grid requires knowing apriori the number of subcycling steps of the barotropic solver.
Here I have hardcoded 60 because I tend to think it is a rather safe default for domains that have a depth similar to the one of the ocean and do not have terribly stretched horizontal coordinates. The free surface speed tends to be about 100 times faster than the maximum advection speed accounting for about 6km depth and 10m2/s gravitational acceleration.
Taking into account that the CFL for the free surface is typically much larger than the one for advection we reach a factor of about 60 difference.

However, hardcoding a substep number might be a bit wasteful if the domain is shallow (probably not a big problem as the free surface solver is very cheap), and a little dangerous if we use better time-stepping schemes for the baroclinic step which allow a higher CFL for advection or the domain is very deep.

What do people think?

@glwagner
Copy link
Member

glwagner commented Jan 24, 2025

I recommend explicitly making default_free_surface depend on the time-step and then computing the number of substeps using a CFL criterion in the function. Then one needs to select a time-step based on the grid. This will explicitly encode and document the logic of how the number of substeps is chosen so that you don't have to explain it in words (which is great), but then just write "60" (random)

@@ -49,18 +49,28 @@ mutable struct HydrostaticFreeSurfaceModel{TS, E, A<:AbstractArchitecture, S,
vertical_coordinate :: Z # Rulesets that define the time-evolution of the grid
end

default_free_surface(grid::XYRegularRG; gravitational_acceleration=g_Earth) =
default_free_surface(grid::XYRegularRG; gravitational_acceleration=g_Earth, args...) =
Copy link
Member

Choose a reason for hiding this comment

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

What do you think about using the same default for all grids? I know it is maybe less efficient but there is an advantage to having the setup remain the same when you change grids / configurations. It will also probably be less confusing to debug user configurations.

When we eventually finally have tutorials on model-building, we can explain the default and how it might be optimized depending on the setting.

Basically my idea is to have a default that improves our ability to understand the model and simulations (ie maximizes convenience) --- rather than the alternative goal of choosing a default that achieves optimal performance.

Copy link
Member

@glwagner glwagner Jan 24, 2025

Choose a reason for hiding this comment

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

So the first question to ask is: what is the right goal for a default?

Copy link
Collaborator Author

@simone-silvestri simone-silvestri Jan 24, 2025

Choose a reason for hiding this comment

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

I think the right goal to strive for in a default is stability. A user wouldn't mind if the simulation is 2 or 3 times slower than it could theoretically be, it would be more annoying if he gets a NaN and doesn't know why.

So for the goal of convenience, I am ok uniformizing the free surface for all grids. We can keep the SplitExplicitFreeSurface for all grids since it is the only supported one with all grids. I don't know if we should distinguish between a variable and a fixed substep size where supported or, in the spirit of keeping all defaults the same using only a fixed substep size which is the only supported configuration for every grid. The latter option involves guessing which baroclinic time step the user will use, which might create some stability problems if the user chooses a very large time step and infringes the principle of having a stable simulation with the default configuration.

I would probably keep a variable substep size for serial grids (which should be always stable), while we could make the assumption that users that use distributed grids might have larger problems at hand and tolerate some more tampering with the settings, so as to keep the fixed substep default.

what do you think?

Copy link
Member

Choose a reason for hiding this comment

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

Okay, that makes sense. Basically ideally we could use the same configuration for all scenarios including Distributed, but the complexity of our performance optimization for distributed cases introduces an important trade-off. So we will compromise and use split-explicit always, but different approaches for serial vs distributed grids: variable substeps on serial grids to guarantee stability, fixed substeps on distributed grids (the only thing we support currently).

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.

2 participants