NOAA-OWP / ngen

Next Generation Water Modeling Engine and Framework Prototype
Other
84 stars 62 forks source link

Forcings Engine Data Provider Base Interface #839

Closed program-- closed 3 months ago

program-- commented 3 months ago

[!IMPORTANT] This PR replaces #720.

This PR adds the ForcingsEngineDataProvider<DataType, SelectionType> class. This class is intended to serve as the base class for Lumped, Gridded, and Unstructured forcings engine data providers. The base class handles timing and updating the underlying BMI instance, so derived classes need only implement the value querying requirements.

Internally, this PR also adds the detail::ForcingsEngineStorage class, which composes a map of initialization file names to Python BMI Adapter shared pointers. The design of this is to allow the Forcings Engine data providers to store a mask of some sort to simplify querying from the forcings engine, i.e. for a Gridded instance, the mask may be a bounding box. This need is due to the implementation of the forcings engine, and should simplify the external requirements for a NGen run using the Python Forcings Engine.

Additionally, this PR includes some minor changes to the forcings library. Namely, the GenericDataProvider class is refactored into a type alias, and the NullForcingProvider implementation is split into header/source files rather than being header-only. The latter change is to ensure the forcings CMake target is always build-able.

Additions

Changes

Checklist

PhilMiller commented 3 months ago

The shadowed variable bmi_ is a substantial concern. The other comments are inconsequential.

PhilMiller commented 3 months ago

The main header here can only be included with NGEN_WITH_PYTHON enabled, but I'm not sure that's actually something we need to guard against in the header itself. Implementations and clients are going to need to guard against it anyway. I guess it would save clients conditionalizing both the #include and the usage site.