Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 30 additions & 16 deletions docs/dev/protocols-plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,25 +127,39 @@ For development/testing, provide an optional validation function:
- Caching tests
- All tests passing

### Phase 3: Not Started

**Integrate with _resolve_dimensions** - NOT DONE
- Update _resolve_dimensions() in structure.py:
- Try parent.get_all_dimensions() FIRST (new path)
- Fall back to xattree's parent.data.dims (compatibility)
- Keep computed dimension fallback (temporary)
- All tests pass using both new and fallback paths
- Tests: All existing tests pass (proving coexistence works)

NOTE: structure.py has been created but still uses old xattree path (parent.data.dims)

**Validation** - NOT DONE
- Add conflict detection in get_all_dimensions()
- Add optional validate_dimension_resolution() tool
### Phase 3: Complete ✅

**Integrate with _resolve_dimensions** - DONE ✅
- Updated _resolve_dimensions() in structure.py:
- Uses parent.resolve_dims() (new path)
- Removed xattree fallback - cleaner, simpler code
- Updated resolve_dims() to include parent dimensions (walks up hierarchy)
- Tests: All 207 non-integration tests pass

**Validation** - DONE ✅
- Added conflict detection in resolve_dims()
- Detects conflicts among children at same level
- Allows children to override parent dimensions
- Added validate_dimension_resolution() validation tool in dimensions.py

**Implement Disv DimensionProvider** - DONE ✅
- Added get_dims() to Disv class
- Returns nlay, ncpl, nvert, and computed nodes dimension
- All Disv-related tests now pass

**API Refinements** - DONE ✅
- Renamed: DimensionRegistry → DimensionResolver
- Renamed: DimensionRegistryMixin → DimensionResolverMixin
- Renamed: get_dimensions() → get_dims()
- Unified API: resolve_dimension() + get_all_dimensions() → resolve_dims()
- resolve_dims() always returns dict for consistency:
- `resolve_dims()` → all available dimensions
- `resolve_dims('nlay')` → `{'nlay': 3}`
- `resolve_dims('nlay', 'nrow')` → `{'nlay': 3, 'nrow': 10}`

**ParentSettingDict** - NOT DONE
- Not yet implemented
- Planned for Phase 3 (parent management migration)
- Deferred to Phase 4 (parent management migration)

### Phase 4: Future Work

Expand Down
4 changes: 2 additions & 2 deletions flopy4/mf6/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from xattree import xattree

from flopy4.mf6.constants import MF6
from flopy4.mf6.dimensions import DimensionRegistryMixin
from flopy4.mf6.dimensions import DimensionResolverMixin
from flopy4.mf6.spec import field, fields_dict
from flopy4.mf6.utils.grid import update_maxbound
from flopy4.mf6.write_context import WriteContext
Expand All @@ -22,7 +22,7 @@
# kw_only=True necessary so we can define optional fields here
# and required fields in subclasses. attrs complains otherwise
@xattree(kw_only=True)
class Component(DimensionRegistryMixin, ABC, MutableMapping):
class Component(DimensionResolverMixin, ABC, MutableMapping):
"""
Base class for MF6 components.

Expand Down
6 changes: 5 additions & 1 deletion flopy4/mf6/converter/ingress/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from flopy4.adapters import get_nn
from flopy4.mf6.config import SPARSE_THRESHOLD
from flopy4.mf6.constants import FILL_DNODATA
from flopy4.mf6.dimensions import DimensionResolver


def structure_keyword(value, field) -> str | None:
Expand Down Expand Up @@ -48,7 +49,10 @@ def _resolve_dimensions(

# Resolve dims from model context
# Priority: 1) explicit dims parameter, 2) self_.__dict__, 3) parent
inherited_dims = dict(self_.parent.data.dims) if self_.parent else {}
inherited_dims = {}
if self_.parent and isinstance(self_.parent, DimensionResolver):
inherited_dims = self_.parent.resolve_dims()

explicit_dims = self_.__dict__.get("dims", {})
dim_dict = inherited_dims | explicit_dims

Expand Down
Loading
Loading