Skip to content

Commit

Permalink
Merge branch 'master' into tws
Browse files Browse the repository at this point in the history
  • Loading branch information
dalmijn authored Jan 24, 2024
2 parents a0aec18 + 5370bef commit ba7016f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
6 changes: 4 additions & 2 deletions docs/src/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
## [unreleased]

### Fixed

- Added missing BMI function `get_grid_size`, it is used for unstructured grids, for example
to get the length of arrays returned by BMI functions `get_grid_x` and `get_grid_y`.

### Changed

### Added
Expand Down
4 changes: 4 additions & 0 deletions src/bmi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,10 @@ function BMI.get_grid_node_count(model::Model, grid::Int)
return length(active_indices(model.network, grids[grid]))
end

function BMI.get_grid_size(model::Model, grid::Int)
return length(active_indices(model.network, grids[grid]))
end

function BMI.get_grid_edge_count(model::Model, grid::Int)
@unpack network = model
if grid == 4
Expand Down
4 changes: 4 additions & 0 deletions test/bmi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ tomlpath = joinpath(@__DIR__, "sbm_config.toml")
@test BMI.get_grid_node_count(model, 4) == 5809
@test BMI.get_grid_node_count(model, 5) == 50063
@test BMI.get_grid_node_count(model, 6) == 50063
@test BMI.get_grid_size(model, 1) == 2
@test BMI.get_grid_size(model, 4) == 5809
@test BMI.get_grid_size(model, 5) == 50063
@test BMI.get_grid_size(model, 6) == 50063
@test minimum(BMI.get_grid_x(model, 5, zeros(Float, 50063)))
5.426666666666667f0
@test maximum(BMI.get_grid_x(model, 5, zeros(Float, 50063)))
Expand Down

0 comments on commit ba7016f

Please sign in to comment.