Skip to content

Commit 82300d4

Browse files
committed
examples: Update DRP notebook
1 parent 56873be commit 82300d4

4 files changed

Lines changed: 14 additions & 13 deletions

File tree

devito/data/decomposition.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,12 +214,13 @@ def index_glb_to_loc(self, *args, rel=True):
214214
if not self.loc_empty:
215215
loc_abs_min = self.loc_abs_min - self.glb_min
216216
loc_abs_max = self.loc_abs_max - self.glb_min
217+
glb_max = self.glb_max - self.glb_min
217218
else:
218219
loc_abs_min = self.loc_abs_min
219220
loc_abs_max = self.loc_abs_max
221+
glb_max = self.glb_max
220222

221223
glb_min = 0
222-
glb_max = self.glb_max - self.glb_min
223224

224225
base = loc_abs_min if rel else 0
225226
top = loc_abs_max

devito/operations/interpolators.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,8 @@ def _interp_idx(self, variables, implicit_dims=None, pos_only=(), subdomain=None
294294
mapper = self._rdim(subdomain=subdomain).getters
295295

296296
# Index substitution to make in variables
297-
subs = {k: c + p for ((k, c), p) in zip(mapper.items(), pos)}
298-
subs.update({k.root: c + p for ((k, c), p) in zip(mapper.items(), pos)})
297+
subs = {ki: c + p for ((k, c), p)
298+
in zip(mapper.items(), pos) for ki in {k, k.root}}
299299

300300
idx_subs = {v: v.subs(subs) for v in variables}
301301

devito/types/basic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1477,7 +1477,7 @@ def _offset_subdomain(self):
14771477
offsets.append(l_tkn)
14781478
else:
14791479
offsets.append(0)
1480-
return DimensionTuple(offsets, getters=self.dimensions)
1480+
return DimensionTuple(*offsets, getters=self.dimensions)
14811481

14821482
@property
14831483
def _data_alignment(self):

examples/seismic/tutorials/07_DRP_schemes.ipynb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -396,18 +396,14 @@
396396
" x, z = dimensions\n",
397397
" # We want our lower layer to span the entire x-dimension and all\n",
398398
" # but the top 121 (+boundary layer) cells in the z-direction.\n",
399-
" return {x: x, z: ('right', 121+nbl)}\n",
400-
"\n",
401-
"# Create these subdomains:\n",
402-
"ur = Upper()\n",
403-
"lr = Lower()"
399+
" return {x: x, z: ('right', 121+nbl)}"
404400
]
405401
},
406402
{
407403
"cell_type": "markdown",
408404
"metadata": {},
409405
"source": [
410-
"We now create our model incoporating these subdomains:"
406+
"We now create our `Model` and attach these `SubDomain`s:"
411407
]
412408
},
413409
{
@@ -432,7 +428,11 @@
432428
"\n",
433429
"# Create our model passing it our 'upper' and 'lower' subdomains: \n",
434430
"model = Model(vp=v, origin=origin, shape=shape, spacing=spacing,\n",
435-
" space_order=order, nbl=nbl, subdomains=(ur,lr), bcs=\"damp\")"
431+
" space_order=order, nbl=nbl, bcs=\"damp\")\n",
432+
"\n",
433+
"# Create these subdomains:\n",
434+
"ur = Upper(grid=model.grid)\n",
435+
"lr = Lower(grid=model.grid)"
436436
]
437437
},
438438
{
@@ -504,9 +504,9 @@
504504
"\n",
505505
"# Create a stencil for each subdomain:\n",
506506
"stencil_u = Eq(u_DRP.forward, solve(pde_DRP, u_DRP.forward).subs({H: u_lap}),\n",
507-
" subdomain = model.grid.subdomains['upper'])\n",
507+
" subdomain=ur)\n",
508508
"stencil_l = Eq(u_DRP.forward, solve(pde_DRP, u_DRP.forward).subs({H: l_lap}),\n",
509-
" subdomain = model.grid.subdomains['lower'])\n",
509+
" subdomain=lr)\n",
510510
"\n",
511511
"# Source term:\n",
512512
"src_term = src.inject(field=u_DRP.forward, expr=src * dt**2 / model.m)\n",

0 commit comments

Comments
 (0)