Skip to content

Conversation

@simone-silvestri
Copy link
Collaborator

@simone-silvestri simone-silvestri commented Jul 25, 2025

I am implementing immersed drag for a SeaIceModel here, but I noticed that the regularization for ImmersedBoundaryCondition is not correct because it assigns boundary conditions in nothing directions, for example, in CliMA/ClimaSeaIce.jl#84 this happens:

julia> grid = RectilinearGrid(size = (10, 10, 1), x = (0, 1), y = (0, 1), z = (0, 1));

julia> grid = ImmersedBoundaryGrid(grid, GridFittedBottom(rand(10, 10)));

julia> u_bcs = FieldBoundaryConditions(grid, (Face, Center, Nothing); immersed = FluxBoundaryCondition(1));

julia> model = SeaIceModel(grid; boundary_conditions = (; u = u_bcs));

julia> model.velocities.u.boundary_conditions.immersed
ImmersedBoundaryCondition:
├── west: Nothing
├── east: Nothing
├── south: FluxBoundaryCondition: 1.0
├── north: FluxBoundaryCondition: 1.0
├── bottom: FluxBoundaryCondition: 1.0
└── top: FluxBoundaryCondition: 1.0

In this case, top and bottom boundary conditions should be a Nothing, so this PR corrects this regularization

@glwagner glwagner merged commit 07519ae into main Jul 25, 2025
66 of 69 checks passed
@glwagner glwagner deleted the ss/fix-the-regularize branch July 25, 2025 19:38
@navidcy
Copy link
Member

navidcy commented Jul 26, 2025

just noting that even after this is merged; using ClimaSeaIce#main and Oceananigans#main I get:

(ClimaSeaIce) pkg> st
Project ClimaSeaIce v0.3.2
Status `~/Library/CloudStorage/OneDrive-TheUniversityofMelbourne/Documents/Research/ClimaSeaIce.jl/Project.toml`
  [79e6a3ab] Adapt v4.3.0
  [63c18a36] KernelAbstractions v0.9.38
  [9e8cae18] Oceananigans v0.97.3 `https://github.com/CliMA/Oceananigans.jl.git#main`
  [7181ea78] RootSolvers v0.4.4
  [f2b01f46] Roots v2.2.8
  [d496a93d] SeawaterPolynomials v0.3.10

julia> using Oceananigans, ClimaSeaIce

julia> grid = RectilinearGrid(size = (10, 10, 1), x = (0, 1), y = (0, 1), z = (0, 1));

julia> grid = ImmersedBoundaryGrid(grid, GridFittedBottom(rand(10, 10)));

julia> u_bcs = FieldBoundaryConditions(grid, (Face, Center, Nothing); immersed = FluxBoundaryCondition(1));

julia> model = SeaIceModel(grid; boundary_conditions = (; u = u_bcs));

julia> model.velocities.u.boundary_conditions.immersed
ImmersedBoundaryCondition:
├── west: Nothing
├── east: Nothing
├── south: FluxBoundaryCondition: 1.0
├── north: FluxBoundaryCondition: 1.0
├── bottom: FluxBoundaryCondition: 1.0
└── top: FluxBoundaryCondition: 1.0

@navidcy
Copy link
Member

navidcy commented Jul 26, 2025

I think this happens because Oceananigans.Operators.assumed_field_location(:u) = (Face, Center, Center) and Oceananigans.BoundaryConditions.regularize_field_boundary_conditions use that, even for the SeaIceModel

@glwagner
Copy link
Member

good call. Then perhaps SeaIceModel needs to do something special with the bcs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants