Esempio n. 1
0
def test_saveh5(tmpdir):
    from fem.post.create_res_sim import run
    import h5py

    h5file = tmpdir.join('res_sim_test.h5')
    gauss_qsym_pml_example_path = examplesPath / "gauss_qsym_pml"

    run(dynadeck=gauss_qsym_pml_example_path / "gauss_qsym_pml.dyn",
        dispout=gauss_qsym_pml_example_path / "disp.dat.xz",
        nodedyn=gauss_qsym_pml_example_path / "nodes.dyn",
        ressim=h5file.strpath)

    valid_data = h5py.File(gauss_qsym_pml_example_path / "res_sim_valid.h5", 'r')
    test_data = h5py.File(h5file.strpath, 'r')

    assert (test_data['arfidata'][10, 10, 2] == valid_data['arfidata'][10, 10, 2])
Esempio n. 2
0
def test_savemat(tmpdir):
    from fem.post.create_res_sim import run
    from scipy.io import loadmat

    matfile = tmpdir.join('res_sim_test.mat')
    gauss_qsym_pml_example_path = examplesPath / "gauss_qsym_pml"

    run(dynadeck=gauss_qsym_pml_example_path / "gauss_qsym_pml.dyn",
        dispout=gauss_qsym_pml_example_path / "disp.dat.xz",
        nodedyn=gauss_qsym_pml_example_path / "nodes.dyn",
        ressim=matfile.strpath)

    valid_data = loadmat(gauss_qsym_pml_example_path / "res_sim_valid.mat")
    test_data = loadmat(matfile.strpath)

    assert (test_data['arfidata'][10, 10, 2] == valid_data['arfidata'][10, 10, 2])
Esempio n. 3
0
def test_savepvd(tmpdir):
    """Test the PVD/VTR files written correctly."""
    from fem.post.create_res_sim import extract3Darfidata as run
    import filecmp

    pvdfile = tmpdir.join('res_sim.pvd')
    vtr0file = tmpdir.join('res_sim_T0000.vtr')
    vtr1file = tmpdir.join('res_sim_T0001.vtr')
    vtr2file = tmpdir.join('res_sim_T0002.vtr')
    gauss_qsym_pml_example_path = examplesPath / "gauss_qsym_pml"

    run(dynadeck=gauss_qsym_pml_example_path / "gauss_qsym_pml.dyn",
        dispout=gauss_qsym_pml_example_path / "disp.dat.xz",
        nodedyn=gauss_qsym_pml_example_path / "nodes.dyn",
        ressim=pvdfile.strpath)

    assert filecmp.cmp(gauss_qsym_pml_example_path / "res_sim.pvd", pvdfile.strpath)
    assert filecmp.cmp(gauss_qsym_pml_example_path / "res_sim_T0000.vtr", vtr0file.strpath)
    assert filecmp.cmp(gauss_qsym_pml_example_path / "res_sim_T0001.vtr", vtr1file.strpath)
    assert filecmp.cmp(gauss_qsym_pml_example_path / "res_sim_T0002.vtr", vtr2file.strpath)
Esempio n. 4
0
File: run.py Progetto: mlp6/fem
print('HOST: {}'.format(gethostname()))

DYNADECK = 'gauss_qsym_pml.dyn'
NTASKS = environ.get('SLURM_NTASKS', '8')

GenMesh.run((-1.5, 0.0, 0.0, 1.5, -3.0, 0.0), (75, 75, 150))

# setup quarter-symmetry condition
pml_elems = ((5, 0), (0, 5), (5, 5))
face_constraints = (('1,1,1,1,1,1', '1,0,0,0,1,1'),
                    ('0,1,0,1,0,1', '1,1,1,1,1,1'), ('1,1,1,1,1,1',
                                                     '1,1,1,1,1,1'))
edge_constraints = (((0, 1), (1, 0), (0, 0)), '1,1,0,1,1,1')
bc.apply_pml(pml_elems, face_constraints, edge_constraints)

generate_loads([0.25, 0.25, 0.75], [0.0, 0.0, -1.5])

system('ls-dyna-d ncpu={} i={}'.format(NTASKS, DYNADECK))

create_disp_dat()

create_res_sim.run(DYNADECK, dispout="disp.dat", ressim="res_sim.mat")
create_res_sim.run(dynadeck=DYNADECK, dispout="disp.dat", ressim='res_sim.h5')
create_res_sim.extract3Darfidata(dynadeck=DYNADECK,
                                 dispout="disp.dat",
                                 ressim="res_sim.pvd")

os.system("xz -v disp.dat")

print('FINISHED: {}'.format(ctime()))