Esempio n. 1
0
def test_writenek():
    import pymech.neksuite as ns

    fname = './tests/nek/channel3D_0.f00001'
    time0 = time.perf_counter()
    field = ns.readnek(fname)
    time1 = time.perf_counter()

    fnamew = './test_0.f00001'
    status = ns.writenek(fnamew, field)
    time2 = time.perf_counter()
    print('readnek: {:.6e} s; writenek: {:.6e} s'.format(
        time1 - time0, time2 - time1))

    assert status == 0

    fieldw = ns.readnek(fnamew)

    assert field.endian == fieldw.endian
    assert field.istep == fieldw.istep
    assert field.lr1 == fieldw.lr1
    assert field.ndim == fieldw.ndim
    assert field.nel == fieldw.nel
    assert field.var == fieldw.var
    assert field.wdsz == fieldw.wdsz
    assert (field.time - fieldw.time) < 1e-3
    assert field.lims.pos.all() == fieldw.lims.pos.all()
    assert field.lims.vel.all() == fieldw.lims.vel.all()
    assert field.lims.pres.all() == fieldw.lims.pres.all()
    assert field.lims.scal.all() == fieldw.lims.scal.all()
    assert np.abs(field.elem[123].vel - fieldw.elem[123].vel).max() < 1e-9
    assert np.abs(field.elem[-1].pos - fieldw.elem[-1].pos).max() < 1e-9
    assert np.abs(field.elem[-1].pres - fieldw.elem[-1].pres).max() < 1e-9
Esempio n. 2
0
def test_writenek_scalars():
    import pymech.neksuite as ns

    fname = './tests/nek/stsabl0.f00001'
    field = ns.readnek(fname)

    fnamew = './test_sts_0.f00001'
    status = ns.writenek(fnamew, field)

    assert status == 0

    fieldw = ns.readnek(fnamew)
    npt.assert_array_equal(field.lims.scal, fieldw.lims.scal)
Esempio n. 3
0
def test_writenek():
    import pymech.neksuite as ns

    fname = "./tests/nek/channel3D_0.f00001"
    time0 = time.perf_counter()
    field = ns.readnek(fname)
    time1 = time.perf_counter()

    fnamew = "./test_0.f00001"
    status = ns.writenek(fnamew, field)
    time2 = time.perf_counter()
    logger.info(
        "readnek: {:.6e} s; writenek: {:.6e} s".format(time1 - time0, time2 - time1)
    )

    assert status == 0

    fieldw = ns.readnek(fnamew)

    assert field.endian == fieldw.endian
    assert field.istep == fieldw.istep
    assert field.lr1 == fieldw.lr1
    assert field.ndim == fieldw.ndim
    assert field.nel == fieldw.nel
    assert field.var == fieldw.var
    assert field.wdsz == fieldw.wdsz
    assert (field.time - fieldw.time) < 1e-3
    npt.assert_array_equal(field.lims.pos, fieldw.lims.pos)
    npt.assert_array_equal(field.lims.vel, fieldw.lims.vel)
    npt.assert_array_equal(field.lims.pres, fieldw.lims.pres)
    npt.assert_array_equal(field.lims.scal, fieldw.lims.scal)

    for elem, elemw in zip(field.elem, fieldw.elem):
        npt.assert_array_equal(elem.pos, elemw.pos)
        npt.assert_array_equal(elem.vel, elemw.vel)
        npt.assert_array_equal(elem.pres, elemw.pres)
        npt.assert_array_equal(elem.scal, elemw.scal)
Esempio n. 4
0
def test_writenek_big_endian():
    import pymech.neksuite as ns

    fname = './tests/nek/channel3D_0.f00001'
    field = ns.readnek(fname)

    field.endian = "big"
    fnamew = './test_0_big.f00001'
    status = ns.writenek(fnamew, field)
    assert status == 0

    fieldw = ns.readnek(fnamew)
    assert field.endian == fieldw.endian == "big"

    npt.assert_array_equal(field.lims.pos, fieldw.lims.pos)
    npt.assert_array_equal(field.lims.vel, fieldw.lims.vel)
    npt.assert_array_equal(field.lims.pres, fieldw.lims.pres)
    npt.assert_array_equal(field.lims.scal, fieldw.lims.scal)

    for elem, elemw in zip(field.elem, fieldw.elem):
        npt.assert_array_equal(elem.pos, elemw.pos)
        npt.assert_array_equal(elem.vel, elemw.vel)
        npt.assert_array_equal(elem.pres, elemw.pres)
        npt.assert_array_equal(elem.scal, elemw.scal)