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
1k stars 196 forks source link

Why are the prognostic fields deep-copied in the constructor for `HydrostaticFreeSurfaceModel`? #3967

Open glwagner opened 20 hours ago

glwagner commented 20 hours ago

Doesn't this allocate unnecessary memory?

https://github.com/CliMA/Oceananigans.jl/blob/fe4123f92155f5086bce72e366843045606b4bf5/src/Models/HydrostaticFreeSurfaceModels/hydrostatic_free_surface_model.jl#L201

glwagner commented 20 hours ago

@simone-silvestri

simone-silvestri commented 12 hours ago

It is needed for the RK3 timestepper. I can move the deepcopy in the timestepper constructor to avoid the memory allocation when using an AB2

glwagner commented 3 hours ago

Right, so its unnecessary for AB2 which is currently the default. Good also to note this is an additional downside of the RK3 scheme.