-
Notifications
You must be signed in to change notification settings - Fork 195
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
Invoke mask_immersed_field!
when converting args for Makie
#3725
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
only minor thing is that we need to call mask_immersed_field!(f, NaN)
in three different places... bit trickier to modify if needed.
we could be calling it within flattened_cpu_interior
but the method name doesn't suggest that... if you think of a way to improve do it!
mask_immersed_field!
when converting args for Makie
Good idea. Find a new name for the function! What it does:
Perhaps simple |
I'm tempted to merge this. But I don't understand why the code snippet below is not working: Look: using Oceananigans, CairoMakie
underlying_grid = RectilinearGrid(size = (250, 125),
x = (-1000e3, 1000e3),
z = (-2e3, 0),
halo = (4, 4),
topology = (Periodic, Flat, Bounded))
bottom(x) = - underlying_grid.Lz + 500 * exp(-x^2 / (2*(20e3)^2))
grid = ImmersedBoundaryGrid(underlying_grid, GridFittedBottom(bottom))
lines(grid.immersed_boundary.bottom_height) gives: which is all good! But: x, y, z = nodes(grid.immersed_boundary.bottom_height)
lines(x, grid.immersed_boundary.bottom_height) Perhaps this is a bit informative lines(x/1e3, grid.immersed_boundary.bottom_height) |
Hm... julia> using Oceananigans, CairoMakie
julia> underlying_grid = RectilinearGrid(size = (250, 125),
x = (-1000e3, 1000e3),
z = (-2e3, 0),
halo = (4, 4),
topology = (Periodic, Flat, Bounded));
julia> bottom(x) = - underlying_grid.Lz + 500 * exp(-x^2 / (2*(20e3)^2));
julia> grid = ImmersedBoundaryGrid(underlying_grid, GridFittedBottom(bottom));
julia> c = Field{Center, Nothing, Nothing}(grid)
250×1×1 Field{Center, Nothing, Nothing} reduced over dims = (2, 3) on ImmersedBoundaryGrid on CPU
├── grid: 250×1×125 ImmersedBoundaryGrid{Float64, Periodic, Flat, Bounded} on CPU with 4×0×4 halo
├── boundary conditions: FieldBoundaryConditions
│ └── west: Periodic, east: Periodic, south: Nothing, north: Nothing, bottom: Nothing, top: Nothing, immersed: ZeroFlux
└── data: 258×1×1 OffsetArray(::Array{Float64, 3}, -3:254, 1:1, 1:1) with eltype Float64 with indices -3:254×1:1×1:1
└── max=0.0, min=0.0, mean=0.0
julia> set!(c, rand())
250×1×1 Field{Center, Nothing, Nothing} reduced over dims = (2, 3) on ImmersedBoundaryGrid on CPU
├── grid: 250×1×125 ImmersedBoundaryGrid{Float64, Periodic, Flat, Bounded} on CPU with 4×0×4 halo
├── boundary conditions: FieldBoundaryConditions
│ └── west: Periodic, east: Periodic, south: Nothing, north: Nothing, bottom: Nothing, top: Nothing, immersed: ZeroFlux
└── data: 258×1×1 OffsetArray(::Array{Float64, 3}, -3:254, 1:1, 1:1) with eltype Float64 with indices -3:254×1:1×1:1
└── max=0.952381, min=0.952381, mean=0.952381
julia> lines(c)
julia> c
250×1×1 Field{Center, Nothing, Nothing} reduced over dims = (2, 3) on ImmersedBoundaryGrid on CPU
├── grid: 250×1×125 ImmersedBoundaryGrid{Float64, Periodic, Flat, Bounded} on CPU with 4×0×4 halo
├── boundary conditions: FieldBoundaryConditions
│ └── west: Periodic, east: Periodic, south: Nothing, north: Nothing, bottom: Nothing, top: Nothing, immersed: ZeroFlux
└── data: 258×1×1 OffsetArray(::Array{Float64, 3}, -3:254, 1:1, 1:1) with eltype Float64 with indices -3:254×1:1×1:1
└── max=NaN, min=NaN, mean=NaN After plotting a field then it has NaNs. Is this OK? |
Yes, that's a bug. Hopefully @simone-silvestri can help who designed the conditional reductions |
Can you check whether this behavior is actually changed by this PR? It seems like maybe this would have happened before this PR anyways. |
Co-authored-by: Gregory L. Wagner <wagner.greg@gmail.com>
Co-authored-by: Gregory L. Wagner <wagner.greg@gmail.com>
Co-authored-by: Gregory L. Wagner <wagner.greg@gmail.com>
Captures the masking of immersed cells for visualization in #3725.
* Bump patch release Captures the masking of immersed cells for visualization in #3725. * enable doc previews Now there is a [GitHub action](https://github.com/CliMA/OceananigansDocumentation/blob/master/.github/workflows/DocPreviewsCleanup.yml) that automatically clears up the previews directory once a week! * update comment
@navidcy I think you can use this in the internal tide example?