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

(0.90.11) Tests for a distributed Immersed boundary grid + fix some on_architecture bugs #3487

Merged
merged 18 commits into from
Mar 12, 2024
Merged
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
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Oceananigans"
uuid = "9e8cae18-63c1-5223-a75c-80ca9d6e9a09"
authors = ["Climate Modeling Alliance and contributors"]
version = "0.90.10"
version = "0.90.11"

[deps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
Expand Down
12 changes: 6 additions & 6 deletions src/Fields/field.jl
Original file line number Diff line number Diff line change
Expand Up @@ -420,12 +420,12 @@ total_size(f::Field) = total_size(f.grid, location(f), f.indices)

on_architecture(arch, field::AbstractField{LX, LY, LZ}) where {LX, LY, LZ} =
Field{LX, LY, LZ}(on_architecture(arch, field.grid),
on_architecture(arch, data),
on_architecture(arch, bcs),
on_architecture(arch, indices),
on_architecture(arch, op),
on_architecture(arch, status),
on_architecture(arch, buffers))
on_architecture(arch, field.data),
on_architecture(arch, field.boundary_conditions),
on_architecture(arch, field.indices),
on_architecture(arch, field.operand),
on_architecture(arch, field.status),
on_architecture(arch, field.boundary_buffers))

#####
##### Interface for field computations
Expand Down
1 change: 1 addition & 0 deletions test/dependencies_for_runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ using Oceananigans.Units
using Oceananigans.Utils
using Oceananigans.MultiRegion
using Oceananigans.Architectures: device, array_type # to resolve conflict with CUDA.device
using Oceananigans.Architectures: on_architecture

using Oceananigans: Clock
using Dates: DateTime, Nanosecond
Expand Down
96 changes: 52 additions & 44 deletions test/test_distributed_hydrostatic_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,49 +78,57 @@ Ny = 32

for arch in archs
@testset "Testing distributed solid body rotation" begin
grid = LatitudeLongitudeGrid(arch, size = (Nx, Ny, 1),
halo = (4, 4, 4),
latitude = (-80, 80),
longitude = (-160, 160),
z = (-1, 0),
radius = 1,
topology=(Bounded, Bounded, Bounded))

global_grid = reconstruct_global_grid(grid)

# "s" for "serial" computation
us, vs, ws, cs, ηs = solid_body_rotation_test(global_grid)

us = Array(interior(us))
vs = Array(interior(vs))
ws = Array(interior(ws))
cs = Array(interior(cs))
ηs = Array(interior(ηs))

@info " Testing distributed solid body rotation with architecture $arch"
u, v, w, c, η = solid_body_rotation_test(grid)

u = Array(interior(u))
v = Array(interior(v))
w = Array(interior(w))
c = Array(interior(c))
η = Array(interior(η))

cpu_arch = cpu_architecture(arch)

us = partition_global_array(cpu_arch, us, size(u))
vs = partition_global_array(cpu_arch, vs, size(v))
ws = partition_global_array(cpu_arch, ws, size(w))
cs = partition_global_array(cpu_arch, cs, size(c))
ηs = partition_global_array(cpu_arch, ηs, size(η))

atol = eps(eltype(grid))
rtol = sqrt(eps(eltype(grid)))

@test all(isapprox(u, us; atol, rtol))
@test all(isapprox(v, vs; atol, rtol))
@test all(isapprox(w, ws; atol, rtol))
@test all(isapprox(c, cs; atol, rtol))
@test all(isapprox(η, ηs; atol, rtol))
underlying_grid = LatitudeLongitudeGrid(arch, size = (Nx, Ny, 1),
halo = (4, 4, 4),
latitude = (-80, 80),
longitude = (-160, 160),
z = (-1, 0),
radius = 1,
topology=(Bounded, Bounded, Bounded))

bottom(λ, φ) = -30 < λ < 30 && -40 < φ < 20 ? 0 : - 1

immersed_grid = ImmersedBoundaryGrid(underlying_grid, GridFittedBottom(bottom); active_cells_map = true)

global_underlying_grid = reconstruct_global_grid(underlying_grid)
global_immersed_grid = ImmersedBoundaryGrid(global_underlying_grid, GridFittedBottom(bottom); active_cells_map = true)

for (grid, global_grid) in zip((underlying_grid, immersed_grid), (global_underlying_grid, global_immersed_grid))

# "s" for "serial" computation
us, vs, ws, cs, ηs = solid_body_rotation_test(global_grid)

us = interior(on_architecture(CPU(), us))
vs = interior(on_architecture(CPU(), vs))
ws = interior(on_architecture(CPU(), ws))
cs = interior(on_architecture(CPU(), cs))
ηs = interior(on_architecture(CPU(), ηs))

@info " Testing distributed solid body rotation with architecture $arch on $(typeof(grid).name.wrapper)"
u, v, w, c, η = solid_body_rotation_test(grid)

cpu_arch = cpu_architecture(arch)

u = interior(on_architecture(cpu_arch, u))
v = interior(on_architecture(cpu_arch, v))
w = interior(on_architecture(cpu_arch, w))
c = interior(on_architecture(cpu_arch, c))
η = interior(on_architecture(cpu_arch, η))

us = partition_global_array(cpu_arch, us, size(u))
vs = partition_global_array(cpu_arch, vs, size(v))
ws = partition_global_array(cpu_arch, ws, size(w))
cs = partition_global_array(cpu_arch, cs, size(c))
ηs = partition_global_array(cpu_arch, ηs, size(η))

atol = eps(eltype(grid))
rtol = sqrt(eps(eltype(grid)))

@test all(isapprox(u, us; atol, rtol))
@test all(isapprox(v, vs; atol, rtol))
@test all(isapprox(w, ws; atol, rtol))
@test all(isapprox(c, cs; atol, rtol))
@test all(isapprox(η, ηs; atol, rtol))
navidcy marked this conversation as resolved.
Show resolved Hide resolved
end
end
end