Skip to content

refactor(dfns): introduce cell ID type - #394

Merged
wpbonelli merged 1 commit into
MODFLOW-ORG:developfrom
wpbonelli:cellid-element-type
Oct 15, 2026
Merged

wpbonelli merged 1 commit into
MODFLOW-ORG:developfrom
wpbonelli:cellid-element-type

Conversation

@wpbonelli

Copy link
Copy Markdown
Member
  • make CellID a first class field type instead of an ncelldim integer array
  • model ("1"/"2"/None) attribute to replace cellid=True/"1"/"2" attribute
  • allow_zero attribute for e.g. SFR packagedata cellid and GNC cellidsj

Before:

cellid:   Array(dtype="integer", shape=["ncelldim"], index=True, cellid=True)
cellidsj: Array(dtype="integer", shape=["ncelldim", "numalphaj"], index=True, cellid="1")

After:

cellid:   CellID()
cellidsj: Array(dtype="cellid", shape=["numalphaj"], model="1", allow_zero=True)

A cellid was an integer array whose first axis was `ncelldim`, its
components, with any further axes counting cellids. That put a property of
the elements into the array's shape: consumers had to strip `ncelldim` to
find what counts the values, and to special-case a single cellid, which
has no counting axis and so looked self-sizing.

Now a single cellid is a scalar `CellID` field (type "cellid"), and several
are an `Array` with dtype "cellid", shaped only by what counts them (GNC's
`cellidsj` is `["numalphaj"]`). `ncelldim` leaves every shape: a cellid's
width is its grid's. Which grid is `model` ("1"/"2", or None for the
component's own), replacing `cellid=True/"1"/"2"`. A cellid is always
1-based, so it has no `index`. A cellid array rejects `index`, `fk`,
`time_series`, `layered` and `netcdf`, and `model`/`allow_zero` are
rejected on any other dtype.

New `allow_zero`: the cellid may refer to no cell, given as zeros. MF6
allows it for SFR packagedata `cellid` (an unconnected reach) and GNC
`cellidsj` (a dummy contributing cell); the migration sets it from an
audited allowlist, since v1 says so only in prose.

Rendered DFN text is unchanged (`<cellid(ncelldim)>`,
`<cellidsj(ncelldim, numalphaj)>`); checked for all 146 components. The
dev3 schema changes in place, as for MODFLOW-ORG#385.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@wpbonelli wpbonelli added this to the 1.10.0 milestone Oct 15, 2026
@wpbonelli
wpbonelli marked this pull request as ready for review October 15, 2026 00:29
@wpbonelli
wpbonelli merged commit 873c5ca into MODFLOW-ORG:develop Oct 15, 2026
15 checks passed
@wpbonelli
wpbonelli deleted the cellid-element-type branch October 15, 2026 00:33
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.

1 participant