@pytest.mark.parametrize('dim', [1, 2, 3])
def test_pulse(ctx_factory, dim):
    '\n    Test of Gaussian pulse generator.\n    If it looks, walks, and quacks like a duck, then ...\n    '
    cl_ctx = ctx_factory()
    queue = cl.CommandQueue(cl_ctx)
    actx = PyOpenCLArrayContext(queue)
    nel_1d = 10
    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}')
    tol = 1e-15
    from mirgecom.initializers import _make_pulse
    amp = 1.0
    w = 0.1
    rms2 = (w * w)
    r0 = np.zeros(dim)
    r2 = (np.dot(nodes, nodes) / rms2)
    pulse = _make_pulse(amp=amp, r0=r0, w=w, r=nodes)
    print(f'Pulse = {pulse}')
    pulse_check = actx.np.exp(((- 0.5) * r2))
    print(f'exact: {pulse_check}')
    pulse_resid = (pulse - pulse_check)
    print(f'pulse residual: {pulse_resid}')
    assert (discr.norm(pulse_resid, np.inf) < tol)
    amp = 2.0
    pulse = 0
    pulse = _make_pulse(amp=amp, r0=r0, w=w, r=nodes)
    pulse_resid = (pulse - (pulse_check + pulse_check))
    assert (discr.norm(pulse_resid, np.inf) < tol)
    amp = 1.0
    rcheck = (np.sqrt(2.0) * nodes)
    pulse = _make_pulse(amp=amp, r0=r0, w=w, r=rcheck)
    assert (discr.norm((pulse - (pulse_check * pulse_check)), np.inf) < tol)
    w = (w / np.sqrt(2.0))
    pulse = _make_pulse(amp=amp, r0=r0, w=w, r=nodes)
    assert (discr.norm((pulse - (pulse_check * pulse_check)), np.inf) < tol)
Test of Gaussian pulse generator.
If it looks, walks, and quacks like a duck, then ...
@pytest.mark.parametrize('dim', [1, 2, 3])
def test_pulse(ctx_factory, dim):
    '\n    Test of Gaussian pulse generator.\n    If it looks, walks, and quacks like a duck, then ...\n    '
    cl_ctx = ctx_factory()
    queue = cl.CommandQueue(cl_ctx)
    actx = PyOpenCLArrayContext(queue)
    nel_1d = 10
    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}')
    tol = 1e-15
    from mirgecom.initializers import _make_pulse
    amp = 1.0
    w = 0.1
    rms2 = (w * w)
    r0 = np.zeros(dim)
    r2 = (np.dot(nodes, nodes) / rms2)
    pulse = _make_pulse(amp=amp, r0=r0, w=w, r=nodes)
    print(f'Pulse = {pulse}')
    pulse_check = actx.np.exp(((- 0.5) * r2))
    print(f'exact: {pulse_check}')
    pulse_resid = (pulse - pulse_check)
    print(f'pulse residual: {pulse_resid}')
    assert (discr.norm(pulse_resid, np.inf) < tol)
    amp = 2.0
    pulse = 0
    pulse = _make_pulse(amp=amp, r0=r0, w=w, r=nodes)
    pulse_resid = (pulse - (pulse_check + pulse_check))
    assert (discr.norm(pulse_resid, np.inf) < tol)
    amp = 1.0
    rcheck = (np.sqrt(2.0) * nodes)
    pulse = _make_pulse(amp=amp, r0=r0, w=w, r=rcheck)
    assert (discr.norm((pulse - (pulse_check * pulse_check)), np.inf) < tol)
    w = (w / np.sqrt(2.0))
    pulse = _make_pulse(amp=amp, r0=r0, w=w, r=nodes)
    assert (discr.norm((pulse - (pulse_check * pulse_check)), np.inf) < tol)