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

ImmersedBoundaryCondition for drag, take 2 #137

Merged
merged 27 commits into from
Nov 10, 2024
Merged
Changes from 2 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
6f81571
take 2
simone-silvestri Aug 14, 2024
2548528
forse restart build
simone-silvestri Aug 14, 2024
2ae2f6a
Update src/OceanSimulations/OceanSimulations.jl
simone-silvestri Aug 14, 2024
5209b3f
bugfix
simone-silvestri Aug 14, 2024
13e8d91
Merge branch 'ss/immersed-boundary-conditions-take-2' of github.com:C…
simone-silvestri Aug 14, 2024
41d5b19
Merge branch 'main' into ss/immersed-boundary-conditions-take-2
simone-silvestri Aug 15, 2024
9bf8862
adapt to new syntax
simone-silvestri Aug 15, 2024
9653b2c
Merge branch 'main' into ss/immersed-boundary-conditions-take-2
simone-silvestri Aug 19, 2024
14c9e94
Merge branch 'main' into ss/immersed-boundary-conditions-take-2
simone-silvestri Aug 20, 2024
50f2046
Merge branch 'main' into ss/immersed-boundary-conditions-take-2
simone-silvestri Aug 27, 2024
18b1ed8
update project
simone-silvestri Aug 28, 2024
cca28de
Merge branch 'main' into ss/immersed-boundary-conditions-take-2
simone-silvestri Sep 6, 2024
fe7faf7
update Oceananigans
simone-silvestri Sep 16, 2024
43379eb
Merge branch 'main' into ss/immersed-boundary-conditions-take-2
simone-silvestri Sep 18, 2024
3b60770
Merge branch 'main' into ss/immersed-boundary-conditions-take-2
simone-silvestri Sep 24, 2024
3d48ce0
Merge branch 'main' into ss/immersed-boundary-conditions-take-2
simone-silvestri Oct 29, 2024
ebcadb1
Merge branch 'main' into ss/immersed-boundary-conditions-take-2
simone-silvestri Nov 4, 2024
d34eea6
Update OceanSimulations.jl
simone-silvestri Nov 4, 2024
a69b71e
add also generate fluxes
simone-silvestri Nov 5, 2024
637c9f5
this should work now?
simone-silvestri Nov 5, 2024
2094ae4
try adding manifest
simone-silvestri Nov 5, 2024
8a833fa
Merge branch 'main' into ss/immersed-boundary-conditions-take-2
simone-silvestri Nov 6, 2024
4d80a81
remove the manifest
simone-silvestri Nov 6, 2024
0fd6607
Merge branch 'main' into ss/immersed-boundary-conditions-take-2
simone-silvestri Nov 6, 2024
bfe46cf
Merge branch 'main' into ss/immersed-boundary-conditions-take-2
simone-silvestri Nov 8, 2024
56edade
Merge branch 'main' into ss/immersed-boundary-conditions-take-2
simone-silvestri Nov 9, 2024
7f4217e
Merge branch 'main' into ss/immersed-boundary-conditions-take-2
simone-silvestri Nov 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 19 additions & 16 deletions src/OceanSimulations/OceanSimulations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,9 @@ default_tracer_advection() = TracerAdvection(WENO(; order = 7),
@inline u_quadratic_bottom_drag(i, j, grid, c, Φ, μ) = @inbounds - μ * Φ.u[i, j, 1] * spᶠᶜᶜ(i, j, 1, grid, Φ)
@inline v_quadratic_bottom_drag(i, j, grid, c, Φ, μ) = @inbounds - μ * Φ.v[i, j, 1] * spᶜᶠᶜ(i, j, 1, grid, Φ)

@inline is_immersed_drag_u(i, j, k, grid) = Int(immersed_peripheral_node(i, j, k-1, grid, Face(), Center(), Center()) & !inactive_node(i, j, k, grid, Face(), Center(), Center()))
@inline is_immersed_drag_v(i, j, k, grid) = Int(immersed_peripheral_node(i, j, k-1, grid, Center(), Face(), Center()) & !inactive_node(i, j, k, grid, Center(), Face(), Center()))

# Keep a constant linear drag parameter independent on vertical level
@inline u_immersed_bottom_drag(i, j, k, grid, clock, fields, μ) = @inbounds - μ * fields.u[i, j, k] * is_immersed_drag_u(i, j, k, grid) * spᶠᶜᶜ(i, j, k, grid, fields) / Δzᶠᶜᶜ(i, j, k, grid)
@inline v_immersed_bottom_drag(i, j, k, grid, clock, fields, μ) = @inbounds - μ * fields.v[i, j, k] * is_immersed_drag_v(i, j, k, grid) * spᶜᶠᶜ(i, j, k, grid, fields) / Δzᶜᶠᶜ(i, j, k, grid)
@inline u_immersed_bottom_drag(i, j, k, grid, clock, fields, μ) = @inbounds - μ * fields.u[i, j, k] * spᶠᶜᶜ(i, j, k, grid, fields)
@inline v_immersed_bottom_drag(i, j, k, grid, clock, fields, μ) = @inbounds - μ * fields.v[i, j, k] * spᶜᶠᶜ(i, j, k, grid, fields)

# TODO: Specify the grid to a grid on the sphere; otherwise we can provide a different
# function that requires latitude and longitude etc for computing coriolis=FPlane...
Expand All @@ -65,26 +62,32 @@ function ocean_simulation(grid; Δt = 5minutes,
tracer_advection = default_tracer_advection(),
verbose = false)

# Set up boundary conditions using Field
# allocate memory in `Field`s for surface forcing boundary conditions
simone-silvestri marked this conversation as resolved.
Show resolved Hide resolved
top_zonal_momentum_flux = Jᵘ = Field{Face, Center, Nothing}(grid)
top_meridional_momentum_flux = Jᵛ = Field{Center, Face, Nothing}(grid)
top_ocean_heat_flux = Jᵀ = Field{Center, Center, Nothing}(grid)
top_salt_flux = Jˢ = Field{Center, Center, Nothing}(grid)

# Construct ocean boundary conditions including surface forcing and bottom drag
u_top_bc = FluxBoundaryCondition(Jᵘ)
v_top_bc = FluxBoundaryCondition(Jᵛ)
T_top_bc = FluxBoundaryCondition(Jᵀ)
S_top_bc = FluxBoundaryCondition(Jˢ)

u_bot_bc = FluxBoundaryCondition(u_quadratic_bottom_drag, discrete_form=true, parameters=bottom_drag_coefficient)
v_bot_bc = FluxBoundaryCondition(v_quadratic_bottom_drag, discrete_form=true, parameters=bottom_drag_coefficient)

ocean_boundary_conditions = (u = FieldBoundaryConditions(top = FluxBoundaryCondition(Jᵘ), bottom = u_bot_bc),
v = FieldBoundaryConditions(top = FluxBoundaryCondition(Jᵛ), bottom = v_bot_bc),
T = FieldBoundaryConditions(top = FluxBoundaryCondition(Jᵀ)),
S = FieldBoundaryConditions(top = FluxBoundaryCondition(Jˢ)))
u_immersed_drag = FluxBoundaryCondition(u_immersed_bottom_drag, discrete_form=true, parameters=bottom_drag_coefficient)
v_immersed_drag = FluxBoundaryCondition(v_immersed_bottom_drag, discrete_form=true, parameters=bottom_drag_coefficient)

u_immersed_bc = ImmersedBoundaryCondition(bottom = u_immersed_drag)
v_immersed_bc = ImmersedBoundaryCondition(bottom = v_immersed_drag)

ocean_boundary_conditions = (u = FieldBoundaryConditions(top = u_top_bc, bottom = u_bot_bc, immmersed = u_immersed_bc),
v = FieldBoundaryConditions(top = v_top_bc, bottom = v_bot_bc, immmersed = v_immersed_bc),
T = FieldBoundaryConditions(top = T_top_bc),
S = FieldBoundaryConditions(top = S_top_bc))

if grid isa ImmersedBoundaryGrid
Fu = Forcing(u_immersed_bottom_drag, discrete_form=true, parameters=bottom_drag_coefficient)
Fv = Forcing(v_immersed_bottom_drag, discrete_form=true, parameters=bottom_drag_coefficient)
forcing = merge(forcing, (; u = Fu, v = Fv))
end

# Use the TEOS10 equation of state
teos10 = TEOS10EquationOfState(; reference_density)
buoyancy = SeawaterBuoyancy(; gravitational_acceleration, equation_of_state=teos10)
Expand Down
Loading