Add BMI 2.0 interface and Python bindings#86
Draft
HendrikKok wants to merge 11 commits into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR adds a Basic Model Interface (BMI) 2.0 implementation for Daisy,
along with Python bindings that allow Daisy to be driven from Python
using the BMI standard.
Changes
C++ BMI interface
bmi.h/bmi.C: BMI 2.0 base interfacedaisy_bmi.h/daisy_bmi.C: Daisy-specific BMI implementationwrapping the core
DaisyandColumnobjectsDaisyPythonControllerfor driving Daisy from PythonPython package (
python/)daisyPython package with BMI bindings (bmi_bindings.cpp)DaisyPyFunplugin interface into the new package1-
daisy_bmi_example.pyfor a bmi driven simulation,2- updated
daisy_py_fun_example.pyto use the new python packagepyproject.tomlBuild
CMakeLists.txtand build scripts for the new targetssample_bmi.daisample setup fileStatus
Notes
to expose via BMI is welcome.
build.bat/build_exe.batare included as a convenience for Windows buildsand will be replaced by proper README documentation in a follow-up.
BMI state access: towards a central MemoryManager
The current BMI implementation pierces the full model hierarchy
(
BMI → DaisyBMI → Daisy → Field → Column → SoilWater) with a separategetter at every layer for each variable. Every new BMI variable requires
adding that method at every level, and every read copies a
std::vector.The root cause is that
SoilWaterand other components have private variables,so every caller must go through a getter to reach them.
Proposed direction: global
MemoryManagerModels register live pointers to their internal arrays once at
initialize()time. BMI reads from the manager by name — no per-variableforwarding chain, no copies.