def test_shock_init(ctx_factory):
    '\n    Simple test to check that Shock1D initializer\n    creates the expected solution field.\n    '
    cl_ctx = ctx_factory()
    queue = cl.CommandQueue(cl_ctx)
    actx = PyOpenCLArrayContext(queue)
    nel_1d = 10
    dim = 2
    from meshmode.mesh.generation import generate_regular_rect_mesh
    mesh = generate_regular_rect_mesh(a=[(0.0,), (1.0,)], b=[((- 0.5),), (0.5,)], n=((nel_1d,) * dim))
    order = 3
    print(f'Number of elements: {mesh.nelements}')
    discr = EagerDGDiscretization(actx, mesh, order=order)
    nodes = thaw(actx, discr.nodes())
    initr = SodShock1D()
    initsoln = initr(t=0.0, x_vec=nodes)
    print('Sod Soln:', initsoln)
    xpl = 1.0
    xpr = 0.1
    tol = 1e-15
    nodes_x = nodes[0]
    eos = IdealSingleGas()
    cv = split_conserved(dim, initsoln)
    p = eos.pressure(cv)
    assert (discr.norm(actx.np.where((nodes_x < 0.5), (p - xpl), (p - xpr)), np.inf) < tol)
Simple test to check that Shock1D initializer
creates the expected solution field.
def test_shock_init(ctx_factory):
    '\n    Simple test to check that Shock1D initializer\n    creates the expected solution field.\n    '
    cl_ctx = ctx_factory()
    queue = cl.CommandQueue(cl_ctx)
    actx = PyOpenCLArrayContext(queue)
    nel_1d = 10
    dim = 2
    from meshmode.mesh.generation import generate_regular_rect_mesh
    mesh = generate_regular_rect_mesh(a=[(0.0,), (1.0,)], b=[((- 0.5),), (0.5,)], n=((nel_1d,) * dim))
    order = 3
    print(f'Number of elements: {mesh.nelements}')
    discr = EagerDGDiscretization(actx, mesh, order=order)
    nodes = thaw(actx, discr.nodes())
    initr = SodShock1D()
    initsoln = initr(t=0.0, x_vec=nodes)
    print('Sod Soln:', initsoln)
    xpl = 1.0
    xpr = 0.1
    tol = 1e-15
    nodes_x = nodes[0]
    eos = IdealSingleGas()
    cv = split_conserved(dim, initsoln)
    p = eos.pressure(cv)
    assert (discr.norm(actx.np.where((nodes_x < 0.5), (p - xpl), (p - xpr)), np.inf) < tol)