@pytest.mark.parametrize('dim', [1, 2, 3])
def test_uniform(ctx_factory, dim):
    '\n    Simple test to check that Uniform initializer\n    creates the expected solution field.\n    '
    cl_ctx = ctx_factory()
    queue = cl.CommandQueue(cl_ctx)
    actx = PyOpenCLArrayContext(queue)
    nel_1d = 2
    from meshmode.mesh.generation import generate_regular_rect_mesh
    mesh = generate_regular_rect_mesh(a=(((- 0.5),) * dim), b=((0.5,) * dim), n=((nel_1d,) * dim))
    order = 1
    print(f'Number of elements: {mesh.nelements}')
    discr = EagerDGDiscretization(actx, mesh, order=order)
    nodes = thaw(actx, discr.nodes())
    print(f'DIM = {dim}, {len(nodes)}')
    print(f'Nodes={nodes}')
    from mirgecom.initializers import Uniform
    initr = Uniform(numdim=dim)
    initsoln = initr(t=0.0, x_vec=nodes)
    tol = 1e-15
    ssoln = split_conserved(dim, initsoln)
    assert (discr.norm((ssoln.mass - 1.0), np.inf) < tol)
    assert (discr.norm((ssoln.energy - 2.5), np.inf) < tol)
    print(f'Uniform Soln:{initsoln}')
    eos = IdealSingleGas()
    cv = split_conserved(dim, initsoln)
    p = eos.pressure(cv)
    print(f'Press:{p}')
    assert (discr.norm((p - 1.0), np.inf) < tol)
Simple test to check that Uniform initializer
creates the expected solution field.
@pytest.mark.parametrize('dim', [1, 2, 3])
def test_uniform(ctx_factory, dim):
    '\n    Simple test to check that Uniform initializer\n    creates the expected solution field.\n    '
    cl_ctx = ctx_factory()
    queue = cl.CommandQueue(cl_ctx)
    actx = PyOpenCLArrayContext(queue)
    nel_1d = 2
    from meshmode.mesh.generation import generate_regular_rect_mesh
    mesh = generate_regular_rect_mesh(a=(((- 0.5),) * dim), b=((0.5,) * dim), n=((nel_1d,) * dim))
    order = 1
    print(f'Number of elements: {mesh.nelements}')
    discr = EagerDGDiscretization(actx, mesh, order=order)
    nodes = thaw(actx, discr.nodes())
    print(f'DIM = {dim}, {len(nodes)}')
    print(f'Nodes={nodes}')
    from mirgecom.initializers import Uniform
    initr = Uniform(numdim=dim)
    initsoln = initr(t=0.0, x_vec=nodes)
    tol = 1e-15
    ssoln = split_conserved(dim, initsoln)
    assert (discr.norm((ssoln.mass - 1.0), np.inf) < tol)
    assert (discr.norm((ssoln.energy - 2.5), np.inf) < tol)
    print(f'Uniform Soln:{initsoln}')
    eos = IdealSingleGas()
    cv = split_conserved(dim, initsoln)
    p = eos.pressure(cv)
    print(f'Press:{p}')
    assert (discr.norm((p - 1.0), np.inf) < tol)