|
| 1 | +import os.path |
| 2 | + |
1 | 3 | import pytest
|
2 | 4 |
|
| 5 | +from conftest import SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_5_0 |
3 | 6 | from ansys.dpf import core as dpf
|
| 7 | +from ansys.dpf.core import examples |
4 | 8 |
|
5 | 9 |
|
6 | 10 | @pytest.fixture()
|
@@ -55,3 +59,51 @@ def test_eng(engineering_data_sources, try_load_composites_operators):
|
55 | 59 | field_variable_provider.connect(4, engineering_data_sources)
|
56 | 60 | field_variable_provider.inputs.mesh.connect(m.metadata.mesh_provider)
|
57 | 61 | field_variable_provider.run()
|
| 62 | + |
| 63 | + |
| 64 | +@pytest.mark.skipif(not SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_5_0, |
| 65 | + reason='Requires server version higher than 5.0') |
| 66 | +def test_lsdynahgp(d3plot, server_type): |
| 67 | + ds = dpf.DataSources(server=server_type) |
| 68 | + ds.set_result_file_path(d3plot, "d3plot") |
| 69 | + streams = dpf.operators.metadata.streams_provider(ds, server=server_type) |
| 70 | + u = dpf.operators.result.displacement(server=server_type) |
| 71 | + u.inputs.streams_container(streams) |
| 72 | + fc = u.outputs.fields_container() |
| 73 | + assert len(fc[0]) == 3195 |
| 74 | + assert dpf.Operator("lsdyna::stream_provider") is not None |
| 75 | + |
| 76 | + |
| 77 | +@pytest.mark.skipif(not SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_5_0, |
| 78 | + reason='Requires server version higher than 5.0') |
| 79 | +def test_cgns(server_type): |
| 80 | + assert dpf.Operator("cgns::stream_provider", server=server_type) is not None |
| 81 | + |
| 82 | + |
| 83 | +@pytest.mark.skipif(not SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_5_0, |
| 84 | + reason='Requires server version higher than 5.0') |
| 85 | +def test_vtk(server_type, tmpdir): |
| 86 | + op = dpf.Operator("vtu_export", server=server_type) |
| 87 | + try: |
| 88 | + rst_file = dpf.upload_file_in_tmp_folder(examples.download_pontoon(return_local_path=True) |
| 89 | + , server=server_type) |
| 90 | + except dpf.errors.ServerTypeError as e: |
| 91 | + print(e) |
| 92 | + rst_file = examples.download_pontoon(return_local_path=True) |
| 93 | + pass |
| 94 | + |
| 95 | + assert op is not None |
| 96 | + model = dpf.Model(rst_file, server=server_type) |
| 97 | + u = model.operator("U") |
| 98 | + op.inputs.fields1.connect(u) |
| 99 | + op.inputs.mesh.connect(model.metadata.mesh_provider) |
| 100 | + op.inputs.directory.connect(os.path.dirname(rst_file)) |
| 101 | + out_path = op.eval() |
| 102 | + # assert out_path.result_files is not [] |
| 103 | + # try: |
| 104 | + # out_path = dpf.core.download_file( |
| 105 | + # out_path, tmp_path, server=server_type) |
| 106 | + # except dpf.errors.ServerTypeError as e: |
| 107 | + # print(e) |
| 108 | + # pass |
| 109 | + # assert os.path.exists(tmp_path) |
0 commit comments