Outputting/Evaluating fields at the bottom of an immersed boundary grid #3032
Replies: 2 comments 23 replies
-
I am not sure I understood correctly, but do you want a 2D field that in The cell just above bathymetry is the only cell in the column for which So you can do julia> grid = RectilinearGrid(size = (10, 10, 10), extent = (1, 1, 1))
10×10×10 RectilinearGrid{Float64, Periodic, Periodic, Bounded} on CPU with 3×3×3 halo
├── Periodic x ∈ [0.0, 1.0) regularly spaced with Δx=0.1
├── Periodic y ∈ [0.0, 1.0) regularly spaced with Δy=0.1
└── Bounded z ∈ [-1.0, 0.0] regularly spaced with Δz=0.1
julia> ibg = ImmersedBoundaryGrid(grid, GridFittedBottom((x, y) -> - x))
10×10×10 ImmersedBoundaryGrid{Float64, Periodic, Periodic, Bounded} on CPU with 3×3×3 halo:
├── immersed_boundary: GridFittedBottom(min(h)=-9.50e-01, max(h)=-5.00e-02)
├── underlying_grid: 10×10×10 RectilinearGrid{Float64, Periodic, Periodic, Bounded} on CPU with 3×3×3 halo
├── Periodic x ∈ [0.0, 1.0) regularly spaced with Δx=0.1
├── Periodic y ∈ [0.0, 1.0) regularly spaced with Δy=0.1
└── Bounded z ∈ [-1.0, 0.0] regularly spaced with Δz=0.1
julia> field = CenterField(ibg)
10×10×10 Field{Center, Center, Center} on ImmersedBoundaryGrid on CPU
├── grid: 10×10×10 ImmersedBoundaryGrid{Float64, Periodic, Periodic, Bounded} on CPU with 3×3×3 halo
├── boundary conditions: FieldBoundaryConditions
│ └── west: Periodic, east: Periodic, south: Periodic, north: Periodic, bottom: ZeroFlux, top: ZeroFlux, immersed: ZeroFlux
└── data: 16×16×16 OffsetArray(::Array{Float64, 3}, -2:13, -2:13, -2:13) with eltype Float64 with indices -2:13×-2:13×-2:13
└── max=0.0, min=0.0, mean=0.0
julia> set!(field, (x, y, z) -> x)
10×10×10 Field{Center, Center, Center} on ImmersedBoundaryGrid on CPU
├── grid: 10×10×10 ImmersedBoundaryGrid{Float64, Periodic, Periodic, Bounded} on CPU with 3×3×3 halo
├── boundary conditions: FieldBoundaryConditions
│ └── west: Periodic, east: Periodic, south: Periodic, north: Periodic, bottom: ZeroFlux, top: ZeroFlux, immersed: ZeroFlux
└── data: 16×16×16 OffsetArray(::Array{Float64, 3}, -2:13, -2:13, -2:13) with eltype Float64 with indices -2:13×-2:13×-2:13
└── max=0.95, min=0.15, mean=0.683333
julia> using Oceananigans.ImmersedBoundaries: immersed_peripheral_node
julia> @inline bottom_condition(i, j, k, grid) = immersed_peripheral_node(i, j, k-1, grid, Center(), Center(), Center())
bottom_condition (generic function with 1 method)
julia> using Oceananigans.Fields: condition_operand
julia> bottom_height = sum(condition_operand(identity, field, bottom_condition, 0.0), dims = 3)
10×10×1 Field{Center, Center, Nothing} reduced over dims = (3,) on ImmersedBoundaryGrid on CPU
├── grid: 10×10×10 ImmersedBoundaryGrid{Float64, Periodic, Periodic, Bounded} on CPU with 3×3×3 halo
├── boundary conditions: FieldBoundaryConditions
│ └── west: Periodic, east: Periodic, south: Periodic, north: Periodic, bottom: Nothing, top: Nothing, immersed: ZeroFlux
└── data: 16×16×1 OffsetArray(::Array{Float64, 3}, -2:13, -2:13, 1:1) with eltype Float64 with indices -2:13×-2:13×1:1
└── max=0.95, min=0.15, mean=0.55
julia> interior(bottom_height)
10×10×1 view(::Array{Float64, 3}, 4:13, 4:13, 1:1) with eltype Float64:
[:, :, 1] =
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.15 0.15 0.15 0.15 0.15 0.15 0.15 0.15 0.15 0.15
0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25
0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35
0.45 0.45 0.45 0.45 0.45 0.45 0.45 0.45 0.45 0.45
0.55 0.55 0.55 0.55 0.55 0.55 0.55 0.55 0.55 0.55
0.65 0.65 0.65 0.65 0.65 0.65 0.65 0.65 0.65 0.65
0.75 0.75 0.75 0.75 0.75 0.75 0.75 0.75 0.75 0.75
0.85 0.85 0.85 0.85 0.85 0.85 0.85 0.85 0.85 0.85
0.95 0.95 0.95 0.95 0.95 0.95 0.95 0.95 0.95 0.95
|
Beta Was this translation helpful? Give feedback.
-
OK, fair point. We do not need to precompute anything. Just create the functionality for the user to do it just by prescribing a kwarg or something. |
Beta Was this translation helpful? Give feedback.
-
Sorry that I don't know this but when using an immersed boundary method, what's the best way to evaluate a field at the bottom, right at the bathymetry?
Beta Was this translation helpful? Give feedback.
All reactions