Skip to content

Commit bc45ed6

Browse files
committed
fix: Don't modify user-provided subdomains
Avoid modifying user-provided subdomain objects which breaks Dask pickling/unpickling. Just register them with the grid without changing their internal state.
1 parent 5bfe44b commit bc45ed6

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

examples/seismic/model.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -121,17 +121,16 @@ def __init__(self, origin, spacing, shape, space_order, nbl=20,
121121

122122
# Create subdomains with grid parameter (new pattern)
123123
physdomain = PhysicalDomain(space_order, fs=fs, grid=self.grid)
124-
new_subdomains = [physdomain]
125-
for sd in subdomains:
126-
# Update grid for any user-provided subdomains
127-
sd.grid = self.grid
128-
new_subdomains.append(sd)
124+
# Register physdomain
125+
self.grid._subdomains = self.grid._subdomains + (physdomain,)
126+
127+
# Register user-provided subdomains
128+
self.grid._subdomains = self.grid._subdomains + subdomains
129+
129130
if fs:
130131
fsdomain = FSDomain(space_order, grid=self.grid)
131-
new_subdomains.append(fsdomain)
132-
133-
# Manually update grid's _subdomains to include new subdomains
134-
self.grid._subdomains = self.grid._subdomains + tuple(new_subdomains)
132+
# Register fsdomain
133+
self.grid._subdomains = self.grid._subdomains + (fsdomain,)
135134

136135
self._physical_parameters = set()
137136
self.damp = None

0 commit comments

Comments
 (0)