From abe8eff29c24708b5b0df80f9a189b039369cc9a Mon Sep 17 00:00:00 2001 From: Michael Campbell Date: Wed, 29 Jun 2022 10:56:18 -0500 Subject: [PATCH 1/4] Update for array context API deprecations --- examples/autoignition-mpi.py | 2 +- examples/doublemach-mpi.py | 4 ++-- examples/heat-source-mpi.py | 2 +- examples/hotplate-mpi.py | 4 ++-- examples/lump-mpi.py | 4 ++-- examples/mixture-mpi.py | 4 ++-- examples/nsmix-mpi.py | 2 +- examples/poiseuille-mpi.py | 4 ++-- examples/pulse-mpi.py | 2 +- examples/scalar-lump-mpi.py | 4 ++-- examples/sod-mpi.py | 4 ++-- examples/vortex-mpi.py | 4 ++-- examples/wave-mpi.py | 5 ++--- examples/wave.py | 5 ++--- mirgecom/artificial_viscosity.py | 4 ++-- mirgecom/boundary.py | 13 ++++++------- mirgecom/diffusion.py | 5 ++--- mirgecom/initializers.py | 7 +++---- mirgecom/inviscid.py | 3 +-- mirgecom/navierstokes.py | 4 +--- mirgecom/steppers.py | 8 ++------ mirgecom/viscous.py | 3 +-- mirgecom/wave.py | 4 +--- test/test_av.py | 17 ++++++++--------- test/test_bc.py | 31 +++++++++++++++---------------- test/test_diffusion.py | 15 +++++++-------- test/test_eos.py | 9 +++------ test/test_euler.py | 17 ++++++++--------- test/test_filter.py | 4 +--- test/test_fluid.py | 9 ++++----- test/test_init.py | 15 +++++++-------- test/test_inviscid.py | 13 ++++++------- test/test_lazy.py | 24 +++++++++++------------- test/test_navierstokes.py | 13 ++++++------- test/test_operators.py | 18 ++++++++---------- test/test_restart.py | 3 +-- test/test_simutil.py | 8 +++----- test/test_symbolic.py | 3 +-- test/test_viscous.py | 17 ++++++++--------- test/test_wave.py | 5 ++--- 40 files changed, 142 insertions(+), 180 deletions(-) diff --git a/examples/autoignition-mpi.py b/examples/autoignition-mpi.py index c7860e783..f07775b0e 100644 --- a/examples/autoignition-mpi.py +++ b/examples/autoignition-mpi.py @@ -171,7 +171,7 @@ def main(actx_class, ctx_factory=cl.create_some_context, use_logmgr=True, discr = create_discretization_collection(actx, local_mesh, order=order, mpi_communicator=comm) - nodes = thaw(discr.nodes(), actx) + nodes = actx.thaw(discr.nodes()) ones = discr.zeros(actx) + 1.0 if use_overintegration: diff --git a/examples/doublemach-mpi.py b/examples/doublemach-mpi.py index 397b35655..c2eaa3321 100644 --- a/examples/doublemach-mpi.py +++ b/examples/doublemach-mpi.py @@ -195,7 +195,7 @@ def main(ctx_factory=cl.create_some_context, use_logmgr=True, order = 3 discr = create_discretization_collection(actx, local_mesh, order=order, mpi_communicator=comm) - nodes = thaw(discr.nodes(), actx) + nodes = actx.thaw(discr.nodes()) from grudge.dof_desc import DISCR_TAG_QUAD if use_overintegration: @@ -241,7 +241,7 @@ def main(ctx_factory=cl.create_some_context, use_logmgr=True, def _boundary_state(discr, btag, gas_model, state_minus, **kwargs): actx = state_minus.array_context bnd_discr = discr.discr_from_dd(btag) - nodes = thaw(bnd_discr.nodes(), actx) + nodes = actx.thaw(bnd_discr.nodes()) return make_fluid_state(initializer(x_vec=nodes, eos=gas_model.eos, **kwargs), gas_model) diff --git a/examples/heat-source-mpi.py b/examples/heat-source-mpi.py index d38e28cf8..467df04b5 100644 --- a/examples/heat-source-mpi.py +++ b/examples/heat-source-mpi.py @@ -123,7 +123,7 @@ def main(actx_class, ctx_factory=cl.create_some_context, use_logmgr=True, source_width = 0.2 from arraycontext import thaw - nodes = thaw(discr.nodes(), actx) + nodes = actx.thaw(discr.nodes()) boundaries = { DTAG_BOUNDARY("dirichlet"): DirichletDiffusionBoundary(0.), diff --git a/examples/hotplate-mpi.py b/examples/hotplate-mpi.py index f6704f9ac..0f35353fd 100644 --- a/examples/hotplate-mpi.py +++ b/examples/hotplate-mpi.py @@ -172,7 +172,7 @@ def main(ctx_factory=cl.create_some_context, use_logmgr=True, discr = create_discretization_collection( actx, local_mesh, order=order, mpi_communicator=comm ) - nodes = thaw(discr.nodes(), actx) + nodes = actx.thaw(discr.nodes()) if logmgr: logmgr_add_device_name(logmgr, queue) @@ -225,7 +225,7 @@ def tramp_2d(x_vec, eos, cv=None, **kwargs): def _boundary_state(discr, btag, gas_model, state_minus, **kwargs): actx = state_minus.array_context bnd_discr = discr.discr_from_dd(btag) - nodes = thaw(bnd_discr.nodes(), actx) + nodes = actx.thaw(bnd_discr.nodes()) return make_fluid_state(initializer(x_vec=nodes, eos=gas_model.eos, **kwargs), gas_model) diff --git a/examples/lump-mpi.py b/examples/lump-mpi.py index a6d8e3a04..0f5bbe570 100644 --- a/examples/lump-mpi.py +++ b/examples/lump-mpi.py @@ -151,7 +151,7 @@ def main(actx_class, ctx_factory=cl.create_some_context, use_logmgr=True, discr = create_discretization_collection( actx, local_mesh, order=order, mpi_communicator=comm ) - nodes = thaw(discr.nodes(), actx) + nodes = actx.thaw(discr.nodes()) vis_timer = None @@ -185,7 +185,7 @@ def main(actx_class, ctx_factory=cl.create_some_context, use_logmgr=True, def boundary_solution(discr, btag, gas_model, state_minus, **kwargs): actx = state_minus.array_context bnd_discr = discr.discr_from_dd(btag) - nodes = thaw(bnd_discr.nodes(), actx) + nodes = actx.thaw(bnd_discr.nodes()) return make_fluid_state(initializer(x_vec=nodes, eos=gas_model.eos, **kwargs), gas_model) diff --git a/examples/mixture-mpi.py b/examples/mixture-mpi.py index 46a694460..bd9f25eea 100644 --- a/examples/mixture-mpi.py +++ b/examples/mixture-mpi.py @@ -151,7 +151,7 @@ def main(actx_class, ctx_factory=cl.create_some_context, use_logmgr=True, discr = create_discretization_collection( actx, local_mesh, order=order, mpi_communicator=comm ) - nodes = thaw(discr.nodes(), actx) + nodes = actx.thaw(discr.nodes()) vis_timer = None @@ -206,7 +206,7 @@ def main(actx_class, ctx_factory=cl.create_some_context, use_logmgr=True, def boundary_solution(discr, btag, gas_model, state_minus, **kwargs): actx = state_minus.array_context bnd_discr = discr.discr_from_dd(btag) - nodes = thaw(bnd_discr.nodes(), actx) + nodes = actx.thaw(bnd_discr.nodes()) return make_fluid_state(initializer(x_vec=nodes, eos=gas_model.eos, **kwargs), gas_model, temperature_seed=state_minus.temperature) diff --git a/examples/nsmix-mpi.py b/examples/nsmix-mpi.py index b602e8509..0093f3833 100644 --- a/examples/nsmix-mpi.py +++ b/examples/nsmix-mpi.py @@ -159,7 +159,7 @@ def main(ctx_factory=cl.create_some_context, use_logmgr=True, discr = create_discretization_collection( actx, local_mesh, order=order, mpi_communicator=comm ) - nodes = thaw(discr.nodes(), actx) + nodes = actx.thaw(discr.nodes()) ones = discr.zeros(actx) + 1.0 if logmgr: diff --git a/examples/poiseuille-mpi.py b/examples/poiseuille-mpi.py index c9ee63324..7f0db1cd6 100644 --- a/examples/poiseuille-mpi.py +++ b/examples/poiseuille-mpi.py @@ -174,7 +174,7 @@ def main(ctx_factory=cl.create_some_context, use_logmgr=True, discr = create_discretization_collection( actx, local_mesh, order=order, mpi_communicator=comm ) - nodes = thaw(discr.nodes(), actx) + nodes = actx.thaw(discr.nodes()) if use_overintegration: quadrature_tag = DISCR_TAG_QUAD @@ -241,7 +241,7 @@ def poiseuille_2d(x_vec, eos, cv=None, **kwargs): def _boundary_solution(discr, btag, gas_model, state_minus, **kwargs): actx = state_minus.array_context bnd_discr = discr.discr_from_dd(btag) - nodes = thaw(bnd_discr.nodes(), actx) + nodes = actx.thaw(bnd_discr.nodes()) return make_fluid_state(initializer(x_vec=nodes, eos=gas_model.eos, cv=state_minus.cv, **kwargs), gas_model) diff --git a/examples/pulse-mpi.py b/examples/pulse-mpi.py index a98e31121..f74468e56 100644 --- a/examples/pulse-mpi.py +++ b/examples/pulse-mpi.py @@ -157,7 +157,7 @@ def main(actx_class, ctx_factory=cl.create_some_context, use_logmgr=True, discr = create_discretization_collection( actx, local_mesh, order=order, mpi_communicator=comm ) - nodes = thaw(discr.nodes(), actx) + nodes = actx.thaw(discr.nodes()) if use_overintegration: quadrature_tag = DISCR_TAG_QUAD diff --git a/examples/scalar-lump-mpi.py b/examples/scalar-lump-mpi.py index 9a8fb5f40..475ba9699 100644 --- a/examples/scalar-lump-mpi.py +++ b/examples/scalar-lump-mpi.py @@ -150,7 +150,7 @@ def main(actx_class, ctx_factory=cl.create_some_context, use_logmgr=True, discr = create_discretization_collection( actx, local_mesh, order=order, mpi_communicator=comm ) - nodes = thaw(discr.nodes(), actx) + nodes = actx.thaw(discr.nodes()) vis_timer = None @@ -190,7 +190,7 @@ def main(actx_class, ctx_factory=cl.create_some_context, use_logmgr=True, def boundary_solution(discr, btag, gas_model, state_minus, **kwargs): actx = state_minus.array_context bnd_discr = discr.discr_from_dd(btag) - nodes = thaw(bnd_discr.nodes(), actx) + nodes = actx.thaw(bnd_discr.nodes()) return make_fluid_state(initializer(x_vec=nodes, eos=gas_model.eos, **kwargs), gas_model) diff --git a/examples/sod-mpi.py b/examples/sod-mpi.py index 5f4384a4c..61b85f605 100644 --- a/examples/sod-mpi.py +++ b/examples/sod-mpi.py @@ -149,7 +149,7 @@ def main(actx_class, ctx_factory=cl.create_some_context, use_logmgr=True, discr = create_discretization_collection( actx, local_mesh, order=order, mpi_communicator=comm ) - nodes = thaw(discr.nodes(), actx) + nodes = actx.thaw(discr.nodes()) vis_timer = None @@ -178,7 +178,7 @@ def main(actx_class, ctx_factory=cl.create_some_context, use_logmgr=True, def boundary_solution(discr, btag, gas_model, state_minus, **kwargs): actx = state_minus.array_context bnd_discr = discr.discr_from_dd(btag) - nodes = thaw(bnd_discr.nodes(), actx) + nodes = actx.thaw(bnd_discr.nodes()) return make_fluid_state(initializer(x_vec=nodes, eos=gas_model.eos, **kwargs), gas_model) diff --git a/examples/vortex-mpi.py b/examples/vortex-mpi.py index 21cc15f33..7a67c5954 100644 --- a/examples/vortex-mpi.py +++ b/examples/vortex-mpi.py @@ -154,7 +154,7 @@ def main(actx_class, ctx_factory=cl.create_some_context, use_logmgr=True, discr = create_discretization_collection( actx, local_mesh, order=order, mpi_communicator=comm ) - nodes = thaw(discr.nodes(), actx) + nodes = actx.thaw(discr.nodes()) vis_timer = None @@ -195,7 +195,7 @@ def main(actx_class, ctx_factory=cl.create_some_context, use_logmgr=True, def boundary_solution(discr, btag, gas_model, state_minus, **kwargs): actx = state_minus.array_context bnd_discr = discr.discr_from_dd(btag) - nodes = thaw(bnd_discr.nodes(), actx) + nodes = actx.thaw(bnd_discr.nodes()) return make_fluid_state(initializer(x_vec=nodes, eos=gas_model.eos, **kwargs), gas_model) diff --git a/examples/wave-mpi.py b/examples/wave-mpi.py index 10e0bdcc6..d3d033cf5 100644 --- a/examples/wave-mpi.py +++ b/examples/wave-mpi.py @@ -28,7 +28,6 @@ import pyopencl as cl from pytools.obj_array import flat_obj_array -from arraycontext import thaw, freeze from meshmode.mesh import BTAG_ALL, BTAG_NONE # noqa @@ -135,7 +134,7 @@ def main(actx_class, snapshot_pattern="wave-mpi-{step:04d}-{rank:04d}.pkl", discr = create_discretization_collection( actx, local_mesh, order=order, mpi_communicator=comm ) - nodes = thaw(discr.nodes(), actx) + nodes = actx.thaw(discr.nodes()) current_cfl = 0.485 wave_speed = 1.0 @@ -229,7 +228,7 @@ def rhs(t, w): ], overwrite=True ) - fields = thaw(freeze(fields, actx), actx) + fields = actx.thaw(actx.freeze(fields)) fields = rk4_step(fields, t, dt, compiled_rhs) t += dt diff --git a/examples/wave.py b/examples/wave.py index 7163e0181..0fe095988 100644 --- a/examples/wave.py +++ b/examples/wave.py @@ -39,7 +39,6 @@ from meshmode.array_context import (PyOpenCLArrayContext, PytatoPyOpenCLArrayContext) -from arraycontext import thaw, freeze from mirgecom.profiling import PyOpenCLProfilingArrayContext @@ -104,7 +103,7 @@ def main(use_profiling=False, use_logmgr=False, lazy_eval: bool = False): order = 3 discr = create_discretization_collection(actx, mesh, order=order) - nodes = thaw(discr.nodes(), actx) + nodes = actx.thaw(discr.nodes()) current_cfl = 0.485 wave_speed = 1.0 @@ -149,7 +148,7 @@ def rhs(t, w): if logmgr: logmgr.tick_before() - fields = thaw(freeze(fields, actx), actx) + fields = actx.thaw(actx.freeze(fields)) fields = rk4_step(fields, t, dt, compiled_rhs) if istep % 10 == 0: diff --git a/mirgecom/artificial_viscosity.py b/mirgecom/artificial_viscosity.py index 4537be041..807a0de33 100644 --- a/mirgecom/artificial_viscosity.py +++ b/mirgecom/artificial_viscosity.py @@ -129,7 +129,7 @@ from pytools import memoize_in, keyed_memoize_in from functools import partial -from meshmode.dof_array import thaw, DOFArray +from meshmode.dof_array import DOFArray from mirgecom.flux import num_flux_central from mirgecom.operators import div_operator @@ -254,7 +254,7 @@ def interp_to_vol_quad(u): def central_flux_div(utpair): dd = utpair.dd - normal = thaw(actx, discr.normal(dd)) + normal = actx.thaw(discr.normal(dd)) return op.project(discr, dd, dd.with_dtag("all_faces"), # This uses a central vector flux along nhat: # flux = 1/2 * (grad(Q)- + grad(Q)+) .dot. nhat diff --git a/mirgecom/boundary.py b/mirgecom/boundary.py index acbf32282..1b0eb0921 100644 --- a/mirgecom/boundary.py +++ b/mirgecom/boundary.py @@ -44,7 +44,6 @@ """ import numpy as np -from arraycontext import thaw from meshmode.mesh import BTAG_ALL, BTAG_NONE # noqa from mirgecom.fluid import make_conserved from grudge.trace_pair import TracePair @@ -364,7 +363,7 @@ def _gradient_flux_for_prescribed_cv(self, discr, btag, gas_model, state_minus, exterior=boundary_state.cv) actx = state_minus.array_context - nhat = thaw(discr.normal(btag), actx) + nhat = actx.thaw(discr.normal(btag)) from arraycontext import outer return outer(self._grad_num_flux_func(cv_pair.int, cv_pair.ext), nhat) @@ -374,7 +373,7 @@ def _gradient_flux_for_prescribed_temperature(self, discr, btag, gas_model, state_minus, **kwargs): # Feed a boundary temperature to numerical flux for grad op actx = state_minus.array_context - nhat = thaw(discr.normal(btag), actx) + nhat = actx.thaw(discr.normal(btag)) bnd_tpair = TracePair(btag, interior=state_minus.temperature, exterior=self._bnd_temperature_func( @@ -394,7 +393,7 @@ def _inviscid_flux_for_prescribed_state( gas_model=gas_model, state_minus=state_minus, **kwargs) - normal = thaw(discr.normal(btag), state_minus.array_context) + normal = state_minus.array_context.thaw(discr.normal(btag)) return numerical_flux_func(boundary_state_pair, gas_model, normal) # Returns the flux to be used by the divergence operator when computing the @@ -470,7 +469,7 @@ def av_flux(self, discr, btag, diffusion, **kwargs): """Get the diffusive fluxes for the AV operator API.""" grad_av_minus = op.project(discr, "vol", btag, diffusion) actx = grad_av_minus.mass[0].array_context - nhat = thaw(discr.normal(btag), actx) + nhat = actx.thaw(discr.normal(btag)) grad_av_plus = self._bnd_grad_av_func( discr=discr, btag=btag, grad_av_minus=grad_av_minus, **kwargs) bnd_grad_pair = TracePair(btag, interior=grad_av_minus, @@ -531,7 +530,7 @@ def adiabatic_slip_state(self, discr, btag, gas_model, state_minus, **kwargs): actx = state_minus.array_context # Grab a unit normal to the boundary - nhat = thaw(discr.normal(btag), actx) + nhat = actx.thaw(discr.normal(btag)) # Subtract out the 2*wall-normal component # of velocity from the velocity at the wall to @@ -553,7 +552,7 @@ def adiabatic_slip_grad_av(self, discr, btag, grad_av_minus, **kwargs): # Grab some boundary-relevant data dim, = grad_av_minus.mass.shape actx = grad_av_minus.mass[0].array_context - nhat = thaw(discr.normal(btag), actx) + nhat = actx.thaw(discr.normal(btag)) # Subtract 2*wall-normal component of q # to enforce q=0 on the wall diff --git a/mirgecom/diffusion.py b/mirgecom/diffusion.py index 041a6e8d7..28a190eb4 100644 --- a/mirgecom/diffusion.py +++ b/mirgecom/diffusion.py @@ -37,7 +37,6 @@ import numpy as np import numpy.linalg as la # noqa from pytools.obj_array import make_obj_array, obj_array_vectorize_n_args -from arraycontext import thaw from meshmode.mesh import BTAG_ALL, BTAG_NONE # noqa from grudge.dof_desc import DOFDesc, as_dofdesc, DISCR_TAG_BASE from grudge.trace_pair import TracePair, interior_trace_pairs @@ -52,7 +51,7 @@ def grad_flux(discr, u_tpair, *, quadrature_tag=DISCR_TAG_BASE): dd_quad = dd.with_discr_tag(quadrature_tag) dd_allfaces_quad = dd_quad.with_dtag("all_faces") - normal_quad = thaw(discr.normal(dd_quad), actx) + normal_quad = actx.thaw(discr.normal(dd_quad)) def to_quad(a): return op.project(discr, dd, dd_quad, a) @@ -73,7 +72,7 @@ def diffusion_flux( dd_quad = dd.with_discr_tag(quadrature_tag) dd_allfaces_quad = dd_quad.with_dtag("all_faces") - normal_quad = thaw(discr.normal(dd_quad), actx) + normal_quad = actx.thaw(discr.normal(dd_quad)) def to_quad(a): return op.project(discr, dd, dd_quad, a) diff --git a/mirgecom/initializers.py b/mirgecom/initializers.py index 4216560e1..ee7ab1b26 100644 --- a/mirgecom/initializers.py +++ b/mirgecom/initializers.py @@ -42,7 +42,6 @@ import numpy as np from pytools.obj_array import make_obj_array -from arraycontext import thaw from mirgecom.eos import IdealSingleGas from mirgecom.fluid import make_conserved @@ -510,7 +509,7 @@ def exact_rhs(self, discr, cv, time=0.0): """ t = time actx = cv.array_context - nodes = thaw(discr.nodes(), actx) + nodes = actx.thaw(discr.nodes()) lump_loc = self._center + t * self._velocity # coordinates relative to lump center rel_center = make_obj_array( @@ -689,7 +688,7 @@ def exact_rhs(self, discr, cv, time=0.0): """ t = time actx = cv.array_context - nodes = thaw(discr.nodes(), actx) + nodes = actx.thaw(discr.nodes()) loc_update = t * self._velocity mass = 0 * nodes[0] + self._rho0 @@ -878,7 +877,7 @@ def exact_rhs(self, discr, cv, time=0.0): Time at which RHS is desired (unused) """ actx = cv.array_context - nodes = thaw(discr.nodes(), actx) + nodes = actx.thaw(discr.nodes()) mass = nodes[0].copy() mass[:] = 1.0 massrhs = 0.0 * mass diff --git a/mirgecom/inviscid.py b/mirgecom/inviscid.py index 2cce58171..52911e3c6 100644 --- a/mirgecom/inviscid.py +++ b/mirgecom/inviscid.py @@ -40,7 +40,6 @@ """ import numpy as np -from arraycontext import thaw import grudge.op as op from mirgecom.fluid import make_conserved @@ -270,7 +269,7 @@ def _interior_flux(state_pair): state_pair.dd, state_pair.dd.with_dtag("all_faces"), numerical_flux_func( state_pair, gas_model, - thaw(discr.normal(state_pair.dd), state_pair.int.array_context))) + state_pair.int.array_context.thaw(discr.normal(state_pair.dd)))) def _boundary_flux(dd_bdry, boundary, state_minus): return op.project(discr, diff --git a/mirgecom/navierstokes.py b/mirgecom/navierstokes.py index 86bd57a93..d709d3b00 100644 --- a/mirgecom/navierstokes.py +++ b/mirgecom/navierstokes.py @@ -85,8 +85,6 @@ ) from mirgecom.gas_model import make_operator_fluid_states -from arraycontext import thaw - class _NSGradCVTag: pass @@ -101,7 +99,7 @@ def _gradient_flux_interior(discr, numerical_flux_func, tpair): from arraycontext import outer actx = tpair.int.array_context dd = tpair.dd - normal = thaw(discr.normal(dd), actx) + normal = actx.thaw(discr.normal(dd)) flux = outer(numerical_flux_func(tpair.int, tpair.ext), normal) return op.project(discr, dd, dd.with_dtag("all_faces"), flux) diff --git a/mirgecom/steppers.py b/mirgecom/steppers.py index a8f129487..864b73148 100644 --- a/mirgecom/steppers.py +++ b/mirgecom/steppers.py @@ -32,11 +32,7 @@ from logpyle import set_dt from mirgecom.logging_quantities import set_sim_state from pytools import memoize_in -from arraycontext import ( - freeze, - thaw, - get_container_context_recursively -) +from arraycontext import get_container_context_recursively def _compile_timestepper(actx, timestepper, rhs): @@ -67,7 +63,7 @@ def get_rhs(): def _force_evaluation(actx, state): if actx is None: return state - return thaw(freeze(state, actx), actx) + return actx.thaw(actx.freeze(state)) def _advance_state_stepper_func(rhs, timestepper, diff --git a/mirgecom/viscous.py b/mirgecom/viscous.py index bb39fa1ef..b88035f11 100644 --- a/mirgecom/viscous.py +++ b/mirgecom/viscous.py @@ -45,7 +45,6 @@ import numpy as np from meshmode.dof_array import DOFArray -from arraycontext import thaw import grudge.op as op @@ -323,7 +322,7 @@ def viscous_facial_flux_central(discr, state_pair, grad_cv_pair, grad_t_pair, """ from mirgecom.flux import num_flux_central actx = state_pair.int.array_context - normal = thaw(discr.normal(state_pair.dd), actx) + normal = actx.thaw(discr.normal(state_pair.dd)) f_int = viscous_flux(state_pair.int, grad_cv_pair.int, grad_t_pair.int) diff --git a/mirgecom/wave.py b/mirgecom/wave.py index eea795f99..50e3ecac1 100644 --- a/mirgecom/wave.py +++ b/mirgecom/wave.py @@ -31,7 +31,6 @@ import numpy.linalg as la # noqa from pytools.obj_array import flat_obj_array from meshmode.mesh import BTAG_ALL, BTAG_NONE # noqa -from meshmode.dof_array import thaw from grudge.trace_pair import TracePair, interior_trace_pairs import grudge.op as op @@ -41,8 +40,7 @@ def _flux(discr, c, w_tpair): v = w_tpair[1:] actx = w_tpair.int[0].array_context - - normal = thaw(actx, discr.normal(w_tpair.dd)) + normal = actx.thaw(discr.normal(w_tpair.dd)) flux_weak = flat_obj_array( np.dot(v.avg, normal), diff --git a/test/test_av.py b/test/test_av.py index ef3f41b79..7b9eeb973 100644 --- a/test/test_av.py +++ b/test/test_av.py @@ -34,7 +34,6 @@ pytest_generate_tests_for_pyopencl_array_context as pytest_generate_tests ) -from arraycontext import thaw from meshmode.mesh import BTAG_ALL import grudge.op as op from mirgecom.artificial_viscosity import ( @@ -98,7 +97,7 @@ def norm_indicator(expected, discr, soln, **kwargs): ) discr = create_discretization_collection(actx, mesh, order=order) - nodes = thaw(discr.nodes(), actx) + nodes = actx.thaw(discr.nodes()) nele = mesh.nelements zeros = 0.0*nodes[0] @@ -203,7 +202,7 @@ def test_artificial_viscosity(ctx_factory, dim, order): ) discr = create_discretization_collection(actx, mesh, order=order) - nodes = thaw(discr.nodes(), actx) + nodes = actx.thaw(discr.nodes()) class TestBoundary: @@ -213,14 +212,14 @@ def cv_gradient_flux(self, disc, btag, state_minus, gas_model, **kwargs): bnd_pair = TracePair(btag, interior=cv_int, exterior=cv_int) - nhat = thaw(disc.normal(btag), actx) + nhat = actx.thaw(disc.normal(btag)) from mirgecom.flux import num_flux_central from arraycontext import outer # Do not project to "all_faces" as now we use built-in grad_cv_operator return outer(num_flux_central(bnd_pair.int, bnd_pair.ext), nhat) def av_flux(self, disc, btag, diffusion, **kwargs): - nhat = thaw(disc.normal(btag), actx) + nhat = actx.thaw(disc.normal(btag)) diffusion_minus = op.project(discr, "vol", btag, diffusion) diffusion_plus = diffusion_minus from grudge.trace_pair import TracePair @@ -296,7 +295,7 @@ def test_trig(ctx_factory, dim, order): ) discr = create_discretization_collection(actx, mesh, order=order) - nodes = thaw(discr.nodes(), actx) + nodes = actx.thaw(discr.nodes()) boundaries = {} @@ -406,7 +405,7 @@ def test_fluid_av_boundaries(ctx_factory, prescribed_soln, order): def _boundary_state_func(discr, btag, gas_model, state_minus, **kwargs): actx = state_minus.array_context bnd_discr = discr.discr_from_dd(btag) - nodes = thaw(bnd_discr.nodes(), actx) + nodes = actx.thaw(bnd_discr.nodes()) return make_fluid_state(prescribed_soln(r=nodes, eos=gas_model.eos, **kwargs), gas_model) @@ -416,11 +415,11 @@ def _boundary_state_func(discr, btag, gas_model, state_minus, **kwargs): mesh = _get_box_mesh(dim=dim, a=a, b=b, n=npts_geom) from mirgecom.discretization import create_discretization_collection discr = create_discretization_collection(actx, mesh, order=order) - nodes = thaw(discr.nodes(), actx) + nodes = actx.thaw(discr.nodes()) cv = prescribed_soln(r=nodes, eos=gas_model.eos) fluid_state = make_fluid_state(cv, gas_model) - boundary_nhat = thaw(discr.normal(BTAG_ALL), actx) + boundary_nhat = actx.thaw(discr.normal(BTAG_ALL)) from mirgecom.boundary import ( PrescribedFluidBoundary, diff --git a/test/test_bc.py b/test/test_bc.py index 94688a94e..5a3b812ce 100644 --- a/test/test_bc.py +++ b/test/test_bc.py @@ -29,7 +29,6 @@ import logging import pytest -from arraycontext import thaw from meshmode.mesh import BTAG_ALL, BTAG_NONE # noqa from mirgecom.initializers import Lump from mirgecom.boundary import AdiabaticSlipBoundary @@ -79,10 +78,10 @@ def test_slipwall_identity(actx_factory, dim): order = 3 discr = create_discretization_collection(actx, mesh, order) - nodes = thaw(discr.nodes(), actx) + nodes = actx.thaw(discr.nodes()) eos = IdealSingleGas() orig = np.zeros(shape=(dim,)) - nhat = thaw(discr.normal(BTAG_ALL), actx) + nhat = actx.thaw(discr.normal(BTAG_ALL)) gas_model = GasModel(eos=eos) logger.info(f"Number of {dim}d elems: {mesh.nelements}") @@ -154,8 +153,8 @@ def test_slipwall_flux(actx_factory, dim, order, flux_func): ) discr = create_discretization_collection(actx, mesh, order=order) - nodes = thaw(discr.nodes(), actx) - nhat = thaw(discr.normal(BTAG_ALL), actx) + nodes = actx.thaw(discr.nodes()) + nhat = actx.thaw(discr.normal(BTAG_ALL)) h = 1.0 / nel_1d def bnd_norm(vec): @@ -194,7 +193,7 @@ def bnd_norm(vec): avg_state = 0.5*(bnd_pair.int + bnd_pair.ext) err_max = max(err_max, bnd_norm(np.dot(avg_state.momentum, nhat))) - normal = thaw(discr.normal(BTAG_ALL), actx) + normal = actx.thaw(discr.normal(BTAG_ALL)) bnd_flux = flux_func(state_pair, gas_model, normal) err_max = max(err_max, bnd_norm(bnd_flux.mass), @@ -251,15 +250,15 @@ def test_noslip(actx_factory, dim, flux_func): mesh = _get_box_mesh(dim=dim, a=a, b=b, n=npts_geom) discr = create_discretization_collection(actx, mesh, order=order) - nodes = thaw(discr.nodes(), actx) - nhat = thaw(discr.normal(BTAG_ALL), actx) + nodes = actx.thaw(discr.nodes()) + nhat = actx.thaw(discr.normal(BTAG_ALL)) print(f"{nhat=}") from mirgecom.flux import num_flux_central def scalar_flux_interior(int_tpair): from arraycontext import outer - normal = thaw(discr.normal(int_tpair.dd), actx) + normal = actx.thaw(discr.normal(int_tpair.dd)) # Hard-coding central per [Bassi_1997]_ eqn 13 flux_weak = outer(num_flux_central(int_tpair.int, int_tpair.ext), normal) return op.project(discr, int_tpair.dd, "all_faces", flux_weak) @@ -345,7 +344,7 @@ def scalar_flux_interior(int_tpair): gas_model=gas_model, state_minus=state_minus) - nhat = thaw(discr.normal(state_pair.dd), actx) + nhat = actx.thaw(discr.normal(state_pair.dd)) bnd_flux = flux_func(state_pair, gas_model, nhat) dd = state_pair.dd dd_allfaces = dd.with_dtag("all_faces") @@ -465,7 +464,7 @@ def test_prescribed(actx_factory, prescribed_soln, flux_func): def _boundary_state_func(discr, btag, gas_model, state_minus, **kwargs): actx = state_minus.array_context bnd_discr = discr.discr_from_dd(btag) - nodes = thaw(bnd_discr.nodes(), actx) + nodes = actx.thaw(bnd_discr.nodes()) return make_fluid_state(prescribed_soln(r=nodes, eos=gas_model.eos, **kwargs), gas_model) @@ -482,19 +481,19 @@ def _boundary_state_func(discr, btag, gas_model, state_minus, **kwargs): mesh = _get_box_mesh(dim=dim, a=a, b=b, n=npts_geom) discr = create_discretization_collection(actx, mesh, order=order) - nodes = thaw(discr.nodes(), actx) + nodes = actx.thaw(discr.nodes()) boundary_discr = discr.discr_from_dd(BTAG_ALL) - boundary_nodes = thaw(boundary_discr.nodes(), actx) + boundary_nodes = actx.thaw(boundary_discr.nodes()) expected_boundary_solution = prescribed_soln(r=boundary_nodes, eos=gas_model.eos) - nhat = thaw(discr.normal(BTAG_ALL), actx) + nhat = actx.thaw(discr.normal(BTAG_ALL)) print(f"{nhat=}") from mirgecom.flux import num_flux_central def scalar_flux_interior(int_tpair): from arraycontext import outer - normal = thaw(discr.normal(int_tpair.dd), actx) + normal = actx.thaw(discr.normal(int_tpair.dd)) # Hard-coding central per [Bassi_1997]_ eqn 13 flux_weak = outer(num_flux_central(int_tpair.int, int_tpair.ext), normal) @@ -554,7 +553,7 @@ def scalar_flux_interior(int_tpair): state_pairs = make_fluid_state_trace_pairs(cv_int_pairs, gas_model) state_pair = state_pairs[0] - nhat = thaw(discr.normal(state_pair.dd), actx) + nhat = actx.thaw(discr.normal(state_pair.dd)) bnd_flux = flux_func(state_pair, gas_model, nhat) dd = state_pair.dd dd_allfaces = dd.with_dtag("all_faces") diff --git a/test/test_diffusion.py b/test/test_diffusion.py index 9a8a9600c..9bbd60ad8 100644 --- a/test/test_diffusion.py +++ b/test/test_diffusion.py @@ -26,7 +26,6 @@ import pyopencl.clmath as clmath # noqa from pytools.obj_array import make_obj_array import pymbolic as pmbl -from arraycontext import thaw import grudge.op as op from mirgecom.symbolic import ( diff as sym_diff, @@ -169,7 +168,7 @@ def get_kappa(self, x, t, u): return self._kappa def get_boundaries(self, discr, actx, t): - nodes = thaw(discr.nodes(), actx) + nodes = actx.thaw(discr.nodes()) sym_exact_u = self.get_solution( pmbl.make_sym_vector("x", self.dim), pmbl.var("t")) @@ -183,7 +182,7 @@ def get_boundaries(self, discr, actx, t): lower_btag = DTAG_BOUNDARY("-"+str(i)) upper_btag = DTAG_BOUNDARY("+"+str(i)) upper_grad_u = op.project(discr, "vol", upper_btag, exact_grad_u) - normal = thaw(discr.normal(upper_btag), actx) + normal = actx.thaw(discr.normal(upper_btag)) upper_grad_u_dot_n = np.dot(upper_grad_u, normal) boundaries[lower_btag] = NeumannDiffusionBoundary(0.) boundaries[upper_btag] = NeumannDiffusionBoundary(upper_grad_u_dot_n) @@ -329,7 +328,7 @@ def test_diffusion_accuracy(actx_factory, problem, nsteps, dt, scales, order, discr = create_discretization_collection(actx, mesh, order) - nodes = thaw(discr.nodes(), actx) + nodes = actx.thaw(discr.nodes()) def get_rhs(t, u): kappa = p.get_kappa(nodes, t, u) @@ -391,7 +390,7 @@ def test_diffusion_discontinuous_kappa(actx_factory, order, visualize=False): discr = create_discretization_collection(actx, mesh, order) - nodes = thaw(discr.nodes(), actx) + nodes = actx.thaw(discr.nodes()) # Set up a 1D heat equation interface problem, apply the diffusion operator to # the exact steady state solution, and check that it's zero @@ -512,7 +511,7 @@ def test_diffusion_compare_to_nodal_dg(actx_factory, problem, order, discr_mirgecom = create_discretization_collection(actx, mesh, order=order) - nodes_mirgecom = thaw(discr_mirgecom.nodes(), actx) + nodes_mirgecom = actx.thaw(discr_mirgecom.nodes()) u_mirgecom = p.get_solution(nodes_mirgecom, t) @@ -522,7 +521,7 @@ def test_diffusion_compare_to_nodal_dg(actx_factory, problem, order, u=u_mirgecom) discr_ndg = ndgctx.get_discr(actx) - nodes_ndg = thaw(discr_ndg.nodes(), actx) + nodes_ndg = actx.thaw(discr_ndg.nodes()) u_ndg = p.get_solution(nodes_ndg, t) @@ -584,7 +583,7 @@ def get_u2(x, t): discr = create_discretization_collection(actx, mesh, order=4) - nodes = thaw(discr.nodes(), actx) + nodes = actx.thaw(discr.nodes()) t = 1.23456789 diff --git a/test/test_eos.py b/test/test_eos.py index 65b82bc2d..1109ee67b 100644 --- a/test/test_eos.py +++ b/test/test_eos.py @@ -200,8 +200,7 @@ def test_pyrometheus_eos(ctx_factory, mechname, dim, y0, vel): logger.info(f"Number of elements {mesh.nelements}") discr = create_discretization_collection(actx, mesh, order=order) - from meshmode.dof_array import thaw - nodes = thaw(actx, discr.nodes()) + nodes = actx.thaw(discr.nodes()) # Pyrometheus initialization mech_cti = get_mechanism_cti(mechname) @@ -410,8 +409,7 @@ def test_idealsingle_lump(ctx_factory, dim): logger.info(f"Number of elements {mesh.nelements}") discr = create_discretization_collection(actx, mesh, order=order) - from meshmode.dof_array import thaw - nodes = thaw(actx, discr.nodes()) + nodes = actx.thaw(discr.nodes()) # Init soln with Vortex center = np.zeros(shape=(dim,)) @@ -466,8 +464,7 @@ def test_idealsingle_vortex(ctx_factory): logger.info(f"Number of elements {mesh.nelements}") discr = create_discretization_collection(actx, mesh, order=order) - from meshmode.dof_array import thaw - nodes = thaw(actx, discr.nodes()) + nodes = actx.thaw(discr.nodes()) eos = IdealSingleGas() # Init soln with Vortex vortex = Vortex2D() diff --git a/test/test_euler.py b/test/test_euler.py index a5d90f192..3cb68e3e7 100644 --- a/test/test_euler.py +++ b/test/test_euler.py @@ -38,7 +38,6 @@ make_obj_array, ) -from arraycontext import thaw from meshmode.mesh import BTAG_ALL, BTAG_NONE # noqa from mirgecom.euler import euler_operator from mirgecom.fluid import make_conserved @@ -263,7 +262,7 @@ def test_vortex_rhs(actx_factory, order, use_overintegration, numerical_flux_fun else: quadrature_tag = None - nodes = thaw(discr.nodes(), actx) + nodes = actx.thaw(discr.nodes()) # Init soln with Vortex and expected RHS = 0 vortex = Vortex2D(center=[0, 0], velocity=[0, 0]) @@ -274,7 +273,7 @@ def test_vortex_rhs(actx_factory, order, use_overintegration, numerical_flux_fun def _vortex_boundary(discr, btag, gas_model, state_minus, **kwargs): actx = state_minus.array_context bnd_discr = discr.discr_from_dd(btag) - nodes = thaw(bnd_discr.nodes(), actx) + nodes = actx.thaw(bnd_discr.nodes()) return make_fluid_state(vortex(x_vec=nodes, **kwargs), gas_model) boundaries = { @@ -341,7 +340,7 @@ def test_lump_rhs(actx_factory, dim, order, use_overintegration, else: quadrature_tag = None - nodes = thaw(discr.nodes(), actx) + nodes = actx.thaw(discr.nodes()) # Init soln with Lump and expected RHS = 0 center = np.zeros(shape=(dim,)) @@ -354,7 +353,7 @@ def test_lump_rhs(actx_factory, dim, order, use_overintegration, def _lump_boundary(discr, btag, gas_model, state_minus, **kwargs): actx = state_minus.array_context bnd_discr = discr.discr_from_dd(btag) - nodes = thaw(bnd_discr.nodes(), actx) + nodes = actx.thaw(bnd_discr.nodes()) return make_fluid_state(lump(x_vec=nodes, cv=state_minus, **kwargs), gas_model) @@ -428,7 +427,7 @@ def test_multilump_rhs(actx_factory, dim, order, v0, use_overintegration, else: quadrature_tag = None - nodes = thaw(discr.nodes(), actx) + nodes = actx.thaw(discr.nodes()) centers = make_obj_array([np.zeros(shape=(dim,)) for i in range(nspecies)]) spec_y0s = np.ones(shape=(nspecies,)) @@ -449,7 +448,7 @@ def test_multilump_rhs(actx_factory, dim, order, v0, use_overintegration, def _my_boundary(discr, btag, gas_model, state_minus, **kwargs): actx = state_minus.array_context bnd_discr = discr.discr_from_dd(btag) - nodes = thaw(bnd_discr.nodes(), actx) + nodes = actx.thaw(bnd_discr.nodes()) return make_fluid_state(lump(x_vec=nodes, **kwargs), gas_model) boundaries = { @@ -521,7 +520,7 @@ def _euler_flow_stepper(actx, parameters): else: quadrature_tag = None - nodes = thaw(discr.nodes(), actx) + nodes = actx.thaw(discr.nodes()) cv = initializer(nodes) gas_model = GasModel(eos=eos) @@ -668,7 +667,7 @@ def test_isentropic_vortex(actx_factory, order, use_overintegration, def _vortex_boundary(discr, btag, state_minus, gas_model, **kwargs): actx = state_minus.array_context bnd_discr = discr.discr_from_dd(btag) - nodes = thaw(bnd_discr.nodes(), actx) + nodes = actx.thaw(bnd_discr.nodes()) return make_fluid_state(initializer(x_vec=nodes, **kwargs), gas_model) boundaries = { diff --git a/test/test_filter.py b/test/test_filter.py index 668c40992..de2e469ce 100644 --- a/test/test_filter.py +++ b/test/test_filter.py @@ -30,7 +30,6 @@ import numpy as np from functools import partial -from meshmode.dof_array import thaw from mirgecom.discretization import create_discretization_collection import grudge.op as op from meshmode.array_context import ( # noqa @@ -39,7 +38,6 @@ from pytools.obj_array import ( make_obj_array ) -from meshmode.dof_array import thaw # noqa from mirgecom.filter import make_spectral_filter @@ -169,7 +167,7 @@ def test_filter_function(actx_factory, dim, order, do_viz=False): ) discr = create_discretization_collection(actx, mesh, order=order) - nodes = thaw(actx, discr.nodes()) + nodes = actx.thaw(discr.nodes()) # number of modes see e.g.: # JSH/TW Nodal DG Methods, Section 10.1 diff --git a/test/test_fluid.py b/test/test_fluid.py index d765584be..b59f5049b 100644 --- a/test/test_fluid.py +++ b/test/test_fluid.py @@ -33,7 +33,6 @@ from pytools.obj_array import make_obj_array -from meshmode.dof_array import thaw from mirgecom.fluid import make_conserved from mirgecom.discretization import create_discretization_collection import grudge.op as op @@ -64,7 +63,7 @@ def test_velocity_gradient_sanity(actx_factory, dim, mass_exp, vel_fac): order = 3 discr = create_discretization_collection(actx, mesh, order=order) - nodes = thaw(actx, discr.nodes()) + nodes = actx.thaw(discr.nodes()) zeros = discr.zeros(actx) ones = zeros + 1.0 @@ -113,7 +112,7 @@ def test_velocity_gradient_eoc(actx_factory, dim): ) discr = create_discretization_collection(actx, mesh, order=order) - nodes = thaw(actx, discr.nodes()) + nodes = actx.thaw(discr.nodes()) zeros = discr.zeros(actx) mass = nodes[dim-1]*nodes[dim-1] @@ -161,7 +160,7 @@ def test_velocity_gradient_structure(actx_factory): order = 1 discr = create_discretization_collection(actx, mesh, order=order) - nodes = thaw(actx, discr.nodes()) + nodes = actx.thaw(discr.nodes()) zeros = discr.zeros(actx) ones = zeros + 1.0 @@ -210,7 +209,7 @@ def test_species_mass_gradient(actx_factory, dim): order = 1 discr = create_discretization_collection(actx, mesh, order=order) - nodes = thaw(actx, discr.nodes()) + nodes = actx.thaw(discr.nodes()) zeros = discr.zeros(actx) ones = zeros + 1 diff --git a/test/test_init.py b/test/test_init.py index 05a02f2e1..57dc43695 100644 --- a/test/test_init.py +++ b/test/test_init.py @@ -32,7 +32,6 @@ import pytest from meshmode.array_context import PyOpenCLArrayContext -from meshmode.dof_array import thaw from meshmode.mesh import BTAG_ALL, BTAG_NONE # noqa from mirgecom.initializers import Vortex2D @@ -75,7 +74,7 @@ def test_uniform_init(ctx_factory, dim, nspecies): logger.info(f"Number of elements: {mesh.nelements}") discr = create_discretization_collection(actx, mesh, order=order) - nodes = thaw(actx, discr.nodes()) + nodes = actx.thaw(discr.nodes()) velocity = np.ones(shape=(dim,)) from mirgecom.initializers import Uniform @@ -130,7 +129,7 @@ def test_lump_init(ctx_factory): logger.info(f"Number of elements: {mesh.nelements}") discr = create_discretization_collection(actx, mesh, order=order) - nodes = thaw(actx, discr.nodes()) + nodes = actx.thaw(discr.nodes()) # Init soln with Vortex center = np.zeros(shape=(dim,)) @@ -171,7 +170,7 @@ def test_vortex_init(ctx_factory): logger.info(f"Number of elements: {mesh.nelements}") discr = create_discretization_collection(actx, mesh, order=order) - nodes = thaw(actx, discr.nodes()) + nodes = actx.thaw(discr.nodes()) # Init soln with Vortex vortex = Vortex2D() @@ -209,7 +208,7 @@ def test_shock_init(ctx_factory): print(f"Number of elements: {mesh.nelements}") discr = create_discretization_collection(actx, mesh, order=order) - nodes = thaw(actx, discr.nodes()) + nodes = actx.thaw(discr.nodes()) initr = SodShock1D() initsoln = initr(time=0.0, x_vec=nodes) @@ -248,7 +247,7 @@ def test_uniform(ctx_factory, dim): print(f"Number of elements: {mesh.nelements}") discr = create_discretization_collection(actx, mesh, order=order) - nodes = thaw(actx, discr.nodes()) + nodes = actx.thaw(discr.nodes()) print(f"DIM = {dim}, {len(nodes)}") print(f"Nodes={nodes}") @@ -293,7 +292,7 @@ def test_pulse(ctx_factory, dim): print(f"Number of elements: {mesh.nelements}") discr = create_discretization_collection(actx, mesh, order=order) - nodes = thaw(actx, discr.nodes()) + nodes = actx.thaw(discr.nodes()) print(f"DIM = {dim}, {len(nodes)}") print(f"Nodes={nodes}") @@ -356,7 +355,7 @@ def test_multilump(ctx_factory, dim): logger.info(f"Number of elements: {mesh.nelements}") discr = create_discretization_collection(actx, mesh, order=order) - nodes = thaw(actx, discr.nodes()) + nodes = actx.thaw(discr.nodes()) rho0 = 1.5 centers = make_obj_array([np.zeros(shape=(dim,)) for i in range(nspecies)]) diff --git a/test/test_inviscid.py b/test/test_inviscid.py index d802dbc86..0c2ed83eb 100644 --- a/test/test_inviscid.py +++ b/test/test_inviscid.py @@ -36,7 +36,6 @@ make_obj_array, ) -from arraycontext import thaw from meshmode.mesh import BTAG_ALL, BTAG_NONE # noqa from grudge.trace_pair import TracePair from mirgecom.fluid import make_conserved @@ -175,7 +174,7 @@ def test_inviscid_flux_components(actx_factory, dim): # the expected values (and p0 within tolerance) # === with V = 0, fixed P = p0 tolerance = 1e-15 - nodes = thaw(discr.nodes(), actx) + nodes = actx.thaw(discr.nodes()) mass = discr.zeros(actx) + np.dot(nodes, nodes) + 1.0 mom = make_obj_array([discr.zeros(actx) for _ in range(dim)]) p_exact = discr.zeros(actx) + p0 @@ -232,7 +231,7 @@ def test_inviscid_mom_flux_components(actx_factory, dim, livedim): order = 3 discr = create_discretization_collection(actx, mesh, order=order) - nodes = thaw(discr.nodes(), actx) + nodes = actx.thaw(discr.nodes()) tolerance = 1e-15 for livedim in range(dim): @@ -331,7 +330,7 @@ def test_facial_flux(actx_factory, nspecies, order, dim, num_flux): state_tpairs = make_fluid_state_trace_pairs(cv_interior_pairs, gas_model) interior_state_pair = state_tpairs[0] - nhat = thaw(discr.normal(interior_state_pair.dd), actx) + nhat = actx.thaw(discr.normal(interior_state_pair.dd)) bnd_flux = num_flux(interior_state_pair, gas_model, nhat) dd = interior_state_pair.dd dd_allfaces = dd.with_dtag("all_faces") @@ -358,7 +357,7 @@ def inf_norm(data): # (Explanation courtesy of Mike Campbell, # https://github.com/illinois-ceesd/mirgecom/pull/44#discussion_r463304292) - nhat = thaw(discr.normal("int_faces"), actx) + nhat = actx.thaw(discr.normal("int_faces")) mom_flux_exact = op.project(discr, "int_faces", "all_faces", p0*nhat) print(f"{mom_flux_exact=}") print(f"{interior_face_flux.momentum=}") @@ -380,7 +379,7 @@ def inf_norm(data): interior=make_fluid_state(dir_bval, gas_model), exterior=make_fluid_state(dir_bc, gas_model)) - nhat = thaw(discr.normal(state_tpair.dd), actx) + nhat = actx.thaw(discr.normal(state_tpair.dd)) bnd_flux = num_flux(state_tpair, gas_model, nhat) dd = state_tpair.dd dd_allfaces = dd.with_dtag("all_faces") @@ -390,7 +389,7 @@ def inf_norm(data): assert inf_norm(boundary_flux.energy) < tolerance assert inf_norm(boundary_flux.species_mass) < tolerance - nhat = thaw(discr.normal(BTAG_ALL), actx) + nhat = actx.thaw(discr.normal(BTAG_ALL)) mom_flux_exact = op.project(discr, BTAG_ALL, "all_faces", p0*nhat) momerr = inf_norm(boundary_flux.momentum - mom_flux_exact) assert momerr < tolerance diff --git a/test/test_lazy.py b/test/test_lazy.py index ec874ef06..17cc95d17 100644 --- a/test/test_lazy.py +++ b/test/test_lazy.py @@ -29,7 +29,6 @@ import pyopencl.tools as cl_tools import pyopencl.array as cla # noqa import pyopencl.clmath as clmath # noqa -from arraycontext import freeze, thaw from meshmode.array_context import ( # noqa PyOpenCLArrayContext, PytatoPyOpenCLArrayContext @@ -80,14 +79,13 @@ def get_discr(order): def _isclose(discr, x, y, rel_tol=1e-9, abs_tol=0, return_operands=False): from mirgecom.simutil import componentwise_norms - from arraycontext import flatten actx = x.array_context - lhs = actx.to_numpy(flatten(componentwise_norms(discr, x - y, np.inf), actx)) + lhs = actx.to_numpy(actx.flatten(componentwise_norms(discr, x - y, np.inf))) rhs = np.maximum( rel_tol * np.maximum( - actx.to_numpy(flatten(componentwise_norms(discr, x, np.inf), actx)), - actx.to_numpy(flatten(componentwise_norms(discr, y, np.inf), actx))), + actx.to_numpy(actx.flatten(componentwise_norms(discr, x, np.inf))), + actx.to_numpy(actx.flatten(componentwise_norms(discr, y, np.inf)))), abs_tol) is_close = np.all(lhs <= rhs) @@ -138,7 +136,7 @@ def test_lazy_op_divergence(op_test_data, order): def get_flux(u_tpair): dd = u_tpair.dd dd_allfaces = dd.with_dtag("all_faces") - normal = thaw(discr.normal(dd), u_tpair.int[0].array_context) + normal = u_tpair.int.array_context.thaw(discr.normal(dd)) flux = u_tpair.avg @ normal return op.project(discr, dd, dd_allfaces, flux) @@ -149,7 +147,7 @@ def div_op(u): lazy_op = lazy_actx.compile(div_op) def get_inputs(actx): - nodes = thaw(discr.nodes(), actx) + nodes = actx.thaw(discr.nodes()) u = make_obj_array([actx.np.sin(np.pi*nodes[i]) for i in range(2)]) return u, @@ -158,7 +156,7 @@ def get_inputs(actx): _isclose, discr, rel_tol=tol, abs_tol=tol, return_operands=True) def lazy_to_eager(u): - return thaw(freeze(u, lazy_actx), eager_actx) + return eager_actx.thaw(lazy_actx.freeze(u)) eager_result = div_op(*get_inputs(eager_actx)) lazy_result = lazy_to_eager(lazy_op(*get_inputs(lazy_actx))) @@ -189,7 +187,7 @@ def diffusion_op(kappa, u): lazy_op = lazy_actx.compile(diffusion_op) def get_inputs(actx): - nodes = thaw(discr.nodes(), actx) + nodes = actx.thaw(discr.nodes()) kappa = discr.zeros(actx) + 1 u = actx.np.cos(np.pi*nodes[0]) return kappa, u @@ -199,7 +197,7 @@ def get_inputs(actx): _isclose, discr, rel_tol=tol, abs_tol=tol, return_operands=True) def lazy_to_eager(u): - return thaw(freeze(u, lazy_actx), eager_actx) + return eager_actx.thaw(lazy_actx.freeze(u)) eager_result = diffusion_op(*get_inputs(eager_actx)) lazy_result = lazy_to_eager(lazy_op(*get_inputs(lazy_actx))) @@ -241,7 +239,7 @@ def _get_scalar_lump(): def _my_boundary(discr, btag, gas_model, state_minus, **kwargs): actx = state_minus.array_context bnd_discr = discr.discr_from_dd(btag) - nodes = thaw(bnd_discr.nodes(), actx) + nodes = actx.thaw(bnd_discr.nodes()) return make_fluid_state(init(x_vec=nodes, eos=gas_model.eos, **kwargs), gas_model) @@ -277,7 +275,7 @@ def euler_op(state): lazy_op = lazy_actx.compile(euler_op) def get_inputs(actx): - nodes = thaw(discr.nodes(), actx) + nodes = actx.thaw(discr.nodes()) state = init(nodes) return state, @@ -285,7 +283,7 @@ def get_inputs(actx): _isclose, discr, rel_tol=tol, abs_tol=tol, return_operands=True) def lazy_to_eager(u): - return thaw(freeze(u, lazy_actx), eager_actx) + return eager_actx.thaw(lazy_actx.freeze(u)) eager_result = euler_op(*get_inputs(eager_actx)) lazy_result = lazy_to_eager(lazy_op(*get_inputs(lazy_actx))) diff --git a/test/test_navierstokes.py b/test/test_navierstokes.py index 2d610d248..6a1080b43 100644 --- a/test/test_navierstokes.py +++ b/test/test_navierstokes.py @@ -36,7 +36,6 @@ make_obj_array, ) -from arraycontext import thaw from meshmode.mesh import BTAG_ALL, BTAG_NONE # noqa from mirgecom.navierstokes import ns_operator from mirgecom.fluid import make_conserved @@ -299,7 +298,7 @@ def _boundary_state_func(discr, btag, gas_model, state_minus, time=0, **kwargs): actx = state_minus.array_context bnd_discr = discr.discr_from_dd(btag) - nodes = thaw(bnd_discr.nodes(), actx) + nodes = actx.thaw(bnd_discr.nodes()) return make_fluid_state(self.get_solution(x=nodes, t=time), gas_model) return {BTAG_ALL: @@ -629,7 +628,7 @@ def test_exact_mms(actx_factory, order, dim, manufactured_soln, mu): from mirgecom.discretization import create_discretization_collection discr = create_discretization_collection(actx, mesh, order) - nodes = thaw(discr.nodes(), actx) + nodes = actx.thaw(discr.nodes()) source_eval = evaluate(sym_source, t=0, x=nodes) @@ -681,7 +680,7 @@ def _boundary_state_func(discr, btag, gas_model, state_minus, time=0, **kwargs): actx = state_minus.array_context bnd_discr = discr.discr_from_dd(btag) - nodes = thaw(bnd_discr.nodes(), actx) + nodes = actx.thaw(bnd_discr.nodes()) boundary_cv = exact_soln(x=nodes) return make_fluid_state(boundary_cv, gas_model) @@ -708,7 +707,7 @@ def _boundary_state_func(discr, btag, gas_model, state_minus, time=0, from grudge.dt_utils import h_max_from_volume h_max = actx.to_numpy(h_max_from_volume(discr)) - nodes = thaw(discr.nodes(), actx) + nodes = actx.thaw(discr.nodes()) print(f"{nodes=}") cv_exact = exact_soln(x=nodes) @@ -898,7 +897,7 @@ def test_roy_mms(actx_factory, order, dim, u_0, v_0, w_0, a_r, a_p, a_u, mesh = man_soln.get_mesh(n) discr = create_discretization_collection(actx, mesh, order) - nodes = thaw(discr.nodes(), actx) + nodes = actx.thaw(discr.nodes()) from grudge.dt_utils import characteristic_lengthscales char_len = actx.to_numpy( @@ -937,7 +936,7 @@ def _boundary_state_func(discr, btag, gas_model, state_minus, time=0, **kwargs): actx = state_minus.array_context bnd_discr = discr.discr_from_dd(btag) - nodes = thaw(bnd_discr.nodes(), actx) + nodes = actx.thaw(bnd_discr.nodes()) boundary_cv = evaluate(sym_cv, x=nodes, t=time) return make_fluid_state(boundary_cv, gas_model) diff --git a/test/test_operators.py b/test/test_operators.py index 7904ae75c..5e5b8761a 100644 --- a/test/test_operators.py +++ b/test/test_operators.py @@ -34,7 +34,6 @@ from pytools.obj_array import make_obj_array import pymbolic as pmbl # noqa import pymbolic.primitives as prim -from arraycontext import thaw from meshmode.mesh import BTAG_ALL from mirgecom.flux import num_flux_central from mirgecom.fluid import ( @@ -122,7 +121,7 @@ def _cv_test_func(dim): def central_flux_interior(actx, discr, int_tpair): """Compute a central flux for interior faces.""" - normal = thaw(discr.normal(int_tpair.dd), actx) + normal = actx.thaw(discr.normal(int_tpair.dd)) from arraycontext import outer flux_weak = outer(num_flux_central(int_tpair.int, int_tpair.ext), normal) dd_all_faces = int_tpair.dd.with_dtag("all_faces") @@ -132,9 +131,9 @@ def central_flux_interior(actx, discr, int_tpair): def central_flux_boundary(actx, discr, soln_func, btag): """Compute a central flux for boundary faces.""" boundary_discr = discr.discr_from_dd(btag) - bnd_nodes = thaw(boundary_discr.nodes(), actx) + bnd_nodes = actx.thaw(boundary_discr.nodes()) soln_bnd = soln_func(x_vec=bnd_nodes) - bnd_nhat = thaw(discr.normal(btag), actx) + bnd_nhat = actx.thaw(discr.normal(btag)) from grudge.trace_pair import TracePair bnd_tpair = TracePair(btag, interior=soln_bnd, exterior=soln_bnd) from arraycontext import outer @@ -201,7 +200,7 @@ def sym_eval(expr, x_vec): test_func = partial(sym_eval, sym_test_func) grad_test_func = partial(sym_eval, sym.grad(dim, sym_test_func)) - nodes = thaw(discr.nodes(), actx) + nodes = actx.thaw(discr.nodes()) int_flux = partial(central_flux_interior, actx, discr) bnd_flux = partial(central_flux_boundary, actx, discr, test_func) @@ -209,10 +208,8 @@ def sym_eval(expr, x_vec): exact_grad = grad_test_func(nodes) from mirgecom.simutil import componentwise_norms - from arraycontext import flatten - err_scale = max(flatten(componentwise_norms(discr, exact_grad, np.inf), - actx)) + err_scale = max(actx.flatten(componentwise_norms(discr, exact_grad, np.inf))) if err_scale <= 1e-16: err_scale = 1 @@ -234,8 +231,9 @@ def sym_eval(expr, x_vec): print(f"{test_grad=}") grad_err = \ - max(flatten(componentwise_norms(discr, test_grad - exact_grad, np.inf), - actx)) / err_scale + max(actx.flatten( + componentwise_norms(discr, test_grad - exact_grad, np.inf)) + / err_scale) eoc.add_data_point(actx.to_numpy(h_max), actx.to_numpy(grad_err)) diff --git a/test/test_restart.py b/test/test_restart.py index 30931c1e9..773d50d73 100644 --- a/test/test_restart.py +++ b/test/test_restart.py @@ -50,8 +50,7 @@ def test_restart_cv(actx_factory, nspecies): ) order = 3 discr = create_discretization_collection(actx, mesh, order=order) - from meshmode.dof_array import thaw - nodes = thaw(actx, discr.nodes()) + nodes = actx.thaw(discr.nodes()) mass = nodes[0] energy = nodes[1] diff --git a/test/test_simutil.py b/test/test_simutil.py index 6756bdbde..7dafae2d0 100644 --- a/test/test_simutil.py +++ b/test/test_simutil.py @@ -28,8 +28,6 @@ import pytest # noqa from arraycontext import ( # noqa - thaw, - flatten, pytest_generate_tests_for_pyopencl_array_context as pytest_generate_tests ) @@ -53,7 +51,7 @@ def test_basic_cfd_healthcheck(actx_factory): order = 3 discr = create_discretization_collection(actx, mesh, order=order) - nodes = thaw(discr.nodes(), actx) + nodes = actx.thaw(discr.nodes()) zeros = discr.zeros(actx) ones = zeros + 1.0 @@ -122,7 +120,7 @@ def test_analytic_comparison(actx_factory): order = 2 discr = create_discretization_collection(actx, mesh, order=order) - nodes = thaw(discr.nodes(), actx) + nodes = actx.thaw(discr.nodes()) zeros = discr.zeros(actx) ones = zeros + 1.0 mass = ones @@ -136,7 +134,7 @@ def test_analytic_comparison(actx_factory): resid = vortex_soln - cv expected_errors = actx.to_numpy( - flatten(componentwise_norms(discr, resid, order=np.inf), actx)).tolist() + actx.flatten(componentwise_norms(discr, resid, order=np.inf))).tolist() errors = compare_fluid_solutions(discr, cv, cv) assert max(errors) == 0 diff --git a/test/test_symbolic.py b/test/test_symbolic.py index 36144cda7..0d684dad0 100644 --- a/test/test_symbolic.py +++ b/test/test_symbolic.py @@ -25,7 +25,6 @@ import pyopencl.clmath as clmath # noqa from pytools.obj_array import make_obj_array import pymbolic as pmbl -from meshmode.dof_array import thaw from meshmode.mesh.generation import generate_regular_rect_mesh import mirgecom.symbolic as sym from mirgecom.discretization import create_discretization_collection @@ -301,7 +300,7 @@ def test_symbolic_evaluation(actx_factory): discr = create_discretization_collection(actx, mesh, order=2) - nodes = thaw(actx, discr.nodes()) + nodes = actx.thaw(discr.nodes()) sym_coords = pmbl.make_sym_vector("x", 2) diff --git a/test/test_viscous.py b/test/test_viscous.py index c3c284dd7..0a1963417 100644 --- a/test/test_viscous.py +++ b/test/test_viscous.py @@ -32,7 +32,6 @@ import pytest # noqa from pytools.obj_array import make_obj_array -from meshmode.dof_array import thaw from meshmode.mesh import BTAG_ALL import grudge.op as op from grudge.trace_pair import interior_trace_pairs @@ -71,7 +70,7 @@ def test_viscous_stress_tensor(actx_factory, transport_model): order = 1 discr = create_discretization_collection(actx, mesh, order=order) - nodes = thaw(actx, discr.nodes()) + nodes = actx.thaw(discr.nodes()) zeros = discr.zeros(actx) ones = zeros + 1.0 @@ -168,7 +167,7 @@ def _elbnd_flux(discr, compute_interior_flux, compute_boundary_flux, from mirgecom.flux import num_flux_central def cv_flux_interior(int_tpair): - normal = thaw(actx, discr.normal(int_tpair.dd)) + normal = actx.thaw(discr.normal(int_tpair.dd)) from arraycontext import outer flux_weak = outer(num_flux_central(int_tpair.int, int_tpair.ext), normal) dd_all_faces = int_tpair.dd.with_dtag("all_faces") @@ -176,9 +175,9 @@ def cv_flux_interior(int_tpair): def cv_flux_boundary(btag): boundary_discr = discr.discr_from_dd(btag) - bnd_nodes = thaw(actx, boundary_discr.nodes()) + bnd_nodes = actx.thaw(boundary_discr.nodes()) cv_bnd = initializer(x_vec=bnd_nodes, eos=eos) - bnd_nhat = thaw(actx, discr.normal(btag)) + bnd_nhat = actx.thaw(discr.normal(btag)) from grudge.trace_pair import TracePair bnd_tpair = TracePair(btag, interior=cv_bnd, exterior=cv_bnd) from arraycontext import outer @@ -198,7 +197,7 @@ def cv_flux_boundary(btag): ) discr = create_discretization_collection(actx, mesh, order=order) - nodes = thaw(actx, discr.nodes()) + nodes = actx.thaw(discr.nodes()) def inf_norm(x): return actx.to_numpy(op.norm(discr, x, np.inf)) @@ -300,7 +299,7 @@ def test_species_diffusive_flux(actx_factory): order = 1 discr = create_discretization_collection(actx, mesh, order=order) - nodes = thaw(actx, discr.nodes()) + nodes = actx.thaw(discr.nodes()) zeros = discr.zeros(actx) ones = zeros + 1.0 @@ -376,7 +375,7 @@ def test_diffusive_heat_flux(actx_factory): order = 1 discr = create_discretization_collection(actx, mesh, order=order) - nodes = thaw(actx, discr.nodes()) + nodes = actx.thaw(discr.nodes()) zeros = discr.zeros(actx) ones = zeros + 1.0 @@ -452,7 +451,7 @@ def test_local_max_species_diffusivity(actx_factory, dim, array_valued): order = 1 discr = create_discretization_collection(actx, mesh, order=order) - nodes = thaw(actx, discr.nodes()) + nodes = actx.thaw(discr.nodes()) zeros = discr.zeros(actx) ones = zeros + 1.0 vel = .32 diff --git a/test/test_wave.py b/test/test_wave.py index c51aefa4c..10bf1e8e8 100644 --- a/test/test_wave.py +++ b/test/test_wave.py @@ -28,7 +28,6 @@ import pymbolic.primitives as prim import mirgecom.symbolic as sym from mirgecom.wave import wave_operator -from meshmode.dof_array import thaw from mirgecom.discretization import create_discretization_collection import grudge.op as op @@ -167,7 +166,7 @@ def test_wave_accuracy(actx_factory, problem, order, visualize=False): discr = create_discretization_collection(actx, mesh, order=order) - nodes = thaw(actx, discr.nodes()) + nodes = actx.thaw(discr.nodes()) def sym_eval(expr, t): return sym.EvaluationMapper({"c": p.c, "x": nodes, "t": t})(expr) @@ -230,7 +229,7 @@ def test_wave_stability(actx_factory, problem, timestep_scale, order, discr = create_discretization_collection(actx, mesh, order=order) - nodes = thaw(actx, discr.nodes()) + nodes = actx.thaw(discr.nodes()) def sym_eval(expr, t): return sym.EvaluationMapper({"c": p.c, "x": nodes, "t": t})(expr) From 0eb1d6ba9547c07021d87f8a6dec9af2be6fc9e9 Mon Sep 17 00:00:00 2001 From: Michael Campbell Date: Wed, 29 Jun 2022 11:06:18 -0500 Subject: [PATCH 2/4] Remove lingering imports --- examples/autoignition-mpi.py | 1 - examples/doublemach-mpi.py | 1 - examples/heat-source-mpi.py | 1 - examples/hotplate-mpi.py | 1 - examples/lump-mpi.py | 1 - examples/mixture-mpi.py | 1 - examples/nsmix-mpi.py | 1 - examples/poiseuille-mpi.py | 1 - examples/pulse-mpi.py | 1 - examples/scalar-lump-mpi.py | 1 - examples/sod-mpi.py | 1 - examples/vortex-mpi.py | 1 - 12 files changed, 12 deletions(-) diff --git a/examples/autoignition-mpi.py b/examples/autoignition-mpi.py index f07775b0e..e025288a8 100644 --- a/examples/autoignition-mpi.py +++ b/examples/autoignition-mpi.py @@ -51,7 +51,6 @@ from mirgecom.initializers import MixtureInitializer from mirgecom.eos import PyrometheusMixture from mirgecom.gas_model import GasModel -from arraycontext import thaw from mirgecom.logging_quantities import ( initialize_logmgr, diff --git a/examples/doublemach-mpi.py b/examples/doublemach-mpi.py index c2eaa3321..bc7abd24b 100644 --- a/examples/doublemach-mpi.py +++ b/examples/doublemach-mpi.py @@ -30,7 +30,6 @@ import pyopencl.tools as cl_tools from functools import partial -from arraycontext import thaw from meshmode.mesh import BTAG_ALL, BTAG_NONE # noqa from grudge.dof_desc import DTAG_BOUNDARY from grudge.shortcuts import make_visualizer diff --git a/examples/heat-source-mpi.py b/examples/heat-source-mpi.py index 467df04b5..f8e2859c2 100644 --- a/examples/heat-source-mpi.py +++ b/examples/heat-source-mpi.py @@ -122,7 +122,6 @@ def main(actx_class, ctx_factory=cl.create_some_context, use_logmgr=True, source_width = 0.2 - from arraycontext import thaw nodes = actx.thaw(discr.nodes()) boundaries = { diff --git a/examples/hotplate-mpi.py b/examples/hotplate-mpi.py index 0f35353fd..4cd7247ea 100644 --- a/examples/hotplate-mpi.py +++ b/examples/hotplate-mpi.py @@ -29,7 +29,6 @@ import pyopencl.tools as cl_tools from functools import partial -from arraycontext import thaw from meshmode.mesh import BTAG_ALL, BTAG_NONE # noqa from grudge.shortcuts import make_visualizer diff --git a/examples/lump-mpi.py b/examples/lump-mpi.py index 0f5bbe570..2f6c53335 100644 --- a/examples/lump-mpi.py +++ b/examples/lump-mpi.py @@ -29,7 +29,6 @@ import pyopencl.tools as cl_tools from functools import partial -from arraycontext import thaw from meshmode.mesh import BTAG_ALL, BTAG_NONE # noqa from grudge.shortcuts import make_visualizer diff --git a/examples/mixture-mpi.py b/examples/mixture-mpi.py index bd9f25eea..cd20ed7b6 100644 --- a/examples/mixture-mpi.py +++ b/examples/mixture-mpi.py @@ -29,7 +29,6 @@ import pyopencl.tools as cl_tools from functools import partial -from arraycontext import thaw from meshmode.mesh import BTAG_ALL, BTAG_NONE # noqa from grudge.shortcuts import make_visualizer diff --git a/examples/nsmix-mpi.py b/examples/nsmix-mpi.py index 0093f3833..f1655ff5f 100644 --- a/examples/nsmix-mpi.py +++ b/examples/nsmix-mpi.py @@ -35,7 +35,6 @@ PytatoPyOpenCLArrayContext ) from mirgecom.profiling import PyOpenCLProfilingArrayContext -from arraycontext import thaw from meshmode.mesh import BTAG_ALL, BTAG_NONE # noqa from grudge.shortcuts import make_visualizer diff --git a/examples/poiseuille-mpi.py b/examples/poiseuille-mpi.py index 7f0db1cd6..1258984d5 100644 --- a/examples/poiseuille-mpi.py +++ b/examples/poiseuille-mpi.py @@ -35,7 +35,6 @@ PytatoPyOpenCLArrayContext ) from mirgecom.profiling import PyOpenCLProfilingArrayContext -from arraycontext import thaw from meshmode.mesh import BTAG_ALL, BTAG_NONE # noqa from grudge.shortcuts import make_visualizer diff --git a/examples/pulse-mpi.py b/examples/pulse-mpi.py index f74468e56..9069cedda 100644 --- a/examples/pulse-mpi.py +++ b/examples/pulse-mpi.py @@ -31,7 +31,6 @@ import pyopencl as cl import pyopencl.tools as cl_tools -from arraycontext import thaw from meshmode.mesh import BTAG_ALL, BTAG_NONE # noqa from grudge.shortcuts import make_visualizer from grudge.dof_desc import DISCR_TAG_QUAD diff --git a/examples/scalar-lump-mpi.py b/examples/scalar-lump-mpi.py index 475ba9699..31eb0f01b 100644 --- a/examples/scalar-lump-mpi.py +++ b/examples/scalar-lump-mpi.py @@ -30,7 +30,6 @@ from functools import partial from pytools.obj_array import make_obj_array -from arraycontext import thaw from meshmode.mesh import BTAG_ALL, BTAG_NONE # noqa from grudge.shortcuts import make_visualizer diff --git a/examples/sod-mpi.py b/examples/sod-mpi.py index 61b85f605..c75ad2d5b 100644 --- a/examples/sod-mpi.py +++ b/examples/sod-mpi.py @@ -29,7 +29,6 @@ import pyopencl.tools as cl_tools from functools import partial -from arraycontext import thaw from meshmode.mesh import BTAG_ALL, BTAG_NONE # noqa from grudge.shortcuts import make_visualizer diff --git a/examples/vortex-mpi.py b/examples/vortex-mpi.py index 7a67c5954..d7ebc00bf 100644 --- a/examples/vortex-mpi.py +++ b/examples/vortex-mpi.py @@ -29,7 +29,6 @@ import pyopencl.tools as cl_tools from functools import partial -from arraycontext import thaw from meshmode.mesh import BTAG_ALL, BTAG_NONE # noqa from grudge.shortcuts import make_visualizer From 00f7e0e24c8493777f74f5779e79b67226215386 Mon Sep 17 00:00:00 2001 From: Michael Campbell Date: Wed, 29 Jun 2022 19:59:00 -0500 Subject: [PATCH 3/4] Use actx freeze and thaw. --- test/test_lazy.py | 11 +++++++---- test/test_operators.py | 10 ++++++---- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/test/test_lazy.py b/test/test_lazy.py index 17cc95d17..8b22e6981 100644 --- a/test/test_lazy.py +++ b/test/test_lazy.py @@ -79,13 +79,14 @@ def get_discr(order): def _isclose(discr, x, y, rel_tol=1e-9, abs_tol=0, return_operands=False): from mirgecom.simutil import componentwise_norms + from arraycontext import flatten actx = x.array_context - lhs = actx.to_numpy(actx.flatten(componentwise_norms(discr, x - y, np.inf))) + lhs = actx.to_numpy(flatten(componentwise_norms(discr, x - y, np.inf), actx)) rhs = np.maximum( rel_tol * np.maximum( - actx.to_numpy(actx.flatten(componentwise_norms(discr, x, np.inf))), - actx.to_numpy(actx.flatten(componentwise_norms(discr, y, np.inf)))), + actx.to_numpy(flatten(componentwise_norms(discr, x, np.inf), actx)), + actx.to_numpy(flatten(componentwise_norms(discr, y, np.inf), actx))), abs_tol) is_close = np.all(lhs <= rhs) @@ -136,7 +137,9 @@ def test_lazy_op_divergence(op_test_data, order): def get_flux(u_tpair): dd = u_tpair.dd dd_allfaces = dd.with_dtag("all_faces") - normal = u_tpair.int.array_context.thaw(discr.normal(dd)) + normal = discr.normal(dd) + actx = u_tpair.int[0].array_context + normal = actx.thaw(normal) flux = u_tpair.avg @ normal return op.project(discr, dd, dd_allfaces, flux) diff --git a/test/test_operators.py b/test/test_operators.py index 5e5b8761a..8488efe6e 100644 --- a/test/test_operators.py +++ b/test/test_operators.py @@ -209,7 +209,9 @@ def sym_eval(expr, x_vec): from mirgecom.simutil import componentwise_norms - err_scale = max(actx.flatten(componentwise_norms(discr, exact_grad, np.inf))) + from arraycontext import flatten + err_scale = max(flatten(componentwise_norms(discr, exact_grad, np.inf), + actx)) if err_scale <= 1e-16: err_scale = 1 @@ -231,9 +233,9 @@ def sym_eval(expr, x_vec): print(f"{test_grad=}") grad_err = \ - max(actx.flatten( - componentwise_norms(discr, test_grad - exact_grad, np.inf)) - / err_scale) + max(flatten( + componentwise_norms(discr, test_grad - exact_grad, np.inf), + actx) / err_scale) eoc.add_data_point(actx.to_numpy(h_max), actx.to_numpy(grad_err)) From c0954d411a4aa864643ebd60442ee8838609f3ea Mon Sep 17 00:00:00 2001 From: Michael Campbell Date: Wed, 29 Jun 2022 23:46:03 -0500 Subject: [PATCH 4/4] Bring back flatten funcion --- test/test_simutil.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/test_simutil.py b/test/test_simutil.py index 7dafae2d0..09d473e56 100644 --- a/test/test_simutil.py +++ b/test/test_simutil.py @@ -133,8 +133,9 @@ def test_analytic_comparison(actx_factory): cv = make_conserved(dim, mass=mass, energy=energy, momentum=mom) resid = vortex_soln - cv + from arraycontext import flatten expected_errors = actx.to_numpy( - actx.flatten(componentwise_norms(discr, resid, order=np.inf))).tolist() + flatten(componentwise_norms(discr, resid, order=np.inf), actx)).tolist() errors = compare_fluid_solutions(discr, cv, cv) assert max(errors) == 0