Пример #1
0
def test_402(ceed_resource, capsys):
    ceed = libceed.Ceed(ceed_resource)

    file_dir = os.path.dirname(os.path.abspath(__file__))
    qfs = load_qfs_so()

    qf_setup = ceed.QFunction(1, qfs.setup_mass,
                              os.path.join(file_dir, "test-qfunctions.h:setup_mass"))
    qf_setup.add_input("w", 1, libceed.EVAL_WEIGHT)
    qf_setup.add_input("dx", 1, libceed.EVAL_GRAD)
    qf_setup.add_output("qdata", 1, libceed.EVAL_NONE)

    qf_mass = ceed.QFunction(1, qfs.apply_mass,
                             os.path.join(file_dir, "t400-qfunction.h:apply_mass"))
    qf_mass.add_input("qdata", 1, libceed.EVAL_NONE)
    qf_mass.add_input("u", 1, libceed.EVAL_INTERP)
    qf_mass.add_output("v", 1, libceed.EVAL_INTERP)

    print(qf_setup)
    print(qf_mass)

    ctx_data = np.array([1., 2., 3., 4., 5.])
    ctx = ceed.QFunctionContext()
    ctx.set_data(ctx_data)
    print(ctx)

    stdout, stderr, ref_stdout = check.output(capsys)
    assert not stderr
    assert stdout == ref_stdout
Пример #2
0
def test_413(ceed_resource, capsys):
    ceed = libceed.Ceed(ceed_resource)

    qf_setup = ceed.QFunctionByName("Mass1DBuild")
    qf_mass = ceed.QFunctionByName("MassApply")

    print(qf_setup)
    print(qf_mass)

    stdout, stderr, ref_stdout = check.output(capsys)
    assert not stderr
    assert stdout == ref_stdout
Пример #3
0
def test_211(ceed_resource, capsys):
    ceed = libceed.Ceed(ceed_resource)

    num_elem = 3

    strides = np.array([1, 2, 2], dtype="int32")
    r = ceed.StridedElemRestriction(num_elem, 2, 1, num_elem + 1, strides)

    print(r)

    stdout, stderr, ref_stdout = check.output(capsys)
    assert not stderr
    assert stdout == ref_stdout
Пример #4
0
def test_300(ceed_resource, capsys):
    ceed = libceed.Ceed(ceed_resource)

    b = ceed.BasisTensorH1Lagrange(1, 1, 4, 4, libceed.GAUSS_LOBATTO)
    print(b)
    del b

    b = ceed.BasisTensorH1Lagrange(1, 1, 4, 4, libceed.GAUSS)
    print(b)
    del b

    stdout, stderr, ref_stdout = check.output(capsys)
    assert not stderr
    assert stdout == ref_stdout
Пример #5
0
def test_107(ceed_resource, capsys):
    ceed = libceed.Ceed(ceed_resource)

    n = 10
    x = ceed.Vector(n)

    a = np.arange(10, 10 + n, dtype="float64")
    x.set_array(a, cmode=libceed.USE_POINTER)

    print(x)

    stdout, stderr, ref_stdout = check.output(capsys)
    assert not stderr
    assert stdout == ref_stdout
Пример #6
0
def test_300(ceed_resource, capsys):
    ceed = libceed.Ceed(ceed_resource)

    b = ceed.BasisTensorH1Lagrange(1, 1, 4, 4, libceed.GAUSS_LOBATTO)
    print(b)
    del b

    b = ceed.BasisTensorH1Lagrange(1, 1, 4, 4, libceed.GAUSS)
    print(b)
    del b

    # Only run this test in double precision
    if libceed.lib.CEED_SCALAR_TYPE == libceed.SCALAR_FP64:
        stdout, stderr, ref_stdout = check.output(capsys)
        assert not stderr
        assert stdout == ref_stdout
Пример #7
0
def test_210(ceed_resource, capsys):
    ceed = libceed.Ceed(ceed_resource)

    num_elem = 3

    ind = np.zeros(2 * num_elem, dtype="int32")
    for i in range(num_elem):
        ind[2 * i + 0] = i + 0
        ind[2 * i + 1] = i + 1
    r = ceed.ElemRestriction(num_elem, 2, 1, 1, num_elem + 1, ind,
                             cmode=libceed.USE_POINTER)

    print(r)

    stdout, stderr, ref_stdout = check.output(capsys)
    assert not stderr
    assert stdout == ref_stdout
Пример #8
0
def test_402(ceed_resource, capsys):
    ceed = libceed.Ceed(ceed_resource)

    file_dir = os.path.dirname(os.path.abspath(__file__))
    qfs = load_qfs_so()

    qf_setup = ceed.QFunction(
        1, qfs.setup_mass,
        os.path.join(file_dir, "test-qfunctions.h:setup_mass"))
    qf_setup.add_input("w", 1, libceed.EVAL_WEIGHT)
    qf_setup.add_input("dx", 1, libceed.EVAL_GRAD)
    qf_setup.add_output("qdata", 1, libceed.EVAL_NONE)

    qf_mass = ceed.QFunction(
        1, qfs.apply_mass,
        os.path.join(file_dir, "test-qfunctions.h:apply_mass"))
    qf_mass.add_input("qdata", 1, libceed.EVAL_NONE)
    qf_mass.add_input("u", 1, libceed.EVAL_INTERP)
    qf_mass.add_output("v", 1, libceed.EVAL_INTERP)

    print(qf_setup)
    print(qf_mass)

    if libceed.lib.CEED_SCALAR_TYPE == libceed.SCALAR_FP64:
        ctx_data = np.array([1., 2., 3., 4., 5.], dtype="float64")
    # Make ctx twice as long in fp32, so size will be the same as fp64 output
    else:
        ctx_data = np.array([1., 2., 3., 4., 5., 1., 2., 3., 4., 5.],
                            dtype="float32")
    ctx = ceed.QFunctionContext()
    ctx.set_data(ctx_data)
    print(ctx)

    stdout, stderr, ref_stdout = check.output(capsys)
    assert not stderr
    assert stdout == ref_stdout