Skip to content

Commit

Permalink
Merge pull request #287 from opesci/con_ex
Browse files Browse the repository at this point in the history
Update example to a smoother version
  • Loading branch information
Michael Lange authored Jul 5, 2017
2 parents 571bce0 + bfa1bd0 commit ea614e0
Show file tree
Hide file tree
Showing 4 changed files with 570 additions and 49 deletions.
3 changes: 3 additions & 0 deletions docs/tutorials.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ Devito rather than pure CFD or finite difference theory.
* `01 - Linear convection
<http://nbviewer.jupyter.org/github/opesci/devito/blob/master/examples/cfd/test_01_convection.ipynb>`_
- Building a linear operator with simple zero BCs.
* `01b - Linear convection, revisisted
<http://nbviewer.jupyter.org/github/opesci/devito/blob/master/examples/cfd/test_01_convection_revisited.ipynb>`_
- The above example, with a different initial condition.
* `02 - Nonlinear convection
<http://nbviewer.jupyter.org/github/opesci/devito/blob/master/examples/cfd/test_02_convection_nonlinear.ipynb>`_
- Building an operator with coupled equations and simple BCs.
Expand Down
107 changes: 58 additions & 49 deletions examples/cfd/test_01_convection.ipynb

Large diffs are not rendered by default.

489 changes: 489 additions & 0 deletions examples/cfd/test_01_convection_revisited.ipynb

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions examples/cfd/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,23 @@ def init_hat(field, dx, dy, value=2., bgvalue=1.):
"""
field[:] = bgvalue
field[int(.5 / dx):int(1 / dx + 1), int(.5 / dy):int(1 / dy + 1)] = value


def gaussian(x, mu, sig):
return np.exp(-np.power(x - mu, 2.) / (2 * np.power(sig, 2.)))


def fin_bump(x):
if x <= 0 or x >= 1:
return 0
else:
return 100*np.exp(-1./(x-np.power(x, 2.)))


def init_smooth(field, dx, dy):
nx, ny = field.shape
for ix in range(nx):
for iy in range(ny):
x = ix * dx
y = iy * dy
field[ix, iy] = fin_bump(x/1.5) * fin_bump(y/1.5) + 1.

0 comments on commit ea614e0

Please sign in to comment.