From feda572ad586aadb4ef568f38dfb4a52ad8231bf Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Thu, 14 Nov 2024 08:46:02 +0100 Subject: [PATCH 01/13] reduce parameter space --- ...ute_hydrostatic_free_surface_tendencies.jl | 21 +++++++++---------- ..._free_surface_tendency_kernel_functions.jl | 16 +++++++------- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_tendencies.jl b/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_tendencies.jl index 82c71b05dd..ca5c86742d 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_tendencies.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_tendencies.jl @@ -153,7 +153,6 @@ function compute_hydrostatic_momentum_tendencies!(model, velocities, kernel_para model.diffusivity_fields, model.pressure.pHY′, model.auxiliary_fields, - model.forcing, model.clock) u_kernel_args = tuple(start_momentum_kernel_args..., u_immersed_bc, end_momentum_kernel_args...) @@ -161,12 +160,12 @@ function compute_hydrostatic_momentum_tendencies!(model, velocities, kernel_para launch!(arch, grid, kernel_parameters, compute_hydrostatic_free_surface_Gu!, model.timestepper.Gⁿ.u, grid, - active_cells_map, u_kernel_args; + active_cells_map, u_kernel_args, model.forcing.u; active_cells_map) launch!(arch, grid, kernel_parameters, compute_hydrostatic_free_surface_Gv!, model.timestepper.Gⁿ.v, grid, - active_cells_map, v_kernel_args; + active_cells_map, v_kernel_args, model.forcing.v; active_cells_map) compute_free_surface_tendency!(grid, model, :xy) @@ -200,27 +199,27 @@ end ##### """ Calculate the right-hand-side of the u-velocity equation. """ -@kernel function compute_hydrostatic_free_surface_Gu!(Gu, grid, ::Nothing, args) +@kernel function compute_hydrostatic_free_surface_Gu!(Gu, grid, ::Nothing, args, forcing) i, j, k = @index(Global, NTuple) - @inbounds Gu[i, j, k] = hydrostatic_free_surface_u_velocity_tendency(i, j, k, grid, args...) + @inbounds Gu[i, j, k] = hydrostatic_free_surface_u_velocity_tendency(i, j, k, grid, args..., forcing) end -@kernel function compute_hydrostatic_free_surface_Gu!(Gu, grid, active_cells_map, args) +@kernel function compute_hydrostatic_free_surface_Gu!(Gu, grid, active_cells_map, args, forcing) idx = @index(Global, Linear) i, j, k = active_linear_index_to_tuple(idx, active_cells_map) - @inbounds Gu[i, j, k] = hydrostatic_free_surface_u_velocity_tendency(i, j, k, grid, args...) + @inbounds Gu[i, j, k] = hydrostatic_free_surface_u_velocity_tendency(i, j, k, grid, args..., forcing) end """ Calculate the right-hand-side of the v-velocity equation. """ -@kernel function compute_hydrostatic_free_surface_Gv!(Gv, grid, ::Nothing, args) +@kernel function compute_hydrostatic_free_surface_Gv!(Gv, grid, ::Nothing, args, forcing) i, j, k = @index(Global, NTuple) - @inbounds Gv[i, j, k] = hydrostatic_free_surface_v_velocity_tendency(i, j, k, grid, args...) + @inbounds Gv[i, j, k] = hydrostatic_free_surface_v_velocity_tendency(i, j, k, grid, args..., forcing) end -@kernel function compute_hydrostatic_free_surface_Gv!(Gv, grid, active_cells_map, args) +@kernel function compute_hydrostatic_free_surface_Gv!(Gv, grid, active_cells_map, args, forcing) idx = @index(Global, Linear) i, j, k = active_linear_index_to_tuple(idx, active_cells_map) - @inbounds Gv[i, j, k] = hydrostatic_free_surface_v_velocity_tendency(i, j, k, grid, args...) + @inbounds Gv[i, j, k] = hydrostatic_free_surface_v_velocity_tendency(i, j, k, grid, args..., forcing) end ##### diff --git a/src/Models/HydrostaticFreeSurfaceModels/hydrostatic_free_surface_tendency_kernel_functions.jl b/src/Models/HydrostaticFreeSurfaceModels/hydrostatic_free_surface_tendency_kernel_functions.jl index 6de795e2b6..f9a90138ee 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/hydrostatic_free_surface_tendency_kernel_functions.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/hydrostatic_free_surface_tendency_kernel_functions.jl @@ -38,8 +38,8 @@ implicitly during time-stepping. diffusivities, hydrostatic_pressure_anomaly, auxiliary_fields, - forcings, - clock) + clock, + forcing) model_fields = merge(hydrostatic_fields(velocities, free_surface, tracers), auxiliary_fields) @@ -49,7 +49,7 @@ implicitly during time-stepping. - ∂xᶠᶜᶜ(i, j, k, grid, hydrostatic_pressure_anomaly) - ∂ⱼ_τ₁ⱼ(i, j, k, grid, closure, diffusivities, clock, model_fields, buoyancy) - immersed_∂ⱼ_τ₁ⱼ(i, j, k, grid, velocities, u_immersed_bc, closure, diffusivities, clock, model_fields) - + forcings.u(i, j, k, grid, clock, hydrostatic_prognostic_fields(velocities, free_surface, tracers))) + + forcing(i, j, k, grid, clock, hydrostatic_prognostic_fields(velocities, free_surface, tracers))) end """ @@ -77,8 +77,8 @@ implicitly during time-stepping. diffusivities, hydrostatic_pressure_anomaly, auxiliary_fields, - forcings, - clock) + clock, + forcing) model_fields = merge(hydrostatic_fields(velocities, free_surface, tracers), auxiliary_fields) @@ -88,7 +88,7 @@ implicitly during time-stepping. - ∂yᶜᶠᶜ(i, j, k, grid, hydrostatic_pressure_anomaly) - ∂ⱼ_τ₂ⱼ(i, j, k, grid, closure, diffusivities, clock, model_fields, buoyancy) - immersed_∂ⱼ_τ₂ⱼ(i, j, k, grid, velocities, v_immersed_bc, closure, diffusivities, clock, model_fields) - + forcings.v(i, j, k, grid, clock, model_fields)) + + forcing(i, j, k, grid, clock, model_fields)) end """ @@ -151,13 +151,13 @@ The tendency is called ``G_η`` and defined via free_surface, tracers, auxiliary_fields, - forcings, + forcing, clock) k_top = grid.Nz + 1 model_fields = merge(hydrostatic_fields(velocities, free_surface, tracers), auxiliary_fields) return @inbounds ( velocities.w[i, j, k_top] - + forcings.η(i, j, k_top, grid, clock, model_fields)) + + forcing(i, j, k_top, grid, clock, model_fields)) end From 3f8b60924a2e53507cc7cc646628a210efe3f6b8 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Thu, 14 Nov 2024 08:51:09 +0100 Subject: [PATCH 02/13] change other kernels for symmetry --- .../compute_hydrostatic_free_surface_tendencies.jl | 8 ++++---- .../hydrostatic_free_surface_tendency_kernel_functions.jl | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_tendencies.jl b/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_tendencies.jl index ca5c86742d..276062eb9f 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_tendencies.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_tendencies.jl @@ -89,8 +89,8 @@ function compute_hydrostatic_free_surface_tendency_contributions!(model, kernel_ model.tracers, model.diffusivity_fields, model.auxiliary_fields, - c_forcing, - model.clock) + model.clock, + c_forcing) launch!(arch, grid, kernel_parameters, compute_hydrostatic_free_surface_Gc!, @@ -123,8 +123,8 @@ function compute_free_surface_tendency!(grid, model, kernel_parameters) model.free_surface, model.tracers, model.auxiliary_fields, - model.forcing, - model.clock) + model.clock, + model.forcing) launch!(arch, grid, kernel_parameters, compute_hydrostatic_free_surface_Gη!, model.timestepper.Gⁿ.η, diff --git a/src/Models/HydrostaticFreeSurfaceModels/hydrostatic_free_surface_tendency_kernel_functions.jl b/src/Models/HydrostaticFreeSurfaceModels/hydrostatic_free_surface_tendency_kernel_functions.jl index f9a90138ee..7f19d8617a 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/hydrostatic_free_surface_tendency_kernel_functions.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/hydrostatic_free_surface_tendency_kernel_functions.jl @@ -116,8 +116,8 @@ where `c = C[tracer_index]`. tracers, diffusivities, auxiliary_fields, - forcing, - clock) where tracer_index + clock, + forcing) where tracer_index @inbounds c = tracers[tracer_index] model_fields = merge(hydrostatic_fields(velocities, free_surface, tracers), auxiliary_fields) @@ -151,8 +151,8 @@ The tendency is called ``G_η`` and defined via free_surface, tracers, auxiliary_fields, - forcing, - clock) + clock, + forcing) k_top = grid.Nz + 1 model_fields = merge(hydrostatic_fields(velocities, free_surface, tracers), auxiliary_fields) From 06468b0002cf7b1efb2125f55cfb3c3ec825961d Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Thu, 14 Nov 2024 08:53:14 +0100 Subject: [PATCH 03/13] only free surface forcing --- .../compute_hydrostatic_free_surface_tendencies.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_tendencies.jl b/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_tendencies.jl index 276062eb9f..f218dc7d83 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_tendencies.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_tendencies.jl @@ -124,7 +124,7 @@ function compute_free_surface_tendency!(grid, model, kernel_parameters) model.tracers, model.auxiliary_fields, model.clock, - model.forcing) + model.forcing.η) launch!(arch, grid, kernel_parameters, compute_hydrostatic_free_surface_Gη!, model.timestepper.Gⁿ.η, From d04c680f90e417fbb31e940c3c47eef38fc3ad75 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Thu, 14 Nov 2024 16:49:56 +0100 Subject: [PATCH 04/13] pass specific forcing in kernels --- .../compute_nonhydrostatic_tendencies.jl | 6 +++--- ...nonhydrostatic_tendency_kernel_functions.jl | 18 +++++++++--------- .../compute_shallow_water_tendencies.jl | 10 +++++----- .../solution_and_tracer_tendencies.jl | 18 +++++++++--------- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/Models/NonhydrostaticModels/compute_nonhydrostatic_tendencies.jl b/src/Models/NonhydrostaticModels/compute_nonhydrostatic_tendencies.jl index ffa7865bb2..384ca2d316 100644 --- a/src/Models/NonhydrostaticModels/compute_nonhydrostatic_tendencies.jl +++ b/src/Models/NonhydrostaticModels/compute_nonhydrostatic_tendencies.jl @@ -91,15 +91,15 @@ function compute_interior_tendency_contributions!(model, kernel_parameters; acti u_kernel_args = tuple(start_momentum_kernel_args..., u_immersed_bc, end_momentum_kernel_args..., - forcings, hydrostatic_pressure, clock) + hydrostatic_pressure, clock, forcing.u) v_kernel_args = tuple(start_momentum_kernel_args..., v_immersed_bc, end_momentum_kernel_args..., - forcings, hydrostatic_pressure, clock) + forcings, hydrostatic_pressure, clock, forcing.v) w_kernel_args = tuple(start_momentum_kernel_args..., w_immersed_bc, end_momentum_kernel_args..., - forcings, hydrostatic_pressure, clock) + hydrostatic_pressure, clock, forcing.w) exclude_periphery = true launch!(arch, grid, kernel_parameters, compute_Gu!, diff --git a/src/Models/NonhydrostaticModels/nonhydrostatic_tendency_kernel_functions.jl b/src/Models/NonhydrostaticModels/nonhydrostatic_tendency_kernel_functions.jl index cefb5eadc3..097ab538bc 100644 --- a/src/Models/NonhydrostaticModels/nonhydrostatic_tendency_kernel_functions.jl +++ b/src/Models/NonhydrostaticModels/nonhydrostatic_tendency_kernel_functions.jl @@ -56,9 +56,9 @@ pressure anomaly. tracers, auxiliary_fields, diffusivities, - forcings, hydrostatic_pressure, - clock) + clock, + forcing) model_fields = merge(velocities, tracers, auxiliary_fields) @@ -77,7 +77,7 @@ pressure anomaly. - immersed_∂ⱼ_τ₁ⱼ(i, j, k, grid, velocities, u_immersed_bc, closure, diffusivities, clock, model_fields) + x_curl_Uˢ_cross_U(i, j, k, grid, stokes_drift, velocities, clock.time) + ∂t_uˢ(i, j, k, grid, stokes_drift, clock.time) - + forcings.u(i, j, k, grid, clock, model_fields)) + + forcing(i, j, k, grid, clock, model_fields)) end """ @@ -119,9 +119,9 @@ pressure anomaly. tracers, auxiliary_fields, diffusivities, - forcings, hydrostatic_pressure, - clock) + clock, + forcing) model_fields = merge(velocities, tracers, auxiliary_fields) @@ -140,7 +140,7 @@ pressure anomaly. - immersed_∂ⱼ_τ₂ⱼ(i, j, k, grid, velocities, v_immersed_bc, closure, diffusivities, clock, model_fields) + y_curl_Uˢ_cross_U(i, j, k, grid, stokes_drift, velocities, clock.time) + ∂t_vˢ(i, j, k, grid, stokes_drift, clock.time) - + forcings.v(i, j, k, grid, clock, model_fields)) + + forcing(i, j, k, grid, clock, model_fields)) end # Only add buoyancy if the hydrostatic pressure isa Nothing @@ -185,9 +185,9 @@ velocity components, tracer fields, and precalculated diffusivities where applic tracers, auxiliary_fields, diffusivities, - forcings, hydrostatic_pressure, - clock) + clock, + forcing) model_fields = merge(velocities, tracers, auxiliary_fields) @@ -205,7 +205,7 @@ velocity components, tracer fields, and precalculated diffusivities where applic - immersed_∂ⱼ_τ₃ⱼ(i, j, k, grid, velocities, w_immersed_bc, closure, diffusivities, clock, model_fields) + z_curl_Uˢ_cross_U(i, j, k, grid, stokes_drift, velocities, clock.time) + ∂t_wˢ(i, j, k, grid, stokes_drift, clock.time) - + forcings.w(i, j, k, grid, clock, model_fields)) + + forcing(i, j, k, grid, clock, model_fields)) end """ diff --git a/src/Models/ShallowWaterModels/compute_shallow_water_tendencies.jl b/src/Models/ShallowWaterModels/compute_shallow_water_tendencies.jl index fa5a7708ff..03c82dac52 100644 --- a/src/Models/ShallowWaterModels/compute_shallow_water_tendencies.jl +++ b/src/Models/ShallowWaterModels/compute_shallow_water_tendencies.jl @@ -75,14 +75,14 @@ function compute_interior_tendency_contributions!(tendencies, formulation) transport_args = (grid, gravitational_acceleration, advection.momentum, velocities, coriolis, closure, - bathymetry, solution, tracers, diffusivities, forcings, clock, formulation) + bathymetry, solution, tracers, diffusivities, clock, formulation) h_args = (grid, gravitational_acceleration, advection.mass, coriolis, closure, - solution, tracers, diffusivities, forcings, clock, formulation) + solution, tracers, diffusivities, clock, formulation) - launch!(arch, grid, :xyz, compute_Guh!, tendencies[1], transport_args...; exclude_periphery=true) - launch!(arch, grid, :xyz, compute_Gvh!, tendencies[2], transport_args...; exclude_periphery=true) - launch!(arch, grid, :xyz, compute_Gh!, tendencies[3], h_args...) + launch!(arch, grid, :xyz, compute_Guh!, tendencies[1], transport_args..., forcings[1]; exclude_periphery=true) + launch!(arch, grid, :xyz, compute_Gvh!, tendencies[2], transport_args..., forcings[2]; exclude_periphery=true) + launch!(arch, grid, :xyz, compute_Gh!, tendencies[3], h_args..., forcings.h) for (tracer_index, tracer_name) in enumerate(propertynames(tracers)) @inbounds Gc = tendencies[tracer_index+3] diff --git a/src/Models/ShallowWaterModels/solution_and_tracer_tendencies.jl b/src/Models/ShallowWaterModels/solution_and_tracer_tendencies.jl index 02d5ac2e55..5f90014a56 100644 --- a/src/Models/ShallowWaterModels/solution_and_tracer_tendencies.jl +++ b/src/Models/ShallowWaterModels/solution_and_tracer_tendencies.jl @@ -32,9 +32,9 @@ Compute the tendency for the x-directional transport, uh solution, tracers, diffusivities, - forcings, clock, - formulation) + formulation, + forcing) g = gravitational_acceleration @@ -45,7 +45,7 @@ Compute the tendency for the x-directional transport, uh - x_f_cross_U(i, j, k, grid, coriolis, solution) - bathymetry_contribution_x(i, j, k, grid, g, solution.h, bathymetry, formulation) - sw_∂ⱼ_τ₁ⱼ(i, j, k, grid, closure, diffusivities, clock, model_fields, formulation) - + forcings[1](i, j, k, grid, clock, merge(solution, tracers))) + + forcing(i, j, k, grid, clock, merge(solution, tracers))) end """ @@ -61,9 +61,9 @@ Compute the tendency for the y-directional transport, vh. solution, tracers, diffusivities, - forcings, clock, - formulation) + formulation, + forcing) g = gravitational_acceleration @@ -74,7 +74,7 @@ Compute the tendency for the y-directional transport, vh. - y_f_cross_U(i, j, k, grid, coriolis, solution) - bathymetry_contribution_y(i, j, k, grid, g, solution.h, bathymetry, formulation) - sw_∂ⱼ_τ₂ⱼ(i, j, k, grid, closure, diffusivities, clock, model_fields, formulation) - + forcings[2](i, j, k, grid, clock, merge(solution, tracers))) + + forcing(i, j, k, grid, clock, merge(solution, tracers))) end """ @@ -88,12 +88,12 @@ Compute the tendency for the height, h. solution, tracers, diffusivities, - forcings, clock, - formulation) + formulation, + forcing) return ( - div_Uh(i, j, k, grid, advection, solution, formulation) - + forcings.h(i, j, k, grid, clock, merge(solution, tracers))) + + forcing(i, j, k, grid, clock, merge(solution, tracers))) end @inline function tracer_tendency(i, j, k, grid, From 41bad8801188768e2389f288019fb2702515862f Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Thu, 14 Nov 2024 17:26:22 +0100 Subject: [PATCH 05/13] bugfix --- .../compute_nonhydrostatic_tendencies.jl | 8 ++++---- .../nonhydrostatic_tendency_kernel_functions.jl | 4 ++-- .../compute_shallow_water_tendencies.jl | 2 +- .../ShallowWaterModels/solution_and_tracer_tendencies.jl | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Models/NonhydrostaticModels/compute_nonhydrostatic_tendencies.jl b/src/Models/NonhydrostaticModels/compute_nonhydrostatic_tendencies.jl index 384ca2d316..5fbceb598a 100644 --- a/src/Models/NonhydrostaticModels/compute_nonhydrostatic_tendencies.jl +++ b/src/Models/NonhydrostaticModels/compute_nonhydrostatic_tendencies.jl @@ -91,15 +91,15 @@ function compute_interior_tendency_contributions!(model, kernel_parameters; acti u_kernel_args = tuple(start_momentum_kernel_args..., u_immersed_bc, end_momentum_kernel_args..., - hydrostatic_pressure, clock, forcing.u) + hydrostatic_pressure, clock, forcings.u) v_kernel_args = tuple(start_momentum_kernel_args..., v_immersed_bc, end_momentum_kernel_args..., - forcings, hydrostatic_pressure, clock, forcing.v) + forcings, hydrostatic_pressure, clock, forcings.v) w_kernel_args = tuple(start_momentum_kernel_args..., w_immersed_bc, end_momentum_kernel_args..., - hydrostatic_pressure, clock, forcing.w) + hydrostatic_pressure, clock, forcings.w) exclude_periphery = true launch!(arch, grid, kernel_parameters, compute_Gu!, @@ -128,7 +128,7 @@ function compute_interior_tendency_contributions!(model, kernel_parameters; acti start_tracer_kernel_args..., c_immersed_bc, end_tracer_kernel_args..., - forcing, clock) + clock, forcing) launch!(arch, grid, kernel_parameters, compute_Gc!, c_tendency, grid, active_cells_map, args; diff --git a/src/Models/NonhydrostaticModels/nonhydrostatic_tendency_kernel_functions.jl b/src/Models/NonhydrostaticModels/nonhydrostatic_tendency_kernel_functions.jl index 097ab538bc..1b19ba10b2 100644 --- a/src/Models/NonhydrostaticModels/nonhydrostatic_tendency_kernel_functions.jl +++ b/src/Models/NonhydrostaticModels/nonhydrostatic_tendency_kernel_functions.jl @@ -247,8 +247,8 @@ velocity components, tracer fields, and precalculated diffusivities where applic tracers, auxiliary_fields, diffusivities, - forcing, - clock) where tracer_index + clock, + forcing) where tracer_index @inbounds c = tracers[tracer_index] @inbounds background_fields_c = background_fields.tracers[tracer_index] diff --git a/src/Models/ShallowWaterModels/compute_shallow_water_tendencies.jl b/src/Models/ShallowWaterModels/compute_shallow_water_tendencies.jl index 03c82dac52..d56995a570 100644 --- a/src/Models/ShallowWaterModels/compute_shallow_water_tendencies.jl +++ b/src/Models/ShallowWaterModels/compute_shallow_water_tendencies.jl @@ -90,7 +90,7 @@ function compute_interior_tendency_contributions!(tendencies, @inbounds c_advection = advection[tracer_name] launch!(arch, grid, :xyz, compute_Gc!, Gc, grid, Val(tracer_index), - c_advection, closure, solution, tracers, diffusivities, forcing, clock, formulation) + c_advection, closure, solution, tracers, diffusivities, clock, formulation, forcing) end return nothing diff --git a/src/Models/ShallowWaterModels/solution_and_tracer_tendencies.jl b/src/Models/ShallowWaterModels/solution_and_tracer_tendencies.jl index 5f90014a56..cc3a6c4636 100644 --- a/src/Models/ShallowWaterModels/solution_and_tracer_tendencies.jl +++ b/src/Models/ShallowWaterModels/solution_and_tracer_tendencies.jl @@ -103,9 +103,9 @@ end solution, tracers, diffusivities, - forcing, clock, - formulation) where tracer_index + formulation, + forcing) where tracer_index @inbounds c = tracers[tracer_index] From fa51e82e89a98cf9fe77875910a09125ec36cead Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Thu, 14 Nov 2024 18:53:10 +0100 Subject: [PATCH 06/13] bugfix --- .../compute_nonhydrostatic_tendencies.jl | 2 +- .../nonhydrostatic_tendency_kernel_functions.jl | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Models/NonhydrostaticModels/compute_nonhydrostatic_tendencies.jl b/src/Models/NonhydrostaticModels/compute_nonhydrostatic_tendencies.jl index 5fbceb598a..cb0947b4be 100644 --- a/src/Models/NonhydrostaticModels/compute_nonhydrostatic_tendencies.jl +++ b/src/Models/NonhydrostaticModels/compute_nonhydrostatic_tendencies.jl @@ -95,7 +95,7 @@ function compute_interior_tendency_contributions!(model, kernel_parameters; acti v_kernel_args = tuple(start_momentum_kernel_args..., v_immersed_bc, end_momentum_kernel_args..., - forcings, hydrostatic_pressure, clock, forcings.v) + hydrostatic_pressure, clock, forcings.v) w_kernel_args = tuple(start_momentum_kernel_args..., w_immersed_bc, end_momentum_kernel_args..., diff --git a/src/Models/NonhydrostaticModels/nonhydrostatic_tendency_kernel_functions.jl b/src/Models/NonhydrostaticModels/nonhydrostatic_tendency_kernel_functions.jl index 1b19ba10b2..061daed61f 100644 --- a/src/Models/NonhydrostaticModels/nonhydrostatic_tendency_kernel_functions.jl +++ b/src/Models/NonhydrostaticModels/nonhydrostatic_tendency_kernel_functions.jl @@ -66,7 +66,7 @@ pressure anomaly. v = SumOfArrays{2}(velocities.v, background_fields.velocities.v), w = SumOfArrays{2}(velocities.w, background_fields.velocities.w)) - total_velocities = with_advective_forcing(forcings.u, total_velocities) + total_velocities = with_advective_forcing(forcing, total_velocities) return ( - div_𝐯u(i, j, k, grid, advection, total_velocities, velocities.u) - div_𝐯u(i, j, k, grid, advection, velocities, background_fields.velocities.u) @@ -129,7 +129,7 @@ pressure anomaly. v = SumOfArrays{2}(velocities.v, background_fields.velocities.v), w = SumOfArrays{2}(velocities.w, background_fields.velocities.w)) - total_velocities = with_advective_forcing(forcings.v, total_velocities) + total_velocities = with_advective_forcing(forcing, total_velocities) return ( - div_𝐯v(i, j, k, grid, advection, total_velocities, velocities.v) - div_𝐯v(i, j, k, grid, advection, velocities, background_fields.velocities.v) @@ -195,7 +195,7 @@ velocity components, tracer fields, and precalculated diffusivities where applic v = SumOfArrays{2}(velocities.v, background_fields.velocities.v), w = SumOfArrays{2}(velocities.w, background_fields.velocities.w)) - total_velocities = with_advective_forcing(forcings.w, total_velocities) + total_velocities = with_advective_forcing(forcing, total_velocities) return ( - div_𝐯w(i, j, k, grid, advection, total_velocities, velocities.w) - div_𝐯w(i, j, k, grid, advection, velocities, background_fields.velocities.w) From 2e09e59486681f91111cdc102bb18ab2e395c847 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Fri, 15 Nov 2024 14:22:21 +0100 Subject: [PATCH 07/13] reduce parameter space --- .../split_explicit_free_surface.jl | 6 +++++- 1 file changed, 5 insertions(+), 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 5c62a7a666..203a02ed8a 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl @@ -1,5 +1,5 @@ using Oceananigans.BuoyancyModels: g_Earth -using Oceananigans.Grids: with_halo +using Oceananigans.Grids: with_halo, on_architecture struct SplitExplicitFreeSurface{H, U, M, FT, K , S, T} <: AbstractFreeSurface{H, FT} η :: H @@ -119,6 +119,10 @@ end function split_explicit_substepping(::Nothing, substeps, fixed_Δt, grid, averaging_kernel, gravitational_acceleration) FT = eltype(gravitational_acceleration) fractional_step_size, averaging_weights = weights_from_substeps(FT, substeps, averaging_kernel) + + # Make the weights into an array to reduce the parameter space + averaging_weights = on_architecture(architecture(grid), [averaging_weights...]) + return FixedSubstepNumber(fractional_step_size, averaging_weights) end From b138c3683c6b3c412d5dd9dbdabb037a65f5a3d9 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Fri, 15 Nov 2024 14:30:42 +0100 Subject: [PATCH 08/13] import on_architecture --- .../SplitExplicitFreeSurfaces/split_explicit_free_surface.jl | 3 ++- 1 file changed, 2 insertions(+), 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 203a02ed8a..d53f55ca97 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.BuoyancyModels: g_Earth -using Oceananigans.Grids: with_halo, on_architecture +using Oceananigans.Grids: with_halo +import Oceananigans.Grids: on_architecture struct SplitExplicitFreeSurface{H, U, M, FT, K , S, T} <: AbstractFreeSurface{H, FT} η :: H From 49956365e920c1a0cab6cb555a2ab8df461e1017 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Fri, 15 Nov 2024 14:47:50 +0100 Subject: [PATCH 09/13] some changes --- .../split_explicit_free_surface.jl | 4 -- ...ute_hydrostatic_free_surface_tendencies.jl | 18 +++++--- ..._free_surface_tendency_kernel_functions.jl | 41 +++++++------------ 3 files changed, 26 insertions(+), 37 deletions(-) diff --git a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl index d53f55ca97..7c1e920d06 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/split_explicit_free_surface.jl @@ -120,10 +120,6 @@ end function split_explicit_substepping(::Nothing, substeps, fixed_Δt, grid, averaging_kernel, gravitational_acceleration) FT = eltype(gravitational_acceleration) fractional_step_size, averaging_weights = weights_from_substeps(FT, substeps, averaging_kernel) - - # Make the weights into an array to reduce the parameter space - averaging_weights = on_architecture(architecture(grid), [averaging_weights...]) - return FixedSubstepNumber(fractional_step_size, averaging_weights) end diff --git a/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_tendencies.jl b/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_tendencies.jl index 9e21089913..8cadc39836 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_tendencies.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_tendencies.jl @@ -74,11 +74,16 @@ function compute_hydrostatic_free_surface_tendency_contributions!(model, kernel_ for (tracer_index, tracer_name) in enumerate(propertynames(model.tracers)) + + @inbounds tracer = model.tracers[tracer_name] @inbounds c_tendency = model.timestepper.Gⁿ[tracer_name] @inbounds c_advection = model.advection[tracer_name] @inbounds c_forcing = model.forcing[tracer_name] @inbounds c_immersed_bc = immersed_boundary_condition(model.tracers[tracer_name]) + model_fields = merge(hydrostatic_fields(model.velocities, model.free_surface, model.tracers), model.auxiliary_fields) + + # We need to pass the free_surface only if it args = tuple(Val(tracer_index), Val(tracer_name), c_advection, @@ -86,11 +91,9 @@ function compute_hydrostatic_free_surface_tendency_contributions!(model, kernel_ c_immersed_bc, model.buoyancy, model.biogeochemistry, - model.velocities, - model.free_surface, - model.tracers, + model_fields, + tracer, model.diffusivity_fields, - model.auxiliary_fields, model.clock, c_forcing) @@ -126,12 +129,15 @@ function compute_hydrostatic_momentum_tendencies!(model, velocities, kernel_para u_immersed_bc = immersed_boundary_condition(velocities.u) v_immersed_bc = immersed_boundary_condition(velocities.v) + model_fields = merge(hydrostatic_fields(model.velocities, model.free_surface, model.tracers), model.auxiliary_fields) + free_surface = model.free_surface isa ExplicitFreeSurface ? model.free_surface : nothing + start_momentum_kernel_args = (model.advection.momentum, model.coriolis, model.closure) - end_momentum_kernel_args = (velocities, - model.free_surface, + end_momentum_kernel_args = (model_fields, + free_surface, model.tracers, model.buoyancy, model.diffusivity_fields, diff --git a/src/Models/HydrostaticFreeSurfaceModels/hydrostatic_free_surface_tendency_kernel_functions.jl b/src/Models/HydrostaticFreeSurfaceModels/hydrostatic_free_surface_tendency_kernel_functions.jl index 605849dbee..34da3e2b9e 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/hydrostatic_free_surface_tendency_kernel_functions.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/hydrostatic_free_surface_tendency_kernel_functions.jl @@ -31,25 +31,21 @@ implicitly during time-stepping. coriolis, closure, u_immersed_bc, - velocities, + model_fields, free_surface, - tracers, buoyancy, diffusivities, hydrostatic_pressure_anomaly, - auxiliary_fields, clock, forcing) - - model_fields = merge(hydrostatic_fields(velocities, free_surface, tracers), auxiliary_fields) - return ( - U_dot_∇u(i, j, k, grid, advection, velocities) + return ( - U_dot_∇u(i, j, k, grid, advection, model_fields) - explicit_barotropic_pressure_x_gradient(i, j, k, grid, free_surface) - - x_f_cross_U(i, j, k, grid, coriolis, velocities) + - x_f_cross_U(i, j, k, grid, coriolis, model_fields) - ∂xᶠᶜᶜ(i, j, k, grid, hydrostatic_pressure_anomaly) - ∂ⱼ_τ₁ⱼ(i, j, k, grid, closure, diffusivities, clock, model_fields, buoyancy) - - immersed_∂ⱼ_τ₁ⱼ(i, j, k, grid, velocities, u_immersed_bc, closure, diffusivities, clock, model_fields) - + forcing(i, j, k, grid, clock, hydrostatic_prognostic_fields(velocities, free_surface, tracers))) + - immersed_∂ⱼ_τ₁ⱼ(i, j, k, grid, model_fields, u_immersed_bc, closure, diffusivities, clock, model_fields) + + forcing(i, j, k, grid, clock, model_fields)) end """ @@ -70,24 +66,20 @@ implicitly during time-stepping. coriolis, closure, v_immersed_bc, - velocities, + model_fields, free_surface, - tracers, buoyancy, diffusivities, hydrostatic_pressure_anomaly, - auxiliary_fields, clock, forcing) - model_fields = merge(hydrostatic_fields(velocities, free_surface, tracers), auxiliary_fields) - - return ( - U_dot_∇v(i, j, k, grid, advection, velocities) + return ( - U_dot_∇v(i, j, k, grid, advection, model_fields) - explicit_barotropic_pressure_y_gradient(i, j, k, grid, free_surface) - - y_f_cross_U(i, j, k, grid, coriolis, velocities) + - y_f_cross_U(i, j, k, grid, coriolis, model_fields) - ∂yᶜᶠᶜ(i, j, k, grid, hydrostatic_pressure_anomaly) - ∂ⱼ_τ₂ⱼ(i, j, k, grid, closure, diffusivities, clock, model_fields, buoyancy) - - immersed_∂ⱼ_τ₂ⱼ(i, j, k, grid, velocities, v_immersed_bc, closure, diffusivities, clock, model_fields) + - immersed_∂ⱼ_τ₂ⱼ(i, j, k, grid, model_fields, v_immersed_bc, closure, diffusivities, clock, model_fields) + forcing(i, j, k, grid, clock, model_fields)) end @@ -111,22 +103,17 @@ where `c = C[tracer_index]`. c_immersed_bc, buoyancy, biogeochemistry, - velocities, - free_surface, - tracers, + model_fields, + c, diffusivities, - auxiliary_fields, clock, forcing) where tracer_index - @inbounds c = tracers[tracer_index] - model_fields = merge(hydrostatic_fields(velocities, free_surface, tracers), auxiliary_fields) - biogeochemical_velocities = biogeochemical_drift_velocity(biogeochemistry, val_tracer_name) - total_velocities = (u = SumOfArrays{2}(velocities.u, biogeochemical_velocities.u), - v = SumOfArrays{2}(velocities.v, biogeochemical_velocities.v), - w = SumOfArrays{2}(velocities.w, biogeochemical_velocities.w)) + total_velocities = (u = SumOfArrays{2}(model_fields.u, biogeochemical_velocities.u), + v = SumOfArrays{2}(model_fields.v, biogeochemical_velocities.v), + w = SumOfArrays{2}(model_fields.w, biogeochemical_velocities.w)) total_velocities = with_advective_forcing(forcing, total_velocities) From 2061f57c1d928c1658f4c28ddb0dacb90cf278a8 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Fri, 15 Nov 2024 14:49:19 +0100 Subject: [PATCH 10/13] put model_fields before the tracer loop --- .../compute_hydrostatic_free_surface_tendencies.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_tendencies.jl b/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_tendencies.jl index 8cadc39836..0969e12c0d 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_tendencies.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_tendencies.jl @@ -72,6 +72,8 @@ function compute_hydrostatic_free_surface_tendency_contributions!(model, kernel_ compute_hydrostatic_momentum_tendencies!(model, model.velocities, kernel_parameters; active_cells_map) + model_fields = merge(hydrostatic_fields(model.velocities, model.free_surface, model.tracers), model.auxiliary_fields) + for (tracer_index, tracer_name) in enumerate(propertynames(model.tracers)) @@ -81,7 +83,6 @@ function compute_hydrostatic_free_surface_tendency_contributions!(model, kernel_ @inbounds c_forcing = model.forcing[tracer_name] @inbounds c_immersed_bc = immersed_boundary_condition(model.tracers[tracer_name]) - model_fields = merge(hydrostatic_fields(model.velocities, model.free_surface, model.tracers), model.auxiliary_fields) # We need to pass the free_surface only if it args = tuple(Val(tracer_index), From 1940b6e15621da4fcae04e18b26c6478ef3d77a8 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Fri, 15 Nov 2024 15:05:07 +0100 Subject: [PATCH 11/13] remove tracers from here --- .../compute_hydrostatic_free_surface_tendencies.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_tendencies.jl b/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_tendencies.jl index 0969e12c0d..9cd59e9071 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_tendencies.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_tendencies.jl @@ -139,7 +139,6 @@ function compute_hydrostatic_momentum_tendencies!(model, velocities, kernel_para end_momentum_kernel_args = (model_fields, free_surface, - model.tracers, model.buoyancy, model.diffusivity_fields, model.pressure.pHY′, From d2cc93f44c7528f16268dd787db0cc28bcc5d7de Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Fri, 15 Nov 2024 15:33:15 +0100 Subject: [PATCH 12/13] remove auxiliary fields --- .../compute_hydrostatic_free_surface_tendencies.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_tendencies.jl b/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_tendencies.jl index 9cd59e9071..102b6ced74 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_tendencies.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_tendencies.jl @@ -142,7 +142,6 @@ function compute_hydrostatic_momentum_tendencies!(model, velocities, kernel_para model.buoyancy, model.diffusivity_fields, model.pressure.pHY′, - model.auxiliary_fields, model.clock) u_kernel_args = tuple(start_momentum_kernel_args..., u_immersed_bc, end_momentum_kernel_args...) From 32a711efc837497de3e52462244755fd1d3844c9 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Mon, 18 Nov 2024 13:48:17 -0800 Subject: [PATCH 13/13] revert to previous code --- ...ute_hydrostatic_free_surface_tendencies.jl | 21 ++++------ ..._free_surface_tendency_kernel_functions.jl | 41 ++++++++++++------- 2 files changed, 35 insertions(+), 27 deletions(-) diff --git a/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_tendencies.jl b/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_tendencies.jl index 102b6ced74..9e21089913 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_tendencies.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_tendencies.jl @@ -72,19 +72,13 @@ function compute_hydrostatic_free_surface_tendency_contributions!(model, kernel_ compute_hydrostatic_momentum_tendencies!(model, model.velocities, kernel_parameters; active_cells_map) - model_fields = merge(hydrostatic_fields(model.velocities, model.free_surface, model.tracers), model.auxiliary_fields) - for (tracer_index, tracer_name) in enumerate(propertynames(model.tracers)) - - @inbounds tracer = model.tracers[tracer_name] @inbounds c_tendency = model.timestepper.Gⁿ[tracer_name] @inbounds c_advection = model.advection[tracer_name] @inbounds c_forcing = model.forcing[tracer_name] @inbounds c_immersed_bc = immersed_boundary_condition(model.tracers[tracer_name]) - - # We need to pass the free_surface only if it args = tuple(Val(tracer_index), Val(tracer_name), c_advection, @@ -92,9 +86,11 @@ function compute_hydrostatic_free_surface_tendency_contributions!(model, kernel_ c_immersed_bc, model.buoyancy, model.biogeochemistry, - model_fields, - tracer, + model.velocities, + model.free_surface, + model.tracers, model.diffusivity_fields, + model.auxiliary_fields, model.clock, c_forcing) @@ -130,18 +126,17 @@ function compute_hydrostatic_momentum_tendencies!(model, velocities, kernel_para u_immersed_bc = immersed_boundary_condition(velocities.u) v_immersed_bc = immersed_boundary_condition(velocities.v) - model_fields = merge(hydrostatic_fields(model.velocities, model.free_surface, model.tracers), model.auxiliary_fields) - free_surface = model.free_surface isa ExplicitFreeSurface ? model.free_surface : nothing - start_momentum_kernel_args = (model.advection.momentum, model.coriolis, model.closure) - end_momentum_kernel_args = (model_fields, - free_surface, + end_momentum_kernel_args = (velocities, + model.free_surface, + model.tracers, model.buoyancy, model.diffusivity_fields, model.pressure.pHY′, + model.auxiliary_fields, model.clock) u_kernel_args = tuple(start_momentum_kernel_args..., u_immersed_bc, end_momentum_kernel_args...) diff --git a/src/Models/HydrostaticFreeSurfaceModels/hydrostatic_free_surface_tendency_kernel_functions.jl b/src/Models/HydrostaticFreeSurfaceModels/hydrostatic_free_surface_tendency_kernel_functions.jl index 34da3e2b9e..605849dbee 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/hydrostatic_free_surface_tendency_kernel_functions.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/hydrostatic_free_surface_tendency_kernel_functions.jl @@ -31,21 +31,25 @@ implicitly during time-stepping. coriolis, closure, u_immersed_bc, - model_fields, + velocities, free_surface, + tracers, buoyancy, diffusivities, hydrostatic_pressure_anomaly, + auxiliary_fields, clock, forcing) + + model_fields = merge(hydrostatic_fields(velocities, free_surface, tracers), auxiliary_fields) - return ( - U_dot_∇u(i, j, k, grid, advection, model_fields) + return ( - U_dot_∇u(i, j, k, grid, advection, velocities) - explicit_barotropic_pressure_x_gradient(i, j, k, grid, free_surface) - - x_f_cross_U(i, j, k, grid, coriolis, model_fields) + - x_f_cross_U(i, j, k, grid, coriolis, velocities) - ∂xᶠᶜᶜ(i, j, k, grid, hydrostatic_pressure_anomaly) - ∂ⱼ_τ₁ⱼ(i, j, k, grid, closure, diffusivities, clock, model_fields, buoyancy) - - immersed_∂ⱼ_τ₁ⱼ(i, j, k, grid, model_fields, u_immersed_bc, closure, diffusivities, clock, model_fields) - + forcing(i, j, k, grid, clock, model_fields)) + - immersed_∂ⱼ_τ₁ⱼ(i, j, k, grid, velocities, u_immersed_bc, closure, diffusivities, clock, model_fields) + + forcing(i, j, k, grid, clock, hydrostatic_prognostic_fields(velocities, free_surface, tracers))) end """ @@ -66,20 +70,24 @@ implicitly during time-stepping. coriolis, closure, v_immersed_bc, - model_fields, + velocities, free_surface, + tracers, buoyancy, diffusivities, hydrostatic_pressure_anomaly, + auxiliary_fields, clock, forcing) - return ( - U_dot_∇v(i, j, k, grid, advection, model_fields) + model_fields = merge(hydrostatic_fields(velocities, free_surface, tracers), auxiliary_fields) + + return ( - U_dot_∇v(i, j, k, grid, advection, velocities) - explicit_barotropic_pressure_y_gradient(i, j, k, grid, free_surface) - - y_f_cross_U(i, j, k, grid, coriolis, model_fields) + - y_f_cross_U(i, j, k, grid, coriolis, velocities) - ∂yᶜᶠᶜ(i, j, k, grid, hydrostatic_pressure_anomaly) - ∂ⱼ_τ₂ⱼ(i, j, k, grid, closure, diffusivities, clock, model_fields, buoyancy) - - immersed_∂ⱼ_τ₂ⱼ(i, j, k, grid, model_fields, v_immersed_bc, closure, diffusivities, clock, model_fields) + - immersed_∂ⱼ_τ₂ⱼ(i, j, k, grid, velocities, v_immersed_bc, closure, diffusivities, clock, model_fields) + forcing(i, j, k, grid, clock, model_fields)) end @@ -103,17 +111,22 @@ where `c = C[tracer_index]`. c_immersed_bc, buoyancy, biogeochemistry, - model_fields, - c, + velocities, + free_surface, + tracers, diffusivities, + auxiliary_fields, clock, forcing) where tracer_index + @inbounds c = tracers[tracer_index] + model_fields = merge(hydrostatic_fields(velocities, free_surface, tracers), auxiliary_fields) + biogeochemical_velocities = biogeochemical_drift_velocity(biogeochemistry, val_tracer_name) - total_velocities = (u = SumOfArrays{2}(model_fields.u, biogeochemical_velocities.u), - v = SumOfArrays{2}(model_fields.v, biogeochemical_velocities.v), - w = SumOfArrays{2}(model_fields.w, biogeochemical_velocities.w)) + total_velocities = (u = SumOfArrays{2}(velocities.u, biogeochemical_velocities.u), + v = SumOfArrays{2}(velocities.v, biogeochemical_velocities.v), + w = SumOfArrays{2}(velocities.w, biogeochemical_velocities.w)) total_velocities = with_advective_forcing(forcing, total_velocities)