Skip to content

Qsrc array + urban drainage + drainage structure rewrite - #355

Open
maartenvanormondt wants to merge 7 commits into
mainfrom
qsrc
Open

Qsrc array + urban drainage + drainage structure rewrite#355
maartenvanormondt wants to merge 7 commits into
mainfrom
qsrc

Conversation

@maartenvanormondt

Copy link
Copy Markdown
Contributor

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:

  • Added a new documentation page docs/input_urban_drainage.rst detailing 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.
  • Updated the main documentation index (docs/index.rst) to include the new input_urban_drainage documentation section.

Infiltration and drainage input modernization:

  • Updated docs/input.rst to recommend NetCDF-based infiltrationfile and infiltrationtype for 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]
  • Added dedicated sections for the bucket model and drainage mimic, clarifying their configuration and input requirements. The bucket model now requires all variables to be present in infiltrationfile, and the legacy bucketfile and bucket_loss_frac inputs are no longer supported; for drainage, only the drainagefile input is now supported.

Parameter documentation:

  • Added two new parameters, store_urban_drainage_discharge and store_cumulative_urban_drainage, to docs/parameters.rst, describing their purpose and usage for urban drainage output.

General documentation improvements:

  • Updated section headings and improved clarity in docs/input.rst to reflect the new recommended practices and to organize information more clearly.

maartenvanormondt and others added 3 commits July 13, 2026 15:39
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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread source/src/utils/sfincs_polygons.f90
Comment thread docs/input_structures.rst Outdated
Comment thread source/src/sfincs_ncoutput.F90 Outdated
Comment thread source/src/sfincs_ncoutput.F90 Outdated
maartenvanormondt and others added 4 commits July 13, 2026 22:25
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.
@maartenvanormondt
maartenvanormondt requested a review from Leynse July 13, 2026 20:45
@Leynse Leynse added this to the v2.4.1 milestone Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants