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

Allow get_region(grid::UnstructuredVectorGrid, values) for a single-cell grid #144

Merged
merged 1 commit into from
Dec 5, 2024
Merged
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
9 changes: 9 additions & 0 deletions src/Grids.jl
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,12 @@ cartesian_to_internal(grid::UnstructuredVectorGrid, griddata::AbstractArray) = g
"""
get_region(grid::UnstructuredVectorGrid, values; cell) ->
values_subset, (dim_subset::NamedDimension, ...)
get_region(grid::UnstructuredVectorGrid, values)

# Keywords for region selection:
- `cell::Union{Int, Symbol}`: an Int, or a Symbol to look up in `cellnames`

`get_region(grid, values)` is also allowed for a single-cell Domain,
"""
function get_region(grid::UnstructuredVectorGrid, values; cell::Union{Int, Symbol})
if cell isa Int
Expand All @@ -295,6 +298,12 @@ function get_region(grid::UnstructuredVectorGrid, values; cell::Union{Int, Symbo
)
end

function get_region(grid::UnstructuredVectorGrid, values)
grid.ncells == 1 || throw(ArgumentError("'cell' argument is required for an UnstructuredVectorGrid with > 1 cell"))

return get_region(grid, values; cell=1)
end

"""
create_default_cellrange(domain, grid::UnstructuredVectorGrid [; operatorID=0]) -> CellRange

Expand Down
Loading