Skip to content

Clean up update_boundary_conditions! #4503

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 5 additions & 5 deletions src/BoundaryConditions/update_boundary_conditions.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using Oceananigans: boundary_conditions

@inline update_boundary_conditions!(bcs, field, model) = nothing
@inline update_boundary_condition!(bc, side, field, model) = nothing
@inline update_boundary_condition!(bcs, field, model) = nothing

function update_boundary_condition!(bcs::FieldBoundaryConditions, field, model)
function update_boundary_conditions!(bcs::FieldBoundaryConditions, field, model)
update_boundary_condition!(bcs.west, Val(:west), field, model)
update_boundary_condition!(bcs.east, Val(:east), field, model)
update_boundary_condition!(bcs.south, Val(:south), field, model)
Expand All @@ -14,12 +14,12 @@ function update_boundary_condition!(bcs::FieldBoundaryConditions, field, model)
return nothing
end

update_boundary_condition!(fields::NamedTuple, model) = update_boundary_condition!(values(fields), model)
update_boundary_conditions!(fields::NamedTuple, model) = update_boundary_conditions!(values(fields), model)

function update_boundary_condition!(fields::Tuple, model)
function update_boundary_conditions!(fields::Tuple, model)
for field in fields
bcs = boundary_conditions(field)
update_boundary_condition!(bcs, field, model)
update_boundary_conditions!(bcs, field, model)
end

return nothing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ using Oceananigans.BoundaryConditions

using Oceananigans: UpdateStateCallsite
using Oceananigans.Biogeochemistry: update_biogeochemical_state!
using Oceananigans.BoundaryConditions: update_boundary_condition!, replace_horizontal_vector_halos!
using Oceananigans.BoundaryConditions: update_boundary_conditions!, replace_horizontal_vector_halos!
using Oceananigans.TurbulenceClosures: compute_diffusivities!
using Oceananigans.ImmersedBoundaries: mask_immersed_field!, mask_immersed_field_xy!, inactive_node
using Oceananigans.Models: update_model_field_time_series!
Expand Down Expand Up @@ -37,7 +37,7 @@ function update_state!(model::HydrostaticFreeSurfaceModel, grid, callbacks; comp
@apply_regionally update_model_field_time_series!(model, model.clock)

# Update the boundary conditions
@apply_regionally update_boundary_condition!(fields(model), model)
@apply_regionally update_boundary_conditions!(fields(model), model)

tupled_fill_halo_regions!(prognostic_fields(model), grid, model.clock, fields(model), async=true)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function update_state!(model::NonhydrostaticModel, callbacks=[]; compute_tendenc
update_model_field_time_series!(model, model.clock)

# Update the boundary conditions
update_boundary_condition!(fields(model), model)
update_boundary_conditions!(fields(model), model)

# Fill halos for velocities and tracers
fill_halo_regions!(merge(model.velocities, model.tracers), model.clock, fields(model);
Expand Down
13 changes: 3 additions & 10 deletions src/Models/boundary_mean.jl
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ Base.summary(bam::BoundaryAdjacentMean) = "BoundaryAdjacentMean: ($(bam.value[])

(bam::BoundaryAdjacentMean)(side, u) = bam(Val(side), u)

# computes the boundary mean and stores/returns it
# Computes the boundary mean and stores it.
function (bam::BoundaryAdjacentMean)(val_side::Val, u)
grid = u.grid

Expand All @@ -111,15 +111,8 @@ function (bam::BoundaryAdjacentMean)(val_side::Val, u)

bam.value[] /= CUDA.@allowscalar bam.flux_field[iB, jB, kB]

return bam.value[]
return nothing
end

# let this get updated in boundary conditions

const MOOBC = BoundaryCondition{<:Open, <:BoundaryAdjacentMean}

@inline function update_boundary_condition!(bc::MOOBC, val_side, u, model)
bc.condition(val_side, u)

return nothing
end
@inline update_boundary_condition!(bc::MOOBC, val_side, u, model) = bc.condition(val_side, u)
Loading