Skip to content

Commit d072923

Browse files
committed
Merge remote-tracking branch 'origin/multi-volume' into multi-volume
2 parents c1b68c7 + f8efd52 commit d072923

45 files changed

Lines changed: 500 additions & 8558 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

examples/advection/surface.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import pyopencl as cl
3232
import pyopencl.tools as cl_tools
3333

34-
from arraycontext import thaw
3534
from grudge.array_context import PyOpenCLArrayContext
3635

3736
from meshmode.dof_array import flatten
@@ -62,7 +61,7 @@ def __init__(self, actx, dcoll, order, visualize=True):
6261
import matplotlib.pyplot as pt
6362
self.fig = pt.figure(figsize=(8, 8), dpi=300)
6463

65-
x = thaw(dcoll.discr_from_dd(dof_desc.DD_VOLUME).nodes(), actx)
64+
x = actx.thaw(dcoll.discr_from_dd(dof_desc.DD_VOLUME).nodes())
6665
self.x = actx.to_numpy(flatten(actx.np.arctan2(x[1], x[0])))
6766
elif self.ambient_dim == 3:
6867
from grudge.shortcuts import make_visualizer
@@ -174,7 +173,7 @@ def main(ctx_factory, dim=2, order=4, use_quad=False, visualize=False):
174173
# {{{ Surface advection operator
175174

176175
# velocity field
177-
x = thaw(dcoll.nodes(), actx)
176+
x = actx.thaw(dcoll.nodes())
178177
c = make_obj_array([-x[1], x[0], 0.0])[:dim]
179178

180179
def f_initial_condition(x):
@@ -238,7 +237,7 @@ def rhs(t, u):
238237

239238
df = dof_desc.DOFDesc(FACE_RESTR_INTERIOR)
240239
face_discr = dcoll.discr_from_dd(df)
241-
face_normal = thaw(dcoll.normal(dd=df), actx)
240+
face_normal = actx.thaw(dcoll.normal(dd=df))
242241

243242
from meshmode.discretization.visualization import make_visualizer
244243
vis = make_visualizer(actx, face_discr)

examples/advection/var-velocity.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import pyopencl as cl
3030
import pyopencl.tools as cl_tools
3131

32-
from arraycontext import thaw
3332
from grudge.array_context import PyOpenCLArrayContext
3433

3534
from meshmode.dof_array import flatten
@@ -61,7 +60,7 @@ def __init__(self, actx, dcoll, order, visualize=True, ylim=None):
6160
self.ylim = ylim
6261

6362
volume_discr = dcoll.discr_from_dd(dof_desc.DD_VOLUME)
64-
self.x = actx.to_numpy(flatten(thaw(volume_discr.nodes()[0], actx)))
63+
self.x = actx.to_numpy(flatten(actx.thaw(volume_discr.nodes()[0])))
6564
else:
6665
from grudge.shortcuts import make_visualizer
6766
self.vis = make_visualizer(dcoll)
@@ -168,7 +167,7 @@ def zero_inflow_bc(dtag, t=0):
168167

169168
from grudge.models.advection import VariableCoefficientAdvectionOperator
170169

171-
x = thaw(dcoll.nodes(), actx)
170+
x = actx.thaw(dcoll.nodes())
172171

173172
# velocity field
174173
if dim == 1:

examples/advection/weak.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import pyopencl as cl
3131
import pyopencl.tools as cl_tools
3232

33-
from arraycontext import thaw
3433
from grudge.array_context import PyOpenCLArrayContext
3534

3635
from meshmode.dof_array import flatten
@@ -60,7 +59,7 @@ def __init__(self, actx, dcoll, order, visualize=True, ylim=None):
6059
self.ylim = ylim
6160

6261
volume_discr = dcoll.discr_from_dd(dof_desc.DD_VOLUME)
63-
self.x = actx.to_numpy(flatten(thaw(volume_discr.nodes()[0], actx)))
62+
self.x = actx.to_numpy(flatten(actx.thaw(volume_discr.nodes()[0])))
6463
else:
6564
from grudge.shortcuts import make_visualizer
6665
self.vis = make_visualizer(dcoll)
@@ -152,13 +151,13 @@ def u_analytic(x, t=0):
152151
dcoll,
153152
c,
154153
inflow_u=lambda t: u_analytic(
155-
thaw(dcoll.nodes(dd=BTAG_ALL), actx),
154+
actx.thaw(dcoll.nodes(dd=BTAG_ALL)),
156155
t=t
157156
),
158157
flux_type=flux_type
159158
)
160159

161-
nodes = thaw(dcoll.nodes(), actx)
160+
nodes = actx.thaw(dcoll.nodes())
162161
u = u_analytic(nodes, t=0)
163162

164163
def rhs(t, u):

examples/euler/acoustic_pulse.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import pyopencl as cl
2929
import pyopencl.tools as cl_tools
3030

31-
from arraycontext import thaw, freeze
3231
from grudge.array_context import (
3332
PyOpenCLArrayContext,
3433
PytatoPyOpenCLArrayContext
@@ -175,7 +174,7 @@ def rhs(t, q):
175174
cn = 0.5*(order + 1)**2
176175
dt = cfl * actx.to_numpy(h_min_from_volume(dcoll)) / cn
177176

178-
fields = acoustic_pulse_condition(thaw(dcoll.nodes(), actx))
177+
fields = acoustic_pulse_condition(actx.thaw(dcoll.nodes()))
179178

180179
logger.info("Timestep size: %g", dt)
181180

@@ -204,7 +203,7 @@ def rhs(t, q):
204203
)
205204
assert norm_q < 5
206205

207-
fields = thaw(freeze(fields, actx), actx)
206+
fields = actx.thaw(actx.freeze(fields))
208207
fields = rk4_step(fields, t, dt, compiled_rhs)
209208
t += dt
210209
step += 1

examples/euler/vortex.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626
import pyopencl as cl
2727
import pyopencl.tools as cl_tools
2828

29-
from arraycontext import thaw, freeze
30-
3129
from grudge.array_context import PytatoPyOpenCLArrayContext, PyOpenCLArrayContext
3230
from grudge.models.euler import (
3331
vortex_initial_condition,
@@ -111,7 +109,7 @@ def rhs(t, q):
111109

112110
compiled_rhs = actx.compile(rhs)
113111

114-
fields = vortex_initial_condition(thaw(dcoll.nodes(), actx))
112+
fields = vortex_initial_condition(actx.thaw(dcoll.nodes()))
115113

116114
from grudge.dt_utils import h_min_from_volume
117115

@@ -147,7 +145,7 @@ def rhs(t, q):
147145
)
148146
assert norm_q < 200
149147

150-
fields = thaw(freeze(fields, actx), actx)
148+
fields = actx.thaw(actx.freeze(fields))
151149
fields = rk4_step(fields, t, dt, compiled_rhs)
152150
t += dt
153151
step += 1

examples/geometry.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import pyopencl as cl
3131
import pyopencl.tools as cl_tools
3232

33-
from arraycontext import thaw
3433
from grudge.array_context import PyOpenCLArrayContext
3534

3635
from grudge import DiscretizationCollection, shortcuts
@@ -51,9 +50,9 @@ def main(write_output=True):
5150

5251
dcoll = DiscretizationCollection(actx, mesh, order=4)
5352

54-
nodes = thaw(dcoll.nodes(), actx)
55-
bdry_nodes = thaw(dcoll.nodes(dd=BTAG_ALL), actx)
56-
bdry_normals = thaw(dcoll.normal(dd=BTAG_ALL), actx)
53+
nodes = actx.thaw(dcoll.nodes())
54+
bdry_nodes = actx.thaw(dcoll.nodes(dd=BTAG_ALL))
55+
bdry_normals = actx.thaw(dcoll.normal(dd=BTAG_ALL))
5756

5857
if write_output:
5958
vis = shortcuts.make_visualizer(dcoll)

examples/hello-grudge.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import grudge.op as op
1515
from meshmode.mesh.generation import generate_box_mesh
1616
from meshmode.array_context import PyOpenCLArrayContext
17-
from arraycontext import thaw
1817
from grudge.dof_desc import BoundaryDomainTag, FACE_RESTR_INTERIOR
1918

2019

@@ -43,7 +42,7 @@ def left_boundary_condition(x, t):
4342
def flux(dcoll, u_tpair):
4443
dd = u_tpair.dd
4544
velocity = np.array([2 * np.pi])
46-
normal = thaw(dcoll.normal(dd), actx)
45+
normal = actx.thaw(dcoll.normal(dd))
4746

4847
v_dot_n = np.dot(velocity, normal)
4948
u_upwind = actx.np.where(v_dot_n > 0,
@@ -55,8 +54,8 @@ def flux(dcoll, u_tpair):
5554
left_bndry = BoundaryDomainTag("left")
5655
right_bndry = BoundaryDomainTag("right")
5756

58-
x_vol = thaw(dcoll.nodes(), actx)
59-
x_bndry = thaw(dcoll.discr_from_dd(left_bndry).nodes(), actx)
57+
x_vol = actx.thaw(dcoll.nodes())
58+
x_bndry = actx.thaw(dcoll.discr_from_dd(left_bndry).nodes())
6059

6160
uh = initial_condition(x_vol)
6261

examples/maxwell/cavities.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import pyopencl as cl
2929
import pyopencl.tools as cl_tools
3030

31-
from arraycontext import thaw
3231
from grudge.array_context import PyOpenCLArrayContext
3332

3433
from grudge.shortcuts import set_up_rk4
@@ -84,7 +83,7 @@ def cavity_mode(x, t=0):
8483
else:
8584
return get_rectangular_cavity_mode(actx, x, t, 1, (2, 3))
8685

87-
fields = cavity_mode(thaw(dcoll.nodes(), actx), t=0)
86+
fields = cavity_mode(actx.thaw(dcoll.nodes()), t=0)
8887

8988
maxwell_operator.check_bc_coverage(mesh)
9089

0 commit comments

Comments
 (0)