From ec5268c8391a0a717e4030b46be5676dbedf4ef0 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Sun, 6 Apr 2025 09:38:20 +0200 Subject: [PATCH 01/14] change it --- .../split_explicit_free_surface.jl | 29 ++++++++++++------- .../step_split_explicit_free_surface.jl | 1 - 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl index 53f342451f..2610041e9f 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl @@ -1,5 +1,6 @@ using Oceananigans.BuoyancyFormulations: g_Earth using Oceananigans.Grids: with_halo +using Roots import Oceananigans.Grids: on_architecture struct SplitExplicitFreeSurface{H, U, M, FT, K , S, T} <: AbstractFreeSurface{H, FT} @@ -18,7 +19,7 @@ end substeps = nothing, cfl = nothing, fixed_Δt = nothing, - averaging_kernel = averaging_shape_function, + averaging_kernel = minimal_dispersion_averaging_shape_function, timestepper = ForwardBackwardScheme()) Return a `SplitExplicitFreeSurface` representing an explicit time discretization of @@ -86,7 +87,7 @@ function SplitExplicitFreeSurface(grid = nothing; substeps = nothing, cfl = nothing, fixed_Δt = nothing, - averaging_kernel = averaging_shape_function, + averaging_kernel = minimal_dispersion_averaging_shape_function, timestepper = ForwardBackwardScheme()) if !isnothing(grid) @@ -202,16 +203,26 @@ function materialize_free_surface(free_surface::SplitExplicitFreeSurface, veloci timestepper) end -# (p = 2, q = 4, r = 0.18927) minimize dispersion error from Shchepetkin and McWilliams (2005): https://doi.org/10.1016/j.ocemod.2004.08.002 +# Averaging shape function from from Shchepetkin and McWilliams (2005): https://doi.org/10.1016/j.ocemod.2004.08.002 @inline function averaging_shape_function(τ::FT; p = 2, q = 4, r = FT(0.18927)) where FT τ₀ = (p + 2) * (p + q + 2) / (p + 1) / (p + q + 1) - return (τ / τ₀)^p * (1 - (τ / τ₀)^q) - r * (τ / τ₀) end +# Fixing p = 2, q = 4, r = 0.18927 minimizes dispersion errors. +@inline minimal_dispersion_averaging_shape_function(τ) = averaging_shape_function(τ) + @inline cosine_averaging_kernel(τ::FT) where FT = τ ≥ 0.5 && τ ≤ 1.5 ? convert(FT, 1 + cos(2π * (τ - 1))) : zero(FT) @inline constant_averaging_kernel(τ::FT) where FT = convert(FT, 1) +# Averaging functions for which we know the last fractional time +@inline last_fractional_time(::typeof(minimal_dispersion_averaging_shape_function)) = 1.4410682589927724 +@inline last_fractional_time(::typeof(cosine_averaging_kernel)) = 1.5 +@inline last_fractional_time(::typeof(constant_averaging_kernel)) = 2 + +# Otherwise we need to calculate the last fractional time by solving for the root between 0 and 2 +@inline last_fractional_time(averaging_kernel::Function) = Roots.find_zero(averaging_kernel, 2) + """ An internal type for the `SplitExplicitFreeSurface` that allows substepping with a fixed `Δt_barotropic` based on a CFL condition """ struct FixedTimeStepSize{B, F} @@ -228,7 +239,7 @@ end function FixedTimeStepSize(grid; cfl = 0.7, - averaging_kernel = averaging_shape_function, + averaging_kernel = minimal_dispersion_averaging_shape_function, gravitational_acceleration = g_Earth) FT = eltype(grid) @@ -246,14 +257,12 @@ end @inline function weights_from_substeps(FT, substeps, averaging_kernel) - τᶠ = range(FT(0), FT(2), length = substeps+1) + last_τ = last_fractional_time(averaging_kernel) + + τᶠ = range(FT(0), last_τ, length = substeps+1) Δτ = τᶠ[2] - τᶠ[1] averaging_weights = map(averaging_kernel, τᶠ[2:end]) - idx = searchsortedlast(averaging_weights, 0, rev=true) - substeps = idx - - averaging_weights = averaging_weights[1:idx] averaging_weights ./= sum(averaging_weights) return Δτ, map(FT, tuple(averaging_weights...)) diff --git a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/step_split_explicit_free_surface.jl b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/step_split_explicit_free_surface.jl index c5cc7c9e3a..b94ec7541e 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/step_split_explicit_free_surface.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/step_split_explicit_free_surface.jl @@ -134,7 +134,6 @@ function step_free_surface!(free_surface::SplitExplicitFreeSurface, model, baroc # barotropic time step as fraction of baroclinic step and averaging weights Nsubsteps = calculate_substeps(substepping, Δt) fractional_Δt, weights = calculate_adaptive_settings(substepping, Nsubsteps) - Nsubsteps = length(weights) # barotropic time step in seconds Δτᴮ = fractional_Δt * Δt From f5685e3d341bfe57bca3eee11a7900dc4c318cc5 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Sun, 6 Apr 2025 09:47:50 +0200 Subject: [PATCH 02/14] if convergence fails --- .../split_explicit_free_surface.jl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl index 2610041e9f..810bdeb25d 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl @@ -218,10 +218,16 @@ end # Averaging functions for which we know the last fractional time @inline last_fractional_time(::typeof(minimal_dispersion_averaging_shape_function)) = 1.4410682589927724 @inline last_fractional_time(::typeof(cosine_averaging_kernel)) = 1.5 -@inline last_fractional_time(::typeof(constant_averaging_kernel)) = 2 +@inline last_fractional_time(::typeof(constant_averaging_kernel)) = 2.0 # Otherwise we need to calculate the last fractional time by solving for the root between 0 and 2 -@inline last_fractional_time(averaging_kernel::Function) = Roots.find_zero(averaging_kernel, 2) +@inline function last_fractional_time(averaging_kernel::Function) + try + Roots.find_zero(averaging_kernel, 2.0) + catch + 2.0 + end +end """ An internal type for the `SplitExplicitFreeSurface` that allows substepping with a fixed `Δt_barotropic` based on a CFL condition """ From 2c9ee4d68725883f59eacd01e98af4d0892948f9 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Sun, 6 Apr 2025 09:53:37 +0200 Subject: [PATCH 03/14] add a new type to do this --- .../split_explicit_free_surface.jl | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl index 810bdeb25d..b7087e9a8e 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl @@ -105,6 +105,7 @@ function SplitExplicitFreeSurface(grid = nothing; "For example, SplitExplicitFreeSurface(grid; fixed_Δt=$(fixed_Δt), cfl=$(cfl), ...)"))) end + averaging_kernel = regularize_averaging_kernel(averaging_kernel) gravitational_acceleration = convert(FT, gravitational_acceleration) substepping = split_explicit_substepping(cfl, substeps, fixed_Δt, grid, averaging_kernel, gravitational_acceleration) @@ -203,6 +204,14 @@ function materialize_free_surface(free_surface::SplitExplicitFreeSurface, veloci timestepper) end +struct AveragingKernel{FT} + kernel :: Function + last_τ :: FT +end + +regularize_avergaging_kernel(averaging_kernel::AveragingKernel) = averaging_kernel +regularize_avergaging_kernel(averaging_kernel::Function) = AveragingKernel(averaging_kernel, last_fractional_time(averaging_kernel)) + # Averaging shape function from from Shchepetkin and McWilliams (2005): https://doi.org/10.1016/j.ocemod.2004.08.002 @inline function averaging_shape_function(τ::FT; p = 2, q = 4, r = FT(0.18927)) where FT τ₀ = (p + 2) * (p + q + 2) / (p + 1) / (p + q + 1) @@ -215,6 +224,8 @@ end @inline cosine_averaging_kernel(τ::FT) where FT = τ ≥ 0.5 && τ ≤ 1.5 ? convert(FT, 1 + cos(2π * (τ - 1))) : zero(FT) @inline constant_averaging_kernel(τ::FT) where FT = convert(FT, 1) +@inline last_fractional_time(k::AveragingKernel) = k.last_τ + # Averaging functions for which we know the last fractional time @inline last_fractional_time(::typeof(minimal_dispersion_averaging_shape_function)) = 1.4410682589927724 @inline last_fractional_time(::typeof(cosine_averaging_kernel)) = 1.5 @@ -257,6 +268,7 @@ function FixedTimeStepSize(grid; wave_speed = sqrt(gravitational_acceleration * grid.Lz) Δt_barotropic = convert(FT, cfl * Δs / wave_speed) + averaging_kernel = regularize_avergaging_kernel(averaging_kernel) return FixedTimeStepSize(Δt_barotropic, averaging_kernel) end From 189ec0a03df767bab3e938f94be8cd650b27f50a Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Sun, 6 Apr 2025 09:55:21 +0200 Subject: [PATCH 04/14] add roots --- Project.toml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index 64a9ad72d1..2f817a6e04 100644 --- a/Project.toml +++ b/Project.toml @@ -28,6 +28,7 @@ Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" ReactantCore = "a3311ec8-5e00-46d5-b541-4f83e724a433" +Roots = "f2b01f46-fcfa-551c-844a-d8ac1e96c665" Rotations = "6038ab10-8711-5258-84ad-4b1120ba62dc" SeawaterPolynomials = "d496a93d-167e-4197-9f49-d3af4ff8fe40" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" @@ -42,8 +43,8 @@ Enzyme = "7da242da-08ed-463a-9acd-ee780be4f1d9" Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a" MakieCore = "20f20a25-4f0e-4fdf-b5d1-57303727442b" Metal = "dde4c033-4e86-420c-a63e-0dd931031962" -Reactant = "3c362404-f566-11ee-1572-e11a4b42c853" NCDatasets = "85f8d34a-cbdd-5861-8df4-14fed0d494ab" +Reactant = "3c362404-f566-11ee-1572-e11a4b42c853" [extensions] OceananigansEnzymeExt = "Enzyme" @@ -81,9 +82,10 @@ OffsetArrays = "1.4" OrderedCollections = "1.1" Printf = "1.9" Random = "1.9" -ReactantCore = "0.1" Reactant = "0.2.63" +ReactantCore = "0.1" Rotations = "1.0" +Roots = "2.2" SeawaterPolynomials = "0.3.9" SparseArrays = "1.9" StaticArrays = "1" From cd5800266b3aff289385643f305bfbce9133f382 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Sun, 6 Apr 2025 10:00:52 +0200 Subject: [PATCH 05/14] bugfix --- .../SplitExplicitFreeSurfaces/split_explicit_free_surface.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl index b7087e9a8e..262b7c069a 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl @@ -209,8 +209,8 @@ struct AveragingKernel{FT} last_τ :: FT end -regularize_avergaging_kernel(averaging_kernel::AveragingKernel) = averaging_kernel -regularize_avergaging_kernel(averaging_kernel::Function) = AveragingKernel(averaging_kernel, last_fractional_time(averaging_kernel)) +regularize_averaging_kernel(averaging_kernel::AveragingKernel) = averaging_kernel +regularize_averaging_kernel(averaging_kernel::Function) = AveragingKernel(averaging_kernel, last_fractional_time(averaging_kernel)) # Averaging shape function from from Shchepetkin and McWilliams (2005): https://doi.org/10.1016/j.ocemod.2004.08.002 @inline function averaging_shape_function(τ::FT; p = 2, q = 4, r = FT(0.18927)) where FT From 486517a44153a1012da82e87a43502f65c8ac8e6 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Sun, 6 Apr 2025 10:05:03 +0200 Subject: [PATCH 06/14] averaging funcition --- .../SplitExplicitFreeSurfaces/split_explicit_free_surface.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl index 262b7c069a..27f4c85f22 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl @@ -209,6 +209,8 @@ struct AveragingKernel{FT} last_τ :: FT end +@inline (a::AveragingKernel)(τ) = a.kernel(τ) + regularize_averaging_kernel(averaging_kernel::AveragingKernel) = averaging_kernel regularize_averaging_kernel(averaging_kernel::Function) = AveragingKernel(averaging_kernel, last_fractional_time(averaging_kernel)) From 921f0a867b95a4dcb573cfafa6bf9ba81f442e9a Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Sun, 6 Apr 2025 10:10:05 +0200 Subject: [PATCH 07/14] make sure correct typing --- .../split_explicit_free_surface.jl | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl index 27f4c85f22..a9b1c31278 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl @@ -105,7 +105,7 @@ function SplitExplicitFreeSurface(grid = nothing; "For example, SplitExplicitFreeSurface(grid; fixed_Δt=$(fixed_Δt), cfl=$(cfl), ...)"))) end - averaging_kernel = regularize_averaging_kernel(averaging_kernel) + averaging_kernel = regularize_averaging_kernel(FT, averaging_kernel) gravitational_acceleration = convert(FT, gravitational_acceleration) substepping = split_explicit_substepping(cfl, substeps, fixed_Δt, grid, averaging_kernel, gravitational_acceleration) @@ -211,8 +211,12 @@ end @inline (a::AveragingKernel)(τ) = a.kernel(τ) -regularize_averaging_kernel(averaging_kernel::AveragingKernel) = averaging_kernel -regularize_averaging_kernel(averaging_kernel::Function) = AveragingKernel(averaging_kernel, last_fractional_time(averaging_kernel)) +regularize_averaging_kernel(FT, a::AveragingKernel) = AveragingKernel(a.kernel, convert(FT, a.last_τ)) + +function regularize_averaging_kernel(FT, f::Function) + last_τ = last_fractional_time(f) + return AveragingKernel(f, convert(FT, last_τ)) +end # Averaging shape function from from Shchepetkin and McWilliams (2005): https://doi.org/10.1016/j.ocemod.2004.08.002 @inline function averaging_shape_function(τ::FT; p = 2, q = 4, r = FT(0.18927)) where FT @@ -236,7 +240,7 @@ end # Otherwise we need to calculate the last fractional time by solving for the root between 0 and 2 @inline function last_fractional_time(averaging_kernel::Function) try - Roots.find_zero(averaging_kernel, 2.0) + a = Roots.find_zero(averaging_kernel, 2.0) catch 2.0 end From eb405e51147fca4b4148bdba6f5094814f615e59 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Sun, 6 Apr 2025 10:11:21 +0200 Subject: [PATCH 08/14] comment --- .../SplitExplicitFreeSurfaces/split_explicit_free_surface.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl index a9b1c31278..67b8d0a055 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl @@ -204,6 +204,8 @@ function materialize_free_surface(free_surface::SplitExplicitFreeSurface, veloci timestepper) end +""" An internal function that stores the averaging kernel +and the last fractional time for which kernel(τ) > 0 """ struct AveragingKernel{FT} kernel :: Function last_τ :: FT From 957263d1805bd25e5c4affd02ba9f21f6a747e3d Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Sun, 6 Apr 2025 10:16:13 +0200 Subject: [PATCH 09/14] better comment --- .../SplitExplicitFreeSurfaces/split_explicit_free_surface.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl index 67b8d0a055..c33a825589 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl @@ -205,7 +205,7 @@ function materialize_free_surface(free_surface::SplitExplicitFreeSurface, veloci end """ An internal function that stores the averaging kernel -and the last fractional time for which kernel(τ) > 0 """ +and the last fractional time stepped in the subcycling """ struct AveragingKernel{FT} kernel :: Function last_τ :: FT From 7223853139f080aa30d81c9eddb074a15a7bd42d Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Sun, 6 Apr 2025 10:20:15 +0200 Subject: [PATCH 10/14] exclude last substep --- .../split_explicit_free_surface.jl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl index c33a825589..ea95118108 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl @@ -285,10 +285,12 @@ end last_τ = last_fractional_time(averaging_kernel) - τᶠ = range(FT(0), last_τ, length = substeps+1) + τᶠ = range(FT(0), last_τ, length = substeps+2) Δτ = τᶠ[2] - τᶠ[1] - averaging_weights = map(averaging_kernel, τᶠ[2:end]) + # By convention, the last substep corresponds to kernel == 0 + # So we exclude it from the averaging + averaging_weights = map(averaging_kernel, τᶠ[2:end-1]) averaging_weights ./= sum(averaging_weights) return Δτ, map(FT, tuple(averaging_weights...)) From b58328f97974b0f1fec927d346ea69d009ceab77 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Mon, 7 Apr 2025 19:23:06 +0200 Subject: [PATCH 11/14] bugfix --- .../SplitExplicitFreeSurfaces/split_explicit_free_surface.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl index ea95118108..412a147197 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl @@ -276,7 +276,7 @@ function FixedTimeStepSize(grid; wave_speed = sqrt(gravitational_acceleration * grid.Lz) Δt_barotropic = convert(FT, cfl * Δs / wave_speed) - averaging_kernel = regularize_avergaging_kernel(averaging_kernel) + averaging_kernel = regularize_averaging_kernel(FT, averaging_kernel) return FixedTimeStepSize(Δt_barotropic, averaging_kernel) end From bec2323b9038c4bc26a0ebdec5acd396f885acae Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Mon, 7 Apr 2025 19:24:43 +0200 Subject: [PATCH 12/14] correct hydrostatic regression --- test/test_hydrostatic_regression.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_hydrostatic_regression.jl b/test/test_hydrostatic_regression.jl index 7e3b7e7d61..c82dce2fb6 100644 --- a/test/test_hydrostatic_regression.jl +++ b/test/test_hydrostatic_regression.jl @@ -77,7 +77,7 @@ include("regression_tests/hydrostatic_free_turbulence_regression_test.jl") split_explicit_free_surface = SplitExplicitFreeSurface(grid, gravitational_acceleration = 1.0, - substeps = 5) + substeps = 3) for free_surface in [explicit_free_surface, implicit_free_surface, split_explicit_free_surface] From 65f32d7ad1b7632532076c36359fa637d81d3d38 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Wed, 16 Apr 2025 12:17:16 +0200 Subject: [PATCH 13/14] fix function type --- .../SplitExplicitFreeSurfaces/split_explicit_free_surface.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl index 412a147197..9c74b67e78 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl @@ -206,8 +206,8 @@ end """ An internal function that stores the averaging kernel and the last fractional time stepped in the subcycling """ -struct AveragingKernel{FT} - kernel :: Function +struct AveragingKernel{F, FT} + kernel :: F last_τ :: FT end From dafd355e88e70dd6441fbdc0cd46f9ee122a1fec Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Tue, 22 Apr 2025 08:19:14 +0200 Subject: [PATCH 14/14] Update src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl --- .../SplitExplicitFreeSurfaces/split_explicit_free_surface.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl index 9c74b67e78..01dbbca5b5 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl @@ -220,7 +220,7 @@ function regularize_averaging_kernel(FT, f::Function) return AveragingKernel(f, convert(FT, last_τ)) end -# Averaging shape function from from Shchepetkin and McWilliams (2005): https://doi.org/10.1016/j.ocemod.2004.08.002 +# Averaging shape function from Shchepetkin and McWilliams (2005): https://doi.org/10.1016/j.ocemod.2004.08.002 @inline function averaging_shape_function(τ::FT; p = 2, q = 4, r = FT(0.18927)) where FT τ₀ = (p + 2) * (p + q + 2) / (p + 1) / (p + q + 1) return (τ / τ₀)^p * (1 - (τ / τ₀)^q) - r * (τ / τ₀)