|
| 1 | +"""Quick setup of common domains.""" |
| 2 | + |
| 3 | + |
| 4 | +import numpy as np |
| 5 | +import dedalus.public as d3 |
| 6 | + |
| 7 | + |
| 8 | +def fourier(N, dealias=3/2, dtype=np.float64): |
| 9 | + coord = d3.Coordinate('x') |
| 10 | + dist = d3.Distributor(coord, dtype=dtype) |
| 11 | + xbasis = d3.Fourier(coord, size=N, bounds=(0, 2*np.pi), dealias=dealias, dtype=dtype) |
| 12 | + return coord, dist, xbasis |
| 13 | + |
| 14 | + |
| 15 | +def chebyshev(N, dealias=3/2, dtype=np.float64): |
| 16 | + coord = d3.Coordinate('x') |
| 17 | + dist = d3.Distributor(coord, dtype=dtype) |
| 18 | + xbasis = d3.Chebyshev(coord, size=N, bounds=(-1, 1), dealias=dealias) |
| 19 | + return coord, dist, xbasis |
| 20 | + |
| 21 | + |
| 22 | +def fourier_2d(N, dealias=3/2, dtype=np.float64): |
| 23 | + coords = d3.CartesianCoordinates('x', 'y') |
| 24 | + dist = d3.Distributor(coords, dtype=dtype) |
| 25 | + xbasis = d3.Fourier(coords[0], size=N, bounds=(0, 2*np.pi), dealias=dealias, dtype=dtype) |
| 26 | + ybasis = d3.Fourier(coords[1], size=N, bounds=(0, 2*np.pi), dealias=dealias, dtype=dtype) |
| 27 | + return coords, dist, (xbasis, ybasis) |
| 28 | + |
| 29 | + |
| 30 | +def fourier_3d(N, dealias=3/2, dtype=np.float64): |
| 31 | + coords = d3.CartesianCoordinates('x', 'y', 'z') |
| 32 | + dist = d3.Distributor(coords, dtype=dtype) |
| 33 | + xbasis = d3.Fourier(coords[0], size=N, bounds=(0, 2*np.pi), dealias=dealias, dtype=dtype) |
| 34 | + ybasis = d3.Fourier(coords[1], size=N, bounds=(0, 2*np.pi), dealias=dealias, dtype=dtype) |
| 35 | + zbasis = d3.Fourier(coords[2], size=N, bounds=(0, 2*np.pi), dealias=dealias, dtype=dtype) |
| 36 | + return coords, dist, (xbasis, ybasis, zbasis) |
| 37 | + |
| 38 | + |
| 39 | +def channel_2d(N, dealias=3/2, dtype=np.float64): |
| 40 | + coords = d3.CartesianCoordinates('x', 'y') |
| 41 | + dist = d3.Distributor(coords, dtype=dtype) |
| 42 | + xbasis = d3.Fourier(coords[0], size=N, bounds=(0, 2*np.pi), dealias=dealias, dtype=dtype) |
| 43 | + ybasis = d3.Chebyshev(coords[1], size=N, bounds=(-1, 1), dealias=dealias) |
| 44 | + return coords, dist, (xbasis, ybasis) |
| 45 | + |
| 46 | + |
| 47 | +def channel_3d(N, dealias=3/2, dtype=np.float64): |
| 48 | + coords = d3.CartesianCoordinates('x', 'y', 'z') |
| 49 | + dist = d3.Distributor(coords, dtype=dtype) |
| 50 | + xbasis = d3.Fourier(coords[0], size=N, bounds=(0, 2*np.pi), dealias=dealias, dtype=dtype) |
| 51 | + ybasis = d3.Fourier(coords[1], size=N, bounds=(0, 2*np.pi), dealias=dealias, dtype=dtype) |
| 52 | + zbasis = d3.Chebyshev(coords[2], size=N, bounds=(-1, 1), dealias=dealias) |
| 53 | + return coords, dist, (xbasis, ybasis, zbasis) |
| 54 | + |
0 commit comments