CliMA / Oceananigans.jl

🌊 Julia software for fast, friendly, flexible, ocean-flavored fluid dynamics on CPUs and GPUs
https://clima.github.io/OceananigansDocumentation/stable
MIT License
989 stars 194 forks source link

Some refactoring of `time_step!` to unify `HydrostaticFreeSurfaceModel` and `NonhydrostaticModel` #3895

Open simone-silvestri opened 11 hours ago

simone-silvestri commented 11 hours ago

at the moment, the default time stepping function is designed with the non-hydrostatic model in mind, so the logical steps of a time step (or substep for RK3) are

step_variables!(...)
calculate_pressure_correction!(...) 
pressure_correct_velocities!(...)
compute_new_tendencies!(...)

In the hydrostatic model, we are extending the step_variables! function to include a step_free_surface! function that calculates η and we set

calculate_pressure_correction!(::HydrostaticFreeSurfaceModel, ...) = nothing

I would like to calculate the free surface in the calculate_pressure_correction! function to unify conceptually the NonhydrostaticModel and the HydrostaticFreeSurfaceModel, minimize the amount of code, and reduce the necessity for extending the time-stepping function. This will make it easier to implement new time-stepping schemes that work for both the models

glwagner commented 7 hours ago

This is a good idea, the only comment is that we should possibly try to merge https://github.com/CliMA/Oceananigans.jl/pull/3867/files which makes a few small changes first