Qsrc array + urban drainage + drainage structure rewrite - #355
Open
maartenvanormondt wants to merge 7 commits into
Open
Qsrc array + urban drainage + drainage structure rewrite#355maartenvanormondt wants to merge 7 commits into
maartenvanormondt wants to merge 7 commits into
Conversation
Extracted from the urban_drainage branch: only the changes related to urban drainage and the cell-wise qsrc discharge accumulator. The timer rework (sfincs_timers), the sfincs_input get_keyword rewrite and the sfincs_log/startup-log rework are intentionally left out and live on separate branches. Timing uses main's tloop/system_clock style; drainage keywords are read in main's read_*_input style. New modules: sfincs_src_structures (drn TOML: pumps, culverts, check valves, gated structures with ordered operation/when rules), sfincs_rule_expression (rule bytecode engine), sfincs_urban_drainage (urb TOML: per-zone polygon drainage + outfall), sfincs_polygons. sfincs_discharges reworked to accumulate river discharges into qsrc; update_continuity orchestrates discharges, structures, infiltration (incl. new bucket model) and urban drainage. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Update the Visual Studio platform toolset in netcdff_c.vcxproj from v143 to v145 for both Debug and Release x64 configurations, aligning this third-party project with newer MSVC toolchain requirements.
There was a problem hiding this comment.
Pull request overview
This PR introduces an urban drainage feature and refactors how SFINCS handles source/sink terms by moving precipitation, infiltration, river discharges, drainage structures, and urban drainage into a unified per-cell discharge accumulator (qsrc). It also adds a rule-expression mini-language for structure control, modernizes infiltration (including a new bucket model), and updates NetCDF/text outputs and documentation accordingly.
Changes:
- Added new urban drainage model (TOML zones + polygon mapping) with logging and OpenACC/OpenMP-enabled updates.
- Refactored river discharges and drainage structures into separate modules and routed their contributions through
qsrc, aligning continuity and meteo/infiltration updates. - Updated NetCDF/his output and documentation to cover new inputs/outputs (urban drainage, river discharge storage, NetCDF infiltration, bucket model).
Reviewed changes
Copilot reviewed 24 out of 25 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| source/third_party_open/netcdf/netcdf-fortran-4.6.1/netcdff_c.vcxproj | Updates MSVC platform toolset version for the bundled NetCDF-Fortran build. |
| source/src/utils/sfincs_polygons.f90 | Adds polygon reading + point-in-polygon utilities for zone stamping (used by urban drainage). |
| source/src/sfincs_urban_drainage.f90 | Implements the urban drainage zone model (piped drainage + injection wells). |
| source/src/sfincs_rule_expression.f90 | Adds a compiled rule-expression language for structure open/close logic. |
| source/src/sfincs_output.f90 | Updates text output logic to reflect refactored discharge/structure handling. |
| source/src/sfincs_openacc.f90 | Extends OpenACC data regions to include new discharge/structure/urban-drainage arrays. |
| source/src/sfincs_ncoutput.F90 | Extends NetCDF his/map output for refactored drainage structures, river discharges, and urban drainage. |
| source/src/sfincs_ncinput.F90 | Updates FEWS-style discharge netCDF reader API to avoid circular dependencies. |
| source/src/sfincs_meteo.f90 | Routes precipitation contribution into qsrc and removes reliance on netprcp. |
| source/src/sfincs_log.f90 | Adds fmt_real helper for consistent minimal-width real formatting in logs. |
| source/src/sfincs_lib.f90 | Reorders initialization/update sequence to use new initialize/update entry points and update_continuity. |
| source/src/sfincs_input.f90 | Adds new keywords (e.g., urbfile, store_river_discharge, urban drainage flags) and updates bathtub mode disabling. |
| source/src/sfincs_infiltration.f90 | Adds bucket model, shifts infiltration effects into qsrc, and modernizes NetCDF infiltration support. |
| source/src/sfincs_domain.f90 | Moves/updates initialization responsibilities and allocates qsrc at hydro init. |
| source/src/sfincs_discharges.f90 | Refactors river discharges into a dedicated module that interpolates and accumulates into qsrc. |
| source/src/sfincs_data.f90 | Updates shared state: introduces qsrc, new flags, and bucket-model arrays; removes legacy discharge/drainage arrays. |
| source/src/Makefile.am | Adds new Fortran sources (rule expressions, src structures, polygons, urban drainage) and TOML serializer. |
| source/sfincs_lib/sfincs_lib.vfproj | Updates Visual Fortran project file to include new sources and TOML-F files. |
| docs/parameters.rst | Documents new parameters for urban drainage and modernized infiltration/drainage inputs. |
| docs/input.rst | Updates infiltration and drainage documentation to prefer NetCDF inputs and documents bucket model + drainage mimic changes. |
| docs/input_urban_drainage.rst | Adds comprehensive urban drainage user guide (schema, formulas, inputs/outputs). |
| docs/input_structures.rst | Rewrites drainage-structure documentation and introduces rule language docs and TOML-based structure inputs. |
| docs/index.rst | Adds the new urban drainage page to the documentation index. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Adds new NetCDF output fields and metadata for bucket infiltration capacity, cumulative urban drainage depth, river discharge, and urban drainage zone discharge. History output now includes drainage names, gate open fraction, and breach width for dike-breach structures, with coordinate attributes for new series. The update also tightens write logic by guarding optional arrays before writing and aligns his-file close conditions with init-time creation rules so files are only accessed when they were actually created.
Deletes the `toml-f` filter and its file list from `source/sfincs_lib/sfincs_lib.vfproj`, so the Visual Fortran project no longer references those third-party TOML sources.
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.
This pull request significantly updates the SFINCS documentation to introduce and explain the new urban drainage feature, modernizes infiltration and drainage input methods, and clarifies recommended practices for input files. The changes add a comprehensive user guide for urban drainage, update infiltration method documentation to prefer NetCDF-based inputs, deprecate legacy binary input keywords, and introduce new parameters for urban drainage output.
Urban drainage feature:
docs/input_urban_drainage.rstdetailing the urban drainage model, including configuration, input file formats, parameter descriptions, and output variables. This includes both piped drainage and injection well abstractions, with TOML-based configuration and polygon zone assignment.docs/index.rst) to include the newinput_urban_drainagedocumentation section.Infiltration and drainage input modernization:
docs/input.rstto recommend NetCDF-basedinfiltrationfileandinfiltrationtypefor all modern infiltration and bucket model inputs, with detailed variable requirements for each method. Legacy binary keywords (e.g.,qinffile,scsfile,bucketfile, etc.) are now marked as deprecated and for backward compatibility only. [1] [2] [3] [4] [5] [6] [7]infiltrationfile, and the legacybucketfileandbucket_loss_fracinputs are no longer supported; for drainage, only thedrainagefileinput is now supported.Parameter documentation:
store_urban_drainage_dischargeandstore_cumulative_urban_drainage, todocs/parameters.rst, describing their purpose and usage for urban drainage output.General documentation improvements:
docs/input.rstto reflect the new recommended practices and to organize information more clearly.