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

set! should enforce incompressibility when setting an initial condition for an Incompressible model #1027

Closed
navidcy opened this issue Oct 6, 2020 · 4 comments · Fixed by #1259

Comments

@navidcy
Copy link
Collaborator

navidcy commented Oct 6, 2020

For example, here:

set!(model, u=u₀, v=u₀)

clearly the initial condition is not incompressible.

set! should somehow remove the compressible part of the initial conditions and perhaps also print out a warning so that the user knows that the model is not initialized exactly with the fields they provided?

@navidcy navidcy changed the title set! should enforce incompressibility when sets initial condition in an Incompressible model? set! should enforce incompressibility when setting an initial condition for an Incompressible model Oct 6, 2020
@glwagner
Copy link
Member

glwagner commented Oct 6, 2020

There is a comment about divergent initial conditions here:

https://clima.github.io/OceananigansDocumentation/stable/model_setup/setting_initial_conditions/

A related issue is #951 .

We could somehow change the behavior of set! to project the initial condition onto an incompressible field. For example, we might use the pressure solver. While it would be surprising that the initial condition never ends up exactly as its set by the user, it is similarly surprising to observe a large change in the velocity field after a single time step. And set! is intended to be used prior to time stepping.

I'm not sure I agree about printing a warning based on some metric diagnosed from the velocity field passed to set!. However, we could print out an info message that gives the user some information about how much their velocity field was changed during the initialization process. This is related to #1013 .

@ali-ramadhan
Copy link
Member

We could use a kwarg like set!(model, u=u₀, v=u₀, enforce_incompressibility=true) so it's optional based on what the user wants.

@glwagner
Copy link
Member

glwagner commented Oct 16, 2020

How exactly would we enforce incompressibility? Should we perform a pressure correction step? Something like

function set!(model; enforce_incompressibility=false, kwargs...

    # everything else in `set!`

    if enforce_incompressibility
        calculate_pressure_correction!(model, 1.0)
        pressure_correct_velocities!(model, 1.0)
    end

    return nothing
end

(This syntax will work once #1057 is merged). The "1.0" is a pseudo-timestep that is technically irrelevant (but can't be Inf or 0). The two above functions come from the time-stepping routine:

calculate_pressure_correction!(model, first_stage_Δt)
pressure_correct_velocities!(model, first_stage_Δt)

I suppose this projects the user-defined velocity field onto an incompressible field, which is more or less what we want? It seems better than recomputing w from continuity.

@ali-ramadhan
Copy link
Member

Yeah that seems like a nice solution! Especially as it relies on existing functionality. To recompute w from continuity we'd have to add back in some kernels.

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 a pull request may close this issue.

3 participants