Skip to content

Commit 3c2218a

Browse files
committed
Revert examples/seismic/model.py to use legacy SubDomain API
The new SubDomain API (passing grid= to SubDomain constructor) breaks Dask pickling/unpickling, causing AttributeError when Grid is deserialized. Reverting to the legacy API (passing subdomains= to Grid constructor) which works correctly with Dask, even though it triggers a deprecation warning. This is acceptable until the new API is fixed to work with Dask.
1 parent bc45ed6 commit 3c2218a

1 file changed

Lines changed: 9 additions & 18 deletions

File tree

examples/seismic/model.py

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ class PhysicalDomain(SubDomain):
5959

6060
name = 'physdomain'
6161

62-
def __init__(self, so, fs=False, **kwargs):
62+
def __init__(self, so, fs=False):
63+
super().__init__()
6364
self.so = so
6465
self.fs = fs
65-
super().__init__(**kwargs)
6666

6767
def define(self, dimensions):
6868
map_d = {d: d for d in dimensions}
@@ -75,9 +75,9 @@ class FSDomain(SubDomain):
7575

7676
name = 'fsdomain'
7777

78-
def __init__(self, so, **kwargs):
78+
def __init__(self, so):
79+
super().__init__()
7980
self.size = so
80-
super().__init__(**kwargs)
8181

8282
def define(self, dimensions):
8383
"""
@@ -105,7 +105,11 @@ def __init__(self, origin, spacing, shape, space_order, nbl=20,
105105
shape_pml = np.array(shape) + 2 * self.nbl
106106

107107
# Model size depending on freesurface
108+
physdomain = PhysicalDomain(space_order, fs=fs)
109+
subdomains = subdomains + (physdomain,)
108110
if fs:
111+
fsdomain = FSDomain(space_order)
112+
subdomains = subdomains + (fsdomain,)
109113
origin_pml[-1] = origin[-1]
110114
shape_pml[-1] -= self.nbl
111115

@@ -115,23 +119,10 @@ def __init__(self, origin, spacing, shape, space_order, nbl=20,
115119
# Physical extent is calculated per cell, so shape - 1
116120
extent = tuple(np.array(spacing) * (shape_pml - 1))
117121
self.grid = Grid(extent=extent, shape=shape_pml, origin=origin_pml,
118-
dtype=dtype, topology=topology)
122+
dtype=dtype, subdomains=subdomains, topology=topology)
119123
else:
120124
self.grid = grid
121125

122-
# Create subdomains with grid parameter (new pattern)
123-
physdomain = PhysicalDomain(space_order, fs=fs, grid=self.grid)
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-
130-
if fs:
131-
fsdomain = FSDomain(space_order, grid=self.grid)
132-
# Register fsdomain
133-
self.grid._subdomains = self.grid._subdomains + (fsdomain,)
134-
135126
self._physical_parameters = set()
136127
self.damp = None
137128
self._initialize_bcs(bcs=bcs)

0 commit comments

Comments
 (0)