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

Define cartesian_size for all grids #127

Merged
merged 1 commit into from
Jun 13, 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
12 changes: 12 additions & 0 deletions src/Grids.jl
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ PB.internal_size(space::Type{PB.ScalarSpace}, grid::Union{PB.AbstractMesh, Nothi
# allow Vector variables length 1 in a 0D Domain without a grid
PB.internal_size(space::Type{PB.CellSpace}, grid::Nothing) = (1, )

# allow single dimension
PB.cartesian_size(grid::Nothing) = (1, )
cartesian_to_internal(grid::Nothing, griddata::AbstractArray) = griddata

get_subdomain(grid::Nothing, subdomainname::AbstractString) = error("get_subdomain: no subdomain $subdomainname")

"""
Expand Down Expand Up @@ -265,6 +269,10 @@ end

PB.internal_size(space::Type{PB.CellSpace}, grid::UnstructuredVectorGrid) = (grid.ncells, )

# single dimension
PB.cartesian_size(grid::UnstructuredVectorGrid) = (grid.ncells, )
cartesian_to_internal(grid::UnstructuredVectorGrid, griddata::AbstractArray) = griddata

"""
get_region(grid::UnstructuredVectorGrid, values; cell) ->
values_subset, (dim_subset::NamedDimension, ...)
Expand Down Expand Up @@ -333,6 +341,10 @@ end
PB.internal_size(space::Type{PB.CellSpace}, grid::UnstructuredColumnGrid) = (grid.ncells, )
PB.internal_size(space::Type{PB.ColumnSpace}, grid::UnstructuredColumnGrid) = (length(grid.Icolumns), )

# single dimension
PB.cartesian_size(grid::UnstructuredColumnGrid) = (grid.ncells, )
cartesian_to_internal(grid::UnstructuredColumnGrid, griddata::AbstractArray) = griddata

"""
get_region(grid::UnstructuredColumnGrid, values; column, [cell=nothing]) ->
values_subset, (dim_subset::NamedDimension, ...)
Expand Down
2 changes: 1 addition & 1 deletion src/VariableReaction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ get_variables(vl::VarList_tuple; flatten=true) = filter(!isnothing, vl.vars)
create_accessors(vl::VarList_tuple, modeldata::AbstractModelData, arrays_idx::Int) =
Tuple(isnothing(v) ? nothing : create_accessor(v, modeldata, arrays_idx, vl.components) for v in vl.vars)

VarList_tuple_nothing(nvec) = VarList_tuple(fill(nothing, nvec))
Base.@deprecate VarList_tuple_nothing(nvec) VarList_tuple(fill(nothing, nvec))

"""
VarList_ttuple(varcollection) -> VarList_ttuple
Expand Down
Loading