Skip to content

Commit

Permalink
examples: Try reviving Bufffers after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
georgebisbas committed Jan 6, 2025
1 parent c958ddb commit fdce053
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 12 deletions.
2 changes: 1 addition & 1 deletion examples/seismic/acoustic/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def ForwardOperator(model, geometry, space_order=4,

# Create symbols for forward wavefield, source and receivers
u = TimeFunction(name='u', grid=model.grid,
save=geometry.nt if save else Buffer(3),
save=geometry.nt if save else Buffer(2),
# save=geometry.nt if save else None,
time_order=2, space_order=space_order)

Expand Down
8 changes: 5 additions & 3 deletions examples/seismic/acoustic/wavesolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,11 @@ def forward(self, src=None, rec=None, u=None, model=None, save=None, **kwargs):
# Create a new receiver object to store the result
rec = rec or self.geometry.rec

save_t = Buffer(2)

# Create the forward wavefield if not provided
u = u or TimeFunction(name='u', grid=self.model.grid,
save=self.geometry.nt if save else Buffer(3),
# save=self.geometry.nt if save else None,
save=save_t,
time_order=2, space_order=self.space_order)

model = model or self.model
Expand All @@ -114,7 +115,8 @@ def forward(self, src=None, rec=None, u=None, model=None, save=None, **kwargs):

# Execute operator and return wavefield and receiver data
summary = self.op_fwd(save).apply(src=src, rec=rec, u=u,
dt=kwargs.pop('dt', self.dt), **kwargs)
dt=kwargs.pop('dt', self.dt),
**kwargs)

print(norm(rec))
print(norm(u))
Expand Down
3 changes: 2 additions & 1 deletion examples/seismic/elastic/elastic_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ def run(shape=(50, 50), spacing=(20.0, 20.0), tn=1000.0,
info("Applying Forward")
# Define receiver geometry (spread across x, just below surface)
rec1, rec2, v, tau, summary = solver.forward(autotune=autotune)
# rec1, v, tau, summary = solver.forward(autotune=autotune)

print(norm(rec1))
print(norm(rec2))
# print(norm(rec2))
print(norm(v[0]))
print(norm(tau[0]))

Expand Down
3 changes: 2 additions & 1 deletion examples/seismic/elastic/wavesolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def forward(self, src=None, rec1=None, rec2=None, v=None, tau=None,
space_order=self.space_order, time_order=1)
tau = tau or TensorTimeFunction(name='tau', grid=self.model.grid, save=save_t,
space_order=self.space_order, time_order=1)

kwargs.update({k.name: k for k in v})
kwargs.update({k.name: k for k in tau})

Expand All @@ -97,6 +98,6 @@ def forward(self, src=None, rec1=None, rec2=None, v=None, tau=None,

# Execute operator and return wavefield and receiver data
# summary = self.op_fwd(save).apply(src=src, rec1=rec1, rec2=rec2,
summary = self.op_fwd(save).apply(src=src, rec1=rec1,
summary = self.op_fwd(save_t).apply(src=src, rec1=rec1,
dt=kwargs.pop('dt', self.dt), **kwargs)
return rec1, rec2, v, tau, summary
8 changes: 5 additions & 3 deletions examples/seismic/viscoelastic/viscoelastic_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,17 @@ def run(shape=(50, 50), spacing=(20.0, 20.0), tn=1000.0,
space_order=space_order, constant=constant, **kwargs)
info("Applying Forward")
# Define receiver geometry (spread across x, just below surface)
rec1, rec2, v, tau, summary = solver.forward(autotune=autotune)
# rec1, rec2, v, tau, summary = solver.forward(autotune=autotune)
rec1, v, tau, summary = solver.forward(autotune=autotune)

print(norm(rec1))
print(norm(rec2))
# print(norm(rec2))
print(norm(v[0]))
print(norm(tau[0]))

return (summary.gflopss, summary.oi, summary.timings,
[rec1, rec2, v, tau])
# [rec1, rec2, v, tau])
[rec1, v, tau])


@pytest.mark.parametrize("dtype", [np.float32, np.float64])
Expand Down
7 changes: 4 additions & 3 deletions examples/seismic/viscoelastic/wavesolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def forward(self, src=None, rec1=None, rec2=None, v=None, tau=None, r=None,
src = src or self.geometry.src
# Create a new receiver object to store the result
rec1 = rec1 or self.geometry.new_rec(name='rec1')
rec2 = rec2 or self.geometry.new_rec(name='rec2')
# rec2 = rec2 or self.geometry.new_rec(name='rec2')

# Create all the fields v, tau, r
# save_t = src.nt if save else None
Expand All @@ -114,6 +114,7 @@ def forward(self, src=None, rec1=None, rec2=None, v=None, tau=None, r=None,
kwargs.update(model.physical_params(**kwargs))

# Execute operator and return wavefield and receiver data
summary = self.op_fwd(save).apply(src=src, rec1=rec1, rec2=rec2,
# summary = self.op_fwd(save_t).apply(src=src, rec1=rec1, rec2=rec2,
summary = self.op_fwd(save_t).apply(src=src, rec1=rec1,
dt=kwargs.pop('dt', self.dt), **kwargs)
return rec1, rec2, v, tau, summary
return rec1, v, tau, summary

0 comments on commit fdce053

Please sign in to comment.