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

Some problems with ImmersedBoundaryGrids #3742

Closed
simone-silvestri opened this issue Aug 27, 2024 · 6 comments · Fixed by #3746
Closed

Some problems with ImmersedBoundaryGrids #3742

simone-silvestri opened this issue Aug 27, 2024 · 6 comments · Fixed by #3746

Comments

@simone-silvestri
Copy link
Collaborator

I hit these issues when setting a field on an immersed boundary grid.

ERROR: LoadError: MethodError: no method matching ξname(::ImmersedBoundaryGrid{Float64, Periodic, RightConnected, Bounded, OrthogonalSphericalShellGrid{Float64, Periodic, RightConnected, Bounded, OffsetArrays.OffsetMatrix{Float64, CUDA.CuArray{Float64, 2, CUDA.DeviceMemory}}, OffsetArrays.OffsetVector{Float64, CUDA.CuArray{Float64, 1, CUDA.DeviceMemory}}, OffsetArrays.OffsetVector{Float64, CUDA.CuArray{Float64, 1, CUDA.DeviceMemory}}, OrthogonalSphericalShellGrids.Tripolar{Int64, Int64, Int64}, GPU}, GridFittedBottom{Field{Center, Center, Nothing, Nothing, OrthogonalSphericalShellGrid{Float64, Periodic, RightConnected, Bounded, OffsetArrays.OffsetMatrix{Float64, CUDA.CuArray{Float64, 2, CUDA.DeviceMemory}}, OffsetArrays.OffsetVector{Float64, CUDA.CuArray{Float64, 1, CUDA.DeviceMemory}}, OffsetArrays.OffsetVector{Float64, CUDA.CuArray{Float64, 1, CUDA.DeviceMemory}}, OrthogonalSphericalShellGrids.Tripolar{Int64, Int64, Int64}, GPU}, Tuple{Colon, Colon, Colon}, OffsetArrays.OffsetArray{Float64, 3, CUDA.CuArray{Float64, 3, CUDA.DeviceMemory}}, Float64, FieldBoundaryConditions{BoundaryCondition{Oceananigans.BoundaryConditions.Periodic, Nothing}, BoundaryCondition{Oceananigans.BoundaryConditions.Periodic, Nothing}, BoundaryCondition{Flux, Nothing}, BoundaryCondition{OrthogonalSphericalShellGrids.Zipper, Int64}, Nothing, Nothing, Oceananigans.BoundaryConditions.DefaultBoundaryCondition{BoundaryCondition{Flux, Nothing}}}, Nothing, Oceananigans.Fields.FieldBoundaryBuffers{Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}}, Oceananigans.ImmersedBoundaries.CenterImmersedCondition}, CUDA.CuArray{Tuple{UInt16, UInt16, UInt16}, 1, CUDA.DeviceMemory}, CUDA.CuArray{Tuple{UInt16, UInt16}, 1, CUDA.DeviceMemory}, GPU})

Closest candidates are:
  ξname(!Matched::LatitudeLongitudeGrid)
   @ Oceananigans ~/.julia/packages/Oceananigans/O8Ult/src/Grids/latitude_longitude_grid.jl:574
  ξname(!Matched::OrthogonalSphericalShellGrid)
   @ Oceananigans ~/.julia/packages/Oceananigans/O8Ult/src/Grids/orthogonal_spherical_shell_grid.jl:1188
  ξname(!Matched::RectilinearGrid)
   @ Oceananigans ~/.julia/packages/Oceananigans/O8Ult/src/Grids/rectilinear_grid.jl:419
@simone-silvestri
Copy link
Collaborator Author

My bad. It was a trivial issue. I ll close this issue

@glwagner
Copy link
Member

What was the code? We can improve the error message

@simone-silvestri
Copy link
Collaborator Author

Oh, right, I see what the problem was; I was trying to set a field using a function that had a typo, so the set! errored here

try
set!(cpu_u, f_field)
catch err

However, the catch itself errored here
catch err
u_loc = Tuple(L() for L in location(u))
arg_str = tuple_string(node_names(u.grid, u_loc...))
loc_str = tuple_string(location(u))
topo_str = tuple_string(topology(u.grid))
msg = string("An error was encountered within set! while setting the field", '\n', '\n',
" ", prettysummary(u), '\n', '\n',
"Note that to use set!(field, func::Function) on a field at location ",

because node_names is not defined for immersed grids.
So, the error that the catch was spitting out was not related to the actual error I had.
I guess it's a matter of defining the node_names for immersed boundary grids

@glwagner
Copy link
Member

Ok, I think that should just pass to the underlying grid

@glwagner glwagner reopened this Aug 27, 2024
@glwagner
Copy link
Member

sorry can you also produce the code that made the error

@glwagner
Copy link
Member

I got it

julia> using Oceananigans
Precompiling Oceananigans
  1 dependency successfully precompiled in 11 seconds. 139 already precompiled.

julia> grid = RectilinearGrid(size=1, x=(0, 1), topology=(Periodic, Flat, Flat))
1×1×1 RectilinearGrid{Float64, Periodic, Flat, Flat} on CPU with 1×0×0 halo
├── Periodic x  [0.0, 1.0) regularly spaced with Δx=1.0
├── Flat y
└── Flat z

julia> grid = ImmersedBoundaryGrid(grid, GridFittedBoundary(x -> true))
warning: /Users/gregorywagner/.julia/packages/KernelAbstractions/MAxUm/src/cpu.jl:118:0: loop not unrolled: the optimizer was unable to perform the requested transformation; the transformation might be disabled or specified as part of an unsupported transformation ordering
1×1×1 ImmersedBoundaryGrid{Float64, Periodic, Flat, Flat} on CPU with 1×0×0 halo:
├── immersed_boundary: GridFittedBoundary{Field{Center, Center, Center, Nothing, RectilinearGrid{Float64, Periodic, Flat, Flat, Float64, Float64, Float64, OffsetArrays.OffsetVector{Float64, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}}, Nothing, Nothing, CPU}, Tuple{Colon, Colon, Colon}, OffsetArrays.OffsetArray{Bool, 3, Array{Bool, 3}}, Bool, FieldBoundaryConditions{BoundaryCondition{Oceananigans.BoundaryConditions.Periodic, Nothing}, BoundaryCondition{Oceananigans.BoundaryConditions.Periodic, Nothing}, Nothing, Nothing, Nothing, Nothing, BoundaryCondition{Oceananigans.BoundaryConditions.Flux, Nothing}}, Nothing, Oceananigans.Fields.FieldBoundaryBuffers{Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}}}
├── underlying_grid: 1×1×1 RectilinearGrid{Float64, Periodic, Flat, Flat} on CPU with 1×0×0 halo
├── Periodic x  [0.0, 1.0) regularly spaced with Δx=1.0
├── Flat y
└── Flat z

julia> c = CenterField(grid)
1×1×1 Field{Center, Center, Center} on ImmersedBoundaryGrid on CPU
├── grid: 1×1×1 ImmersedBoundaryGrid{Float64, Periodic, Flat, Flat} on CPU with 1×0×0 halo
├── boundary conditions: FieldBoundaryConditions
│   └── west: Periodic, east: Periodic, south: Nothing, north: Nothing, bottom: Nothing, top: Nothing, immersed: ZeroFlux
└── data: 3×1×1 OffsetArray(::Array{Float64, 3}, 0:2, 1:1, 1:1) with eltype Float64 with indices 0:2×1:1×1:1
    └── max=-Inf, min=Inf, mean=NaN

julia> f(x) = not_defined
f (generic function with 1 method)

julia> set!(c, f)
ERROR: MethodError: no method matching ξname(::ImmersedBoundaryGrid{Float64, Periodic, Flat, Flat, RectilinearGrid{…}, GridFittedBoundary{…}, Nothing, Nothing, CPU})

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 a pull request may close this issue.

2 participants