Skip to content

Commit c829c76

Browse files
committed
Add quick domains
1 parent 8cb06e8 commit c829c76

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

dedalus/extras/quick_domains.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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+

dedalus/public.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@
1313
# Temporary stuff
1414
from .extras.flow_tools import CFL, GlobalFlowProperty
1515
from .tools.post import load_tasks_to_xarray
16+
from .extras import quick_domains

0 commit comments

Comments
 (0)