diff --git a/doc/support/arrays.rst b/doc/support/arrays.rst index f0a6ec268..da4797534 100644 --- a/doc/support/arrays.rst +++ b/doc/support/arrays.rst @@ -43,24 +43,25 @@ To demonstrate the effect of this, first we need some setup: .. doctest:: >>> import pyopencl as cl - >>> from arraycontext import PyOpenCLArrayContext, thaw + >>> from arraycontext import thaw + >>> from meshmode.array_context import PyOpenCLArrayContext >>> ctx = cl.create_some_context() >>> queue = cl.CommandQueue(ctx) >>> actx = PyOpenCLArrayContext(queue) >>> from meshmode.mesh.generation import generate_regular_rect_mesh >>> mesh = generate_regular_rect_mesh(a=(0, 0), b=(1, 1), nelements_per_axis=(10, 10)) - >>> from grudge import DiscretizationCollection - >>> dcoll = DiscretizationCollection(actx, mesh, order=5) + >>> from grudge import make_discretization_collection + >>> dcoll = make_discretization_collection(actx, mesh, order=5) Most quantities that are maintained by the discretization will be frozen. For example, if one wanted to grab the nodes of the mesh or normals of a named surface in the mesh: .. doctest:: - >>> from grudge.dof_desc import DOFDesc - >>> nodes = thaw(dcoll.nodes(), actx) - >>> dd = DOFDesc("all_faces") - >>> nhat = thaw(dcoll.normal(dd), actx) + >>> from grudge.dof_desc import as_dofdesc + >>> nodes = actx.thaw(dcoll.nodes()) + >>> dd = as_dofdesc("all_faces") + >>> nhat = actx.thaw(dcoll.normal(dd)) What can go wrong? Attempts to operate on frozen data will yield errors similar to the following: @@ -76,7 +77,7 @@ Fortunately, recovering from this is straightforward: .. doctest:: - >>> nodes = thaw(dcoll.nodes(), actx) + >>> nodes = actx.thaw(dcoll.nodes()) >>> result = nodes * 5 Array Containers diff --git a/examples/advdiff-tpe.py b/examples/advdiff-tpe.py index 6fb524898..fdc7586c4 100644 --- a/examples/advdiff-tpe.py +++ b/examples/advdiff-tpe.py @@ -198,7 +198,15 @@ def vol_max(x): return actx.to_numpy(nodal_max(dcoll, "vol", x))[()] from grudge.dt_utils import characteristic_lengthscales - dx = characteristic_lengthscales(actx, dcoll) + + try: + dx = characteristic_lengthscales(actx, dcoll) + except NotImplementedError: + from warnings import warn + warn("This example requires https://github.com/inducer/grudge/pull/338 . " + "Exiting.") + return + dx_min, dx_max = vol_min(dx), vol_max(dx) print(f"DX: ({dx_min}, {dx_max})") diff --git a/examples/poiseuille-tpe.py b/examples/poiseuille-tpe.py index cb9b0364c..a493f1268 100644 --- a/examples/poiseuille-tpe.py +++ b/examples/poiseuille-tpe.py @@ -426,8 +426,14 @@ def my_rhs(t, state): from mirgecom.simutil import force_evaluation current_state = force_evaluation(actx, current_state) - current_dt = get_sim_timestep(dcoll, current_state, current_t, current_dt, + try: + current_dt = get_sim_timestep(dcoll, current_state, current_t, current_dt, current_cfl, t_final, constant_cfl) + except NotImplementedError: + from warnings import warn + warn("This example requires https://github.com/inducer/grudge/pull/338 . " + "Exiting.") + return current_step, current_t, current_cv = \ advance_state(rhs=my_rhs, timestepper=timestepper, diff --git a/examples/run_examples.sh b/examples/run_examples.sh index d9e2f7ccd..cedd7f071 100755 --- a/examples/run_examples.sh +++ b/examples/run_examples.sh @@ -16,6 +16,11 @@ function endgroup { # }}} +python -c "from grudge.array_context import MPINumpyArrayConext" && numpy_actx_available=numpy || numpy_actx_available= + +echo "Numpy array context available: $numpy_actx_available" + + run_path=$(pwd) examples_dir=${1:-"./"} shift @@ -23,7 +28,7 @@ shift if [[ ! -d "${examples_dir}" ]]; then echo "Usage: run_examples.sh [list of examples]" printf "\nThis script runs examples on 2 MPI ranks (where appropriate) and\n" - printf "compares the results it gets from running with eager, lazy, and numpy\n" + printf "compares the results it gets from running with eager, lazy, and numpy (if available)\n" printf "array contexts. Users may optionally provide a list of which examples\n" printf "to run.\n\nArguments:\n" printf "\n: defaults to the current working directory.\n" @@ -93,14 +98,6 @@ do TOL_LAZY=1e-9 TOL_NUMPY=1e-9 - # FIXME: Have to ignore "rhs", and "gradients" to make - # this example pass. - # if [[ $example == "thermally-coupled.py" ]]; then - # echo "Setting tolerance=1 for $example" - # TOL_LAZY=1 - # TOL_NUMPY=1 - # fi - date printf "***\n***\n" @@ -110,7 +107,7 @@ do test_results=() # Run example with Eager, Lazy, and Numpy arraycontexts - for actx in eager lazy numpy; do + for actx in eager lazy $numpy_actx_available; do test_name="${example_name}_$actx" startgroup "**** Running $test_name" set -x diff --git a/examples/thermally-coupled-tpe.py b/examples/thermally-coupled-tpe.py index a733c4fdc..da0972edc 100644 --- a/examples/thermally-coupled-tpe.py +++ b/examples/thermally-coupled-tpe.py @@ -90,6 +90,13 @@ def main(actx_class, use_esdg=False, use_overintegration=False, if casename is None: casename = "mirgecom" + try: + from grudge.discretization import PartID # noqa: F401 + except ImportError: + from warnings import warn + warn("This example requires a coupling-enabled branch of grudge; exiting.") + return + from mpi4py import MPI comm = MPI.COMM_WORLD rank = comm.Get_rank() diff --git a/examples/thermally-coupled.py b/examples/thermally-coupled.py index 7ef400f1e..93d737bde 100644 --- a/examples/thermally-coupled.py +++ b/examples/thermally-coupled.py @@ -90,6 +90,13 @@ def main(actx_class, use_esdg=False, use_overintegration=False, if casename is None: casename = "mirgecom" + try: + from grudge.discretization import PartID # noqa: F401 + except ImportError: + from warnings import warn + warn("This example requires a coupling-enabled branch of grudge; exiting.") + return + from mpi4py import MPI comm = MPI.COMM_WORLD rank = comm.Get_rank() diff --git a/mirgecom/array_context.py b/mirgecom/array_context.py index f6c066565..abc9ede3f 100644 --- a/mirgecom/array_context.py +++ b/mirgecom/array_context.py @@ -59,10 +59,12 @@ def get_reasonable_array_context_class(*, lazy: bool, distributed: bool, warn("The NumpyArrayContext is still under development") if distributed: - from grudge.array_context import MPINumpyArrayContext + from grudge.array_context import MPINumpyArrayContext \ + # pylint: disable=no-name-in-module return MPINumpyArrayContext else: - from grudge.array_context import NumpyArrayContext + from grudge.array_context import NumpyArrayContext \ + # pylint: disable=no-name-in-module return NumpyArrayContext if profiling: @@ -108,6 +110,13 @@ def actx_class_is_numpy(actx_class: Type[ArrayContext]) -> bool: return False +def actx_class_has_fallback_args(actx_class: Type[ArrayContext]) -> bool: + """Return True if *actx_class* has fallback arguments.""" + import inspect + spec = inspect.getfullargspec(actx_class.__init__) + return "use_axis_tag_inference_fallback" in spec.args + + def _check_cache_dirs_node() -> None: """Check whether multiple ranks share cache directories on the same node.""" from mpi4py import MPI @@ -271,8 +280,8 @@ def initialize_actx( use_einsum_inference_fallback: bool = False) -> ArrayContext: """Initialize a new :class:`~arraycontext.ArrayContext` based on *actx_class*.""" from grudge.array_context import (MPIPyOpenCLArrayContext, - MPIPytatoArrayContext, - MPINumpyArrayContext) + MPIPytatoArrayContext + ) actx_kwargs: Dict[str, Any] = {} @@ -280,6 +289,8 @@ def initialize_actx( actx_kwargs["mpi_communicator"] = comm if actx_class_is_numpy(actx_class): + from grudge.array_context import MPINumpyArrayContext \ + # pylint: disable=no-name-in-module if comm: assert issubclass(actx_class, MPINumpyArrayContext) else: @@ -299,10 +310,12 @@ def initialize_actx( if actx_class_is_lazy(actx_class): assert issubclass(actx_class, PytatoPyOpenCLArrayContext) - actx_kwargs["use_axis_tag_inference_fallback"] = \ - use_axis_tag_inference_fallback - actx_kwargs["use_einsum_inference_fallback"] = \ - use_einsum_inference_fallback + + if actx_class_has_fallback_args(actx_class): + actx_kwargs["use_axis_tag_inference_fallback"] = \ + use_axis_tag_inference_fallback + actx_kwargs["use_einsum_inference_fallback"] = \ + use_einsum_inference_fallback if comm: assert issubclass(actx_class, MPIPytatoArrayContext) actx_kwargs["mpi_base_tag"] = 12000 diff --git a/mirgecom/euler.py b/mirgecom/euler.py index c314a1260..378a8ee2c 100644 --- a/mirgecom/euler.py +++ b/mirgecom/euler.py @@ -93,8 +93,6 @@ interior_trace_pairs, tracepair_with_discr_tag ) -from grudge.projection import volume_quadrature_project -from grudge.flux_differencing import volume_flux_differencing import grudge.op as op @@ -174,6 +172,9 @@ def entropy_stable_euler_operator( gamma_quad = gas_model.eos.gamma(state_quad.cv, state_quad.temperature) # Compute the projected (nodal) entropy variables + from grudge.projection import volume_quadrature_project \ + # pylint: disable=no-name-in-module + entropy_vars = volume_quadrature_project( dcoll, dd_vol_quad, # Map to entropy variables @@ -207,6 +208,9 @@ def _reshape(shape, ary): _reshape((-1, 1), modified_conserved_fluid_state)) # Compute volume derivatives using flux differencing + from grudge.flux_differencing import volume_flux_differencing \ + # pylint: disable=no-name-in-module,import-error + inviscid_vol_term = \ -volume_flux_differencing(dcoll, dd_vol_quad, dd_allfaces_quad, flux_matrices) diff --git a/mirgecom/gas_model.py b/mirgecom/gas_model.py index 7730f00dc..d7dfe273d 100644 --- a/mirgecom/gas_model.py +++ b/mirgecom/gas_model.py @@ -933,7 +933,8 @@ def replace_fluid_state( def make_entropy_projected_fluid_state( discr, dd_vol, dd_faces, state, entropy_vars, gamma, gas_model): """Projects the entropy vars to target manifold, computes the CV from that.""" - from grudge.interpolation import volume_and_surface_quadrature_interpolation + from grudge.interpolation import volume_and_surface_quadrature_interpolation \ + # pylint: disable=no-name-in-module # Interpolate to the volume and surface (concatenated) quadrature # discretizations: v = [v_vol, v_surf] diff --git a/mirgecom/multiphysics/thermally_coupled_fluid_wall.py b/mirgecom/multiphysics/thermally_coupled_fluid_wall.py index 392ce95ad..abcace047 100644 --- a/mirgecom/multiphysics/thermally_coupled_fluid_wall.py +++ b/mirgecom/multiphysics/thermally_coupled_fluid_wall.py @@ -74,7 +74,6 @@ from meshmode.dof_array import DOFArray from grudge.trace_pair import ( TracePair, - inter_volume_trace_pairs ) from grudge.dof_desc import ( DISCR_TAG_BASE, @@ -787,6 +786,10 @@ def _get_interface_trace_pairs_no_grad( (fluid_dd, wall_dd): ( _make_thermal_data(fluid_kappa, fluid_temperature), _make_thermal_data(wall_kappa, wall_temperature))} + + from grudge.trace_pair import inter_volume_trace_pairs \ + # pylint: disable=no-name-in-module + return inter_volume_trace_pairs( dcoll, pairwise_thermal_data, comm_tag=(_ThermalDataNoGradInterVolTag, comm_tag)) @@ -811,6 +814,9 @@ def _get_interface_trace_pairs( wall_temperature, wall_grad_temperature))} + from grudge.trace_pair import inter_volume_trace_pairs \ + # pylint: disable=no-name-in-module + return inter_volume_trace_pairs( dcoll, pairwise_thermal_data, comm_tag=(_ThermalDataInterVolTag, comm_tag)) diff --git a/mirgecom/simutil.py b/mirgecom/simutil.py index c4285e262..8912fddeb 100644 --- a/mirgecom/simutil.py +++ b/mirgecom/simutil.py @@ -84,7 +84,7 @@ DiscretizationDOFAxisTag ) from arraycontext import flatten, map_array_container -from grudge.discretization import DiscretizationCollection, PartID +from grudge.discretization import DiscretizationCollection from grudge.dof_desc import DD_VOLUME_ALL from meshmode.dof_array import DOFArray @@ -981,6 +981,9 @@ def get_rank_to_mesh_data(): for rank in range(num_ranks)] else: + from grudge.discretization import \ + PartID # pylint: disable=no-name-in-module + tag_to_volume = { tag: vol for vol, tags in volume_to_tags.items() diff --git a/test/test_av.py b/test/test_av.py index 5503ebd7c..78e9aa971 100644 --- a/test/test_av.py +++ b/test/test_av.py @@ -29,11 +29,11 @@ import numpy as np import pyopencl as cl import pytest -from meshmode.array_context import ( # noqa - PyOpenCLArrayContext, - pytest_generate_tests_for_pyopencl_array_context - as pytest_generate_tests -) +from meshmode.array_context import PyOpenCLArrayContext + +from meshmode.array_context import PytestPyOpenCLArrayContextFactory +from arraycontext import pytest_generate_tests_for_array_contexts + from meshmode.mesh import BTAG_ALL from meshmode.discretization.connection import FACE_RESTR_ALL import grudge.op as op @@ -51,14 +51,14 @@ from mirgecom.eos import IdealSingleGas from mirgecom.discretization import create_discretization_collection -from pyopencl.tools import ( # noqa - pytest_generate_tests_for_pyopencl as pytest_generate_tests, -) from mirgecom.simutil import get_box_mesh from pytools.obj_array import make_obj_array logger = logging.getLogger(__name__) +pytest_generate_tests = pytest_generate_tests_for_array_contexts( + [PytestPyOpenCLArrayContextFactory]) + # NOTE: Testing of this av_laplacian_operator is currently # pretty limited. This fact is somewhat indicative of the diff --git a/test/test_bc.py b/test/test_bc.py index f34f17767..7b273e9b0 100644 --- a/test/test_bc.py +++ b/test/test_bc.py @@ -52,9 +52,10 @@ import grudge.op as op from mirgecom.simutil import get_box_mesh -from meshmode.array_context import ( # noqa - pytest_generate_tests_for_pyopencl_array_context - as pytest_generate_tests) +from meshmode.array_context import PytestPyOpenCLArrayContextFactory +from arraycontext import pytest_generate_tests_for_array_contexts +pytest_generate_tests = pytest_generate_tests_for_array_contexts( + [PytestPyOpenCLArrayContextFactory]) logger = logging.getLogger(__name__) diff --git a/test/test_chemistry.py b/test/test_chemistry.py index 5c8862a7f..19a17f815 100644 --- a/test/test_chemistry.py +++ b/test/test_chemistry.py @@ -34,9 +34,8 @@ from meshmode.array_context import PyOpenCLArrayContext from meshmode.mesh.generation import generate_regular_rect_mesh -from meshmode.array_context import ( # noqa - pytest_generate_tests_for_pyopencl_array_context - as pytest_generate_tests) +from meshmode.array_context import PytestPyOpenCLArrayContextFactory +from arraycontext import pytest_generate_tests_for_array_contexts from mirgecom.fluid import make_conserved from mirgecom.eos import PyrometheusMixture @@ -47,6 +46,9 @@ get_pyrometheus_wrapper_class ) +pytest_generate_tests = pytest_generate_tests_for_array_contexts( + [PytestPyOpenCLArrayContextFactory]) + @pytest.mark.parametrize(("mechname", "fuel", "rate_tol"), [("uiuc_7sp", "C2H4", 1e-11), diff --git a/test/test_diffusion.py b/test/test_diffusion.py index 08e4d7e10..3fe28b333 100644 --- a/test/test_diffusion.py +++ b/test/test_diffusion.py @@ -33,9 +33,10 @@ from grudge.dof_desc import BoundaryDomainTag, DISCR_TAG_BASE, DISCR_TAG_QUAD from grudge.shortcuts import make_visualizer from meshmode.dof_array import DOFArray -from meshmode.array_context import ( # noqa - pytest_generate_tests_for_pyopencl_array_context - as pytest_generate_tests) + +from meshmode.array_context import PytestPyOpenCLArrayContextFactory +from arraycontext import pytest_generate_tests_for_array_contexts + from mirgecom.symbolic import ( diff as sym_diff, grad as sym_grad, @@ -55,6 +56,9 @@ logger = logging.getLogger(__name__) +pytest_generate_tests = pytest_generate_tests_for_array_contexts( + [PytestPyOpenCLArrayContextFactory]) + def test_diffusion_boundary_conditions(actx_factory): """Checks the boundary conditions for diffusion operator.""" diff --git a/test/test_eos.py b/test/test_eos.py index d3d48092d..33e4d4f35 100644 --- a/test/test_eos.py +++ b/test/test_eos.py @@ -33,14 +33,12 @@ from grudge import op -from meshmode.array_context import ( # noqa - PyOpenCLArrayContext, - PytatoPyOpenCLArrayContext -) +from meshmode.array_context import PyOpenCLArrayContext + +from meshmode.array_context import PytestPyOpenCLArrayContextFactory +from arraycontext import pytest_generate_tests_for_array_contexts + from meshmode.mesh.generation import generate_regular_rect_mesh -from meshmode.array_context import ( # noqa - pytest_generate_tests_for_pyopencl_array_context - as pytest_generate_tests) from mirgecom.fluid import make_conserved from mirgecom.eos import IdealSingleGas, PyrometheusMixture @@ -52,6 +50,9 @@ logger = logging.getLogger(__name__) +pytest_generate_tests = pytest_generate_tests_for_array_contexts( + [PytestPyOpenCLArrayContextFactory]) + @pytest.mark.parametrize("mechname", ["air_3sp", "uiuc_7sp", "sandiego", "uiuc_8sp_phenol", "uiuc_4sp_oxidation"]) diff --git a/test/test_euler.py b/test/test_euler.py index 4caf23165..f3a915690 100644 --- a/test/test_euler.py +++ b/test/test_euler.py @@ -55,9 +55,8 @@ from mirgecom.discretization import create_discretization_collection from grudge.dof_desc import DISCR_TAG_QUAD -from meshmode.array_context import ( # noqa - pytest_generate_tests_for_pyopencl_array_context - as pytest_generate_tests) +from meshmode.array_context import PytestPyOpenCLArrayContextFactory +from arraycontext import pytest_generate_tests_for_array_contexts from mirgecom.simutil import max_component_norm @@ -72,6 +71,9 @@ logger = logging.getLogger(__name__) +pytest_generate_tests = pytest_generate_tests_for_array_contexts( + [PytestPyOpenCLArrayContextFactory]) + @pytest.mark.parametrize("nspecies", [0, 10]) @pytest.mark.parametrize("dim", [1, 2, 3]) diff --git a/test/test_filter.py b/test/test_filter.py index 264bdce96..2d65811c9 100644 --- a/test/test_filter.py +++ b/test/test_filter.py @@ -29,14 +29,18 @@ from functools import partial from mirgecom.discretization import create_discretization_collection -from meshmode.array_context import ( # noqa - pytest_generate_tests_for_pyopencl_array_context - as pytest_generate_tests) + +from meshmode.array_context import PytestPyOpenCLArrayContextFactory +from arraycontext import pytest_generate_tests_for_array_contexts + from pytools.obj_array import ( make_obj_array ) from mirgecom.filter import make_spectral_filter +pytest_generate_tests = pytest_generate_tests_for_array_contexts( + [PytestPyOpenCLArrayContextFactory]) + @pytest.mark.parametrize("dim", [1, 2, 3]) @pytest.mark.parametrize("order", [2, 3, 4]) diff --git a/test/test_fluid.py b/test/test_fluid.py index 26fd3feb2..29d5365e5 100644 --- a/test/test_fluid.py +++ b/test/test_fluid.py @@ -36,12 +36,15 @@ from mirgecom.fluid import make_conserved from mirgecom.discretization import create_discretization_collection import grudge.op as op -from meshmode.array_context import ( # noqa - pytest_generate_tests_for_pyopencl_array_context - as pytest_generate_tests) + +from meshmode.array_context import PytestPyOpenCLArrayContextFactory +from arraycontext import pytest_generate_tests_for_array_contexts logger = logging.getLogger(__name__) +pytest_generate_tests = pytest_generate_tests_for_array_contexts( + [PytestPyOpenCLArrayContextFactory]) + @pytest.mark.parametrize("dim", [1, 2, 3]) @pytest.mark.parametrize(("mass_exp", "vel_fac"), diff --git a/test/test_flux.py b/test/test_flux.py index a72dec470..53649d3a1 100644 --- a/test/test_flux.py +++ b/test/test_flux.py @@ -42,13 +42,17 @@ GasModel, make_fluid_state ) -from meshmode.array_context import ( # noqa - pytest_generate_tests_for_pyopencl_array_context - as pytest_generate_tests) + +from meshmode.array_context import PytestPyOpenCLArrayContextFactory +from arraycontext import pytest_generate_tests_for_array_contexts + from mirgecom.inviscid import inviscid_flux logger = logging.getLogger(__name__) +pytest_generate_tests = pytest_generate_tests_for_array_contexts( + [PytestPyOpenCLArrayContextFactory]) + @pytest.mark.parametrize("nspecies", [0, 1, 10]) @pytest.mark.parametrize("dim", [1, 2, 3]) diff --git a/test/test_init.py b/test/test_init.py index 946d3f67d..70e9c14b1 100644 --- a/test/test_init.py +++ b/test/test_init.py @@ -44,9 +44,10 @@ from mirgecom.discretization import create_discretization_collection import grudge.op as op -from pyopencl.tools import ( # noqa - pytest_generate_tests_for_pyopencl as pytest_generate_tests, -) +from meshmode.array_context import PytestPyOpenCLArrayContextFactory +from arraycontext import pytest_generate_tests_for_array_contexts +pytest_generate_tests = pytest_generate_tests_for_array_contexts( + [PytestPyOpenCLArrayContextFactory]) logger = logging.getLogger(__name__) diff --git a/test/test_inviscid.py b/test/test_inviscid.py index c78b6d79b..586cd0581 100644 --- a/test/test_inviscid.py +++ b/test/test_inviscid.py @@ -44,9 +44,10 @@ from mirgecom.eos import IdealSingleGas from mirgecom.discretization import create_discretization_collection import grudge.op as op -from meshmode.array_context import ( # noqa - pytest_generate_tests_for_pyopencl_array_context - as pytest_generate_tests) + +from meshmode.array_context import PytestPyOpenCLArrayContextFactory +from arraycontext import pytest_generate_tests_for_array_contexts + from mirgecom.inviscid import ( inviscid_flux, inviscid_facial_flux_rusanov, @@ -55,6 +56,9 @@ logger = logging.getLogger(__name__) +pytest_generate_tests = pytest_generate_tests_for_array_contexts( + [PytestPyOpenCLArrayContextFactory]) + @pytest.mark.parametrize("nspecies", [0, 1, 10]) @pytest.mark.parametrize("dim", [1, 2, 3]) diff --git a/test/test_lazy.py b/test/test_lazy.py index 7c91ff718..5757b31af 100644 --- a/test/test_lazy.py +++ b/test/test_lazy.py @@ -36,15 +36,18 @@ from meshmode.discretization.connection import FACE_RESTR_ALL from mirgecom.discretization import create_discretization_collection import grudge.op as op -from meshmode.array_context import ( # noqa - pytest_generate_tests_for_pyopencl_array_context - as pytest_generate_tests) + +from meshmode.array_context import PytestPyOpenCLArrayContextFactory +from arraycontext import pytest_generate_tests_for_array_contexts import pytest # noqa import logging logger = logging.getLogger(__name__) +pytest_generate_tests = pytest_generate_tests_for_array_contexts( + [PytestPyOpenCLArrayContextFactory]) + @pytest.fixture def op_test_data(ctx_factory): diff --git a/test/test_limiter.py b/test/test_limiter.py index 7693392ba..714613086 100644 --- a/test/test_limiter.py +++ b/test/test_limiter.py @@ -20,13 +20,10 @@ THE SOFTWARE. """ import numpy as np -from meshmode.array_context import ( # noqa - pytest_generate_tests_for_pyopencl_array_context - as pytest_generate_tests) -from meshmode.array_context import ( # noqa - PyOpenCLArrayContext, - PytatoPyOpenCLArrayContext -) + +from meshmode.array_context import PytestPyOpenCLArrayContextFactory +from arraycontext import pytest_generate_tests_for_array_contexts + from mirgecom.limiter import bound_preserving_limiter from mirgecom.discretization import create_discretization_collection @@ -39,6 +36,9 @@ import pytest +pytest_generate_tests = pytest_generate_tests_for_array_contexts( + [PytestPyOpenCLArrayContextFactory]) + def test_fluid_api(actx_factory): actx = actx_factory() diff --git a/test/test_multiphysics.py b/test/test_multiphysics.py index 48ea892cb..4a9344139 100644 --- a/test/test_multiphysics.py +++ b/test/test_multiphysics.py @@ -52,14 +52,18 @@ from mirgecom.multiphysics.thermally_coupled_fluid_wall import ( basic_coupled_ns_heat_operator as coupled_ns_heat_operator, ) -from meshmode.array_context import ( # noqa - pytest_generate_tests_for_pyopencl_array_context - as pytest_generate_tests) + +from meshmode.array_context import PytestPyOpenCLArrayContextFactory +from arraycontext import pytest_generate_tests_for_array_contexts + import pytest import logging logger = logging.getLogger(__name__) +pytest_generate_tests = pytest_generate_tests_for_array_contexts( + [PytestPyOpenCLArrayContextFactory]) + @pytest.mark.parametrize("order", [1, 2, 3]) def test_independent_volumes(actx_factory, order, visualize=False): @@ -153,6 +157,11 @@ def get_rhs(t, u): def test_thermally_coupled_fluid_wall( actx_factory, order, use_overintegration, visualize=False): """Check the thermally-coupled fluid/wall interface.""" + try: + from grudge.discretization import PartID # noqa: F401 + except ImportError: + pytest.skip("Test requires a coupling-enabled branch of grudge.") + actx = actx_factory() from pytools.convergence import EOCRecorder @@ -454,6 +463,11 @@ def test_thermally_coupled_fluid_wall_with_radiation( Analytic solution prescribed as initial condition, then the RHS is assessed to ensure that it is nearly zero. """ + try: + from grudge.discretization import PartID # noqa: F401 + except ImportError: + pytest.skip("Test requires a coupling-enabled branch of grudge.") + actx = actx_factory() dim = 2 @@ -554,6 +568,11 @@ def test_orthotropic_flux( actx_factory, use_overintegration, use_radiation, use_noslip, visualize=False): """Check the RHS shape for orthotropic kappa cases.""" + try: + from grudge.discretization import PartID # noqa: F401 + except ImportError: + pytest.skip("Test requires a coupling-enabled branch of grudge.") + actx = actx_factory() dim = 2 diff --git a/test/test_navierstokes.py b/test/test_navierstokes.py index 40cb40607..adfab62b4 100644 --- a/test/test_navierstokes.py +++ b/test/test_navierstokes.py @@ -48,9 +48,10 @@ from mirgecom.transport import SimpleTransport from mirgecom.discretization import create_discretization_collection import grudge.op as op -from meshmode.array_context import ( # noqa - pytest_generate_tests_for_pyopencl_array_context - as pytest_generate_tests) + +from meshmode.array_context import PytestPyOpenCLArrayContextFactory +from arraycontext import pytest_generate_tests_for_array_contexts + from abc import ABCMeta, abstractmethod from meshmode.dof_array import DOFArray import pymbolic as pmbl @@ -71,6 +72,9 @@ logger = logging.getLogger(__name__) +pytest_generate_tests = pytest_generate_tests_for_array_contexts( + [PytestPyOpenCLArrayContextFactory]) + @pytest.mark.parametrize("nspecies", [0, 10]) @pytest.mark.parametrize("dim", [1, 2, 3]) diff --git a/test/test_operators.py b/test/test_operators.py index 04ee9e86d..81be4c761 100644 --- a/test/test_operators.py +++ b/test/test_operators.py @@ -27,10 +27,10 @@ import numpy as np # noqa import pytest # noqa import logging -from meshmode.array_context import ( # noqa - pytest_generate_tests_for_pyopencl_array_context - as pytest_generate_tests -) + +from meshmode.array_context import PytestPyOpenCLArrayContextFactory +from arraycontext import pytest_generate_tests_for_array_contexts + from pytools.obj_array import make_obj_array import pymbolic as pmbl # noqa import pymbolic.primitives as prim @@ -48,6 +48,9 @@ from mirgecom.simutil import get_box_mesh logger = logging.getLogger(__name__) +pytest_generate_tests = pytest_generate_tests_for_array_contexts( + [PytestPyOpenCLArrayContextFactory]) + def _elbnd_flux(dcoll, compute_interior_flux, compute_boundary_flux, int_tpair, boundaries): diff --git a/test/test_restart.py b/test/test_restart.py index cb05ef624..3a93699fe 100644 --- a/test/test_restart.py +++ b/test/test_restart.py @@ -30,9 +30,11 @@ import pytest from pytools.obj_array import make_obj_array from mirgecom.discretization import create_discretization_collection -from meshmode.array_context import ( # noqa - pytest_generate_tests_for_pyopencl_array_context - as pytest_generate_tests) + +from meshmode.array_context import PytestPyOpenCLArrayContextFactory +from arraycontext import pytest_generate_tests_for_array_contexts +pytest_generate_tests = pytest_generate_tests_for_array_contexts( + [PytestPyOpenCLArrayContextFactory]) logger = logging.getLogger(__name__) diff --git a/test/test_simutil.py b/test/test_simutil.py index 6678213b0..59b456197 100644 --- a/test/test_simutil.py +++ b/test/test_simutil.py @@ -27,16 +27,18 @@ import numpy as np import pytest # noqa -from arraycontext import ( # noqa - flatten, - pytest_generate_tests_for_pyopencl_array_context - as pytest_generate_tests -) +from arraycontext import flatten + +from meshmode.array_context import PytestPyOpenCLArrayContextFactory +from arraycontext import pytest_generate_tests_for_array_contexts from mirgecom.fluid import make_conserved from mirgecom.eos import IdealSingleGas from mirgecom.discretization import create_discretization_collection +pytest_generate_tests = pytest_generate_tests_for_array_contexts( + [PytestPyOpenCLArrayContextFactory]) + def test_basic_cfd_healthcheck(actx_factory): """Quick test of some health checking utilities.""" diff --git a/test/test_symbolic.py b/test/test_symbolic.py index b40818e4c..e7aaf2c18 100644 --- a/test/test_symbolic.py +++ b/test/test_symbolic.py @@ -29,15 +29,18 @@ import mirgecom.symbolic as sym from mirgecom.discretization import create_discretization_collection import grudge.op as op -from meshmode.array_context import ( # noqa - pytest_generate_tests_for_pyopencl_array_context - as pytest_generate_tests) + +from meshmode.array_context import PytestPyOpenCLArrayContextFactory +from arraycontext import pytest_generate_tests_for_array_contexts import pytest import logging logger = logging.getLogger(__name__) +pytest_generate_tests = pytest_generate_tests_for_array_contexts( + [PytestPyOpenCLArrayContextFactory]) + def _const_deriv_pair(): """Return a constant ($1$) and its derivative ($0$).""" diff --git a/test/test_time_integrators.py b/test/test_time_integrators.py index 8a734901d..3e4db27d0 100644 --- a/test/test_time_integrators.py +++ b/test/test_time_integrators.py @@ -28,9 +28,9 @@ import logging import pytest import importlib -from meshmode.array_context import ( # noqa - pytest_generate_tests_for_pyopencl_array_context - as pytest_generate_tests) + +from meshmode.array_context import PytestPyOpenCLArrayContextFactory +from arraycontext import pytest_generate_tests_for_array_contexts from mirgecom.integrators import ( euler_step, lsrk54_step, lsrk144_step, @@ -39,6 +39,9 @@ logger = logging.getLogger(__name__) +pytest_generate_tests = pytest_generate_tests_for_array_contexts( + [PytestPyOpenCLArrayContextFactory]) + @pytest.mark.parametrize(("integrator", "method_order"), [(euler_step, 1), diff --git a/test/test_transport.py b/test/test_transport.py index 186d204b3..209387571 100644 --- a/test/test_transport.py +++ b/test/test_transport.py @@ -33,18 +33,13 @@ from grudge import op -from meshmode.array_context import ( # noqa - PyOpenCLArrayContext, - PytatoPyOpenCLArrayContext -) +from meshmode.array_context import PyOpenCLArrayContext + from meshmode.mesh.generation import generate_regular_rect_mesh -from meshmode.array_context import ( # noqa - pytest_generate_tests_for_pyopencl_array_context - as pytest_generate_tests) -from pyopencl.tools import ( # noqa - pytest_generate_tests_for_pyopencl as pytest_generate_tests, -) +from meshmode.array_context import PytestPyOpenCLArrayContextFactory +from arraycontext import pytest_generate_tests_for_array_contexts + from mirgecom.transport import MixtureAveragedTransport from mirgecom.fluid import make_conserved from mirgecom.eos import PyrometheusMixture @@ -59,6 +54,9 @@ logger = logging.getLogger(__name__) +pytest_generate_tests = pytest_generate_tests_for_array_contexts( + [PytestPyOpenCLArrayContextFactory]) + @pytest.mark.parametrize("mechname", ["uiuc_7sp"]) @pytest.mark.parametrize("dim", [2]) diff --git a/test/test_viscous.py b/test/test_viscous.py index ecbbcaf59..099c3ae35 100644 --- a/test/test_viscous.py +++ b/test/test_viscous.py @@ -39,9 +39,8 @@ from grudge.trace_pair import interior_trace_pairs from mirgecom.discretization import create_discretization_collection -from meshmode.array_context import ( # noqa - pytest_generate_tests_for_pyopencl_array_context - as pytest_generate_tests) +from meshmode.array_context import PytestPyOpenCLArrayContextFactory +from arraycontext import pytest_generate_tests_for_array_contexts from mirgecom.fluid import make_conserved from mirgecom.transport import ( @@ -56,6 +55,9 @@ from mirgecom.simutil import get_box_mesh logger = logging.getLogger(__name__) +pytest_generate_tests = pytest_generate_tests_for_array_contexts( + [PytestPyOpenCLArrayContextFactory]) + @pytest.mark.parametrize("transport_model", [0, 1]) def test_viscous_stress_tensor(actx_factory, transport_model): diff --git a/test/test_wallmodel.py b/test/test_wallmodel.py index 9fed63bf7..c3b8ee72a 100644 --- a/test/test_wallmodel.py +++ b/test/test_wallmodel.py @@ -24,13 +24,17 @@ import numpy as np from pytools.obj_array import make_obj_array -from meshmode.array_context import ( # noqa - pytest_generate_tests_for_pyopencl_array_context - as pytest_generate_tests) + +from meshmode.array_context import PytestPyOpenCLArrayContextFactory +from arraycontext import pytest_generate_tests_for_array_contexts + import grudge.op as op from mirgecom.discretization import create_discretization_collection from mirgecom.simutil import get_box_mesh +pytest_generate_tests = pytest_generate_tests_for_array_contexts( + [PytestPyOpenCLArrayContextFactory]) + def test_tacot_decomposition(actx_factory): """Check the wall degradation model.""" diff --git a/test/test_wave.py b/test/test_wave.py index 61eb14d09..2de6763fa 100644 --- a/test/test_wave.py +++ b/test/test_wave.py @@ -31,9 +31,8 @@ from mirgecom.discretization import create_discretization_collection import grudge.op as op -from meshmode.array_context import ( # noqa - pytest_generate_tests_for_pyopencl_array_context - as pytest_generate_tests) +from meshmode.array_context import PytestPyOpenCLArrayContextFactory +from arraycontext import pytest_generate_tests_for_array_contexts import pytest @@ -43,6 +42,9 @@ import logging logger = logging.getLogger(__name__) +pytest_generate_tests = pytest_generate_tests_for_array_contexts( + [PytestPyOpenCLArrayContextFactory]) + @dataclass class WaveProblem: