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

BMI: bug fixes and updates #306

Merged
merged 22 commits into from
Nov 21, 2023
Merged

BMI: bug fixes and updates #306

merged 22 commits into from
Nov 21, 2023

Conversation

verseve
Copy link
Contributor

@verseve verseve commented Oct 23, 2023

Issue addressed

Fixes #304, #307

Explanation

Issue #304:
Fixed Basic Model Interface (BMI) functions that deviated from BMI specifications (BasicModelInterface.jl). Model variables that represent 3-dimensional data (stored as 2d Arrays or Vector of SVectors) are exposed as 2-dimensional unstructured grids. This minimizes the number of required grid types and users are most probably interested in data per third grid coordinate (for example per soil layer). BMI grid information (type and location) and whether a model variable can be exchanged is now stored as part of Struct metadata. For Wflow components that store model variables on grid edges the BMI model grid functions have been extended with get_grid_edge_count and get_grid_edge_nodes.

Issue #307:
config.starttime and config.endtime can also be provided as Strings in the TOML file, so conversion to DateTime is also required in BMI functions where these variables are used.

Checklist

  • Updated tests or added new tests
  • Branch is up to date with master
  • Tests & pre-commit hooks pass
  • Updated documentation if needed
  • Updated changelog.md if needed

Additional Notes

A total of 7 different grid types are required and from a user perspective fewer grid types would be better. To support fewer grid types, changes at the Wflow Model level are required (see also #304 (comment)). This can be part of another PR.

Also added state and time functions (extension of BMI) that can be used for coupling with OpenDA (and other external) software.

Both were missing the required `dest` argument.
Should return the datatype of a variable (with `eltype`) and not the type of a complete Array (`typeof`).
- fix functions that deviate from BasicModelInterface.jl (e.g. get_grid_x).
- add metadata to Structs, for example grid location (node or edge), that can be used by BMI (and Wflow).
SVector type and 2D Array variables are exposed per third dimension coordinate, by adding "-i" (i refers to index) to the variable name (to minimize the number of required grid types). Extracting index i from the variable name has been fixed.
This is done for boundary/ghost nodes.
For SVector type and 2D Array variables use "[ì]" instead of "-i"
Replace getindex (values are retrieved from the array (copy)), with reinterpret (a copy is not created).
@verseve verseve added the bug Something isn't working label Oct 23, 2023
@verseve verseve requested a review from dalmijn October 23, 2023 09:45
@verseve verseve self-assigned this Oct 23, 2023
@verseve verseve marked this pull request as draft October 24, 2023 10:44
For model coupling (OpenDA) additonal functions for loading and saving state information and start time in Unix time format are required. For this, the set states functionality from the initialization function is moved to a separate `set_states` function for each Model type.
@verseve verseve marked this pull request as ready for review October 25, 2023 08:51
config.startime and config.endtime should be converted to `DateTime`, because Wflow accepts also Strings here (TOML).
@verseve verseve linked an issue Oct 25, 2023 that may be closed by this pull request
2 tasks
@verseve verseve requested a review from visr November 8, 2023 09:13
Copy link
Member

@visr visr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments, but overall this looks good to me!

src/reservoir_lake.jl Outdated Show resolved Hide resolved
src/bmi.jl Outdated Show resolved Hide resolved
src/bmi.jl Show resolved Hide resolved
src/bmi.jl Outdated Show resolved Hide resolved
@verseve verseve merged commit 65e2b09 into master Nov 21, 2023
10 of 12 checks passed
@verseve verseve deleted the BMI branch December 7, 2023 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bmi.get_current_time and bmi.get_end_time are broken. BMI get_value and grid type
3 participants