Skip to content

Commit

Permalink
Add a test for USERD case file reader
Browse files Browse the repository at this point in the history
Read the xml crash dataset using libuserd.
  • Loading branch information
randallfrank committed Jan 3, 2025
1 parent d303099 commit 78bfe2b
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/ansys/pyensight/core/libuserd.py
Original file line number Diff line number Diff line change
Expand Up @@ -1298,8 +1298,8 @@ def _launch_enshell(self) -> None:
)
self._cei_home = self._enshell.cei_home()
self._ansys_version = self._enshell.ansys_version()
print("CEI_HOME=", self._cei_home)
print("Ansys Version=", self._ansys_version)
# print("CEI_HOME=", self._cei_home)
# print("Ansys Version=", self._ansys_version)
grpc_port = self._service_host_port["grpc_private"][1]
ensight_args = f"-grpc_server {grpc_port}"
container_env_str = f"ENSIGHT_SECURITY_TOKEN={self._security_token}\n"
Expand Down
36 changes: 36 additions & 0 deletions tests/example_tests/test_libuserd.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os

from ansys.pyensight.core.libuserd import LibUserd
import numpy
import pytest
Expand Down Expand Up @@ -76,3 +78,37 @@ def test_libuserd_synthetic_time(tmpdir, pytestconfig: pytest.Config):
assert not numpy.array_equal(centroid_5, centroid_0)

libuserd.shutdown()


def test_libuserd_userd_case(tmpdir, pytestconfig: pytest.Config):
data_dir = tmpdir.mkdir("datadir")
use_local = pytestconfig.getoption("use_local_launcher")
if use_local:
libuserd = LibUserd()
else:
libuserd = LibUserd(use_docker=True, use_dev=True, data_directory=data_dir)
libuserd.initialize()
readers = libuserd.query_format("example.case")
assert len(readers) == 1
assert readers[0].name == "USERD EnSight Case"

cei_root = os.path.dirname(os.path.dirname(libuserd.server_pathname))
casefile = os.path.join(
cei_root,
f"ensight{libuserd.ansys_release_number()}",
"other_data",
"ensight",
"guard_rail_xml",
"crash_xml.case",
)

readers = libuserd.query_format(casefile)
data = readers[0].read_dataset(casefile)

assert len(data.parts) == 15
assert len(data.variables) == 2
assert len(data.timevalues()) == 21
assert data.variables()[0].unit_label == "mm"
assert data.variables()[1].unit_label == "kg m^-1 s^-2"

libuserd.shutdown()

0 comments on commit 78bfe2b

Please sign in to comment.