Skip to content

Commit

Permalink
Merge pull request #144 from PALEOtoolkit/get_region_cell
Browse files Browse the repository at this point in the history
Allow get_region(grid::UnstructuredVectorGrid, values) for a single-cell grid
  • Loading branch information
sjdaines authored Dec 5, 2024
2 parents c17db77 + 4c4d479 commit 0d5ef01
Showing 1 changed file with 9 additions and 0 deletions.
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

0 comments on commit 0d5ef01

Please sign in to comment.