ansys-pyensight-core 0.8.10__py3-none-any.whl → 0.8.11__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ansys-pyensight-core might be problematic. Click here for more details.
- ansys/pyensight/core/libuserd.py +126 -13
- ansys/pyensight/core/utils/omniverse.py +3 -3
- {ansys_pyensight_core-0.8.10.dist-info → ansys_pyensight_core-0.8.11.dist-info}/METADATA +1 -1
- {ansys_pyensight_core-0.8.10.dist-info → ansys_pyensight_core-0.8.11.dist-info}/RECORD +6 -6
- {ansys_pyensight_core-0.8.10.dist-info → ansys_pyensight_core-0.8.11.dist-info}/LICENSE +0 -0
- {ansys_pyensight_core-0.8.10.dist-info → ansys_pyensight_core-0.8.11.dist-info}/WHEEL +0 -0
ansys/pyensight/core/libuserd.py
CHANGED
|
@@ -601,6 +601,79 @@ class Reader(object):
|
|
|
601
601
|
for key in pb.metadata.keys():
|
|
602
602
|
self.metadata[key] = pb.metadata[key]
|
|
603
603
|
self.raw_metadata = pb.raw_metadata
|
|
604
|
+
self._timesets: List["numpy.array"] = []
|
|
605
|
+
self._update_timesets()
|
|
606
|
+
|
|
607
|
+
def _update_timesets(self) -> None:
|
|
608
|
+
"""
|
|
609
|
+
To simplify the interface to time, the timesets are all queried and
|
|
610
|
+
cached. Additionally, a "common timeset" is generated that combines
|
|
611
|
+
all the timevalues from all timesets into a single timeset which is
|
|
612
|
+
saved as "timeset 0".
|
|
613
|
+
|
|
614
|
+
This method reads all the timesets and generates the common timeset.
|
|
615
|
+
"""
|
|
616
|
+
if len(self._timesets):
|
|
617
|
+
return
|
|
618
|
+
num_timesets = self.get_number_of_time_sets()
|
|
619
|
+
# The common timeset
|
|
620
|
+
common = set()
|
|
621
|
+
self._timesets = [numpy.array([], dtype="float32")]
|
|
622
|
+
# The other timesets
|
|
623
|
+
for ts in range(1, num_timesets + 1):
|
|
624
|
+
v = self.timevalues(timeset=ts)
|
|
625
|
+
# merge into the common timeset
|
|
626
|
+
common.update(v)
|
|
627
|
+
self._timesets.append(v)
|
|
628
|
+
self._timesets[0] = numpy.array(sorted(list(common)))
|
|
629
|
+
|
|
630
|
+
def _common_set_step(self, s: int) -> None:
|
|
631
|
+
"""
|
|
632
|
+
When the common timeset is used in a ``set_timestep()`` call, this
|
|
633
|
+
method selects the time value from the common timeset and then calls
|
|
634
|
+
``_common_set_time()`` to change the current simulation time.
|
|
635
|
+
|
|
636
|
+
Parameters
|
|
637
|
+
----------
|
|
638
|
+
s : int
|
|
639
|
+
The index (timestep) in the common timeset to change the current time to.
|
|
640
|
+
|
|
641
|
+
Raises
|
|
642
|
+
------
|
|
643
|
+
RuntimeError
|
|
644
|
+
If the timestep index is invalid.
|
|
645
|
+
|
|
646
|
+
"""
|
|
647
|
+
try:
|
|
648
|
+
v = self._timesets[0][s]
|
|
649
|
+
self._common_set_time(v)
|
|
650
|
+
except IndexError:
|
|
651
|
+
raise RuntimeError(f"Invalid step number {s}.") from None
|
|
652
|
+
|
|
653
|
+
def _common_set_time(self, t: float) -> None:
|
|
654
|
+
"""
|
|
655
|
+
Change the current time value to the passed time value. This method
|
|
656
|
+
walks all the timesets. It selects the largest time value in each timeset
|
|
657
|
+
that is less than or equal to the specified time value. It then sets
|
|
658
|
+
the time value for each timeset accordingly.
|
|
659
|
+
|
|
660
|
+
Parameters
|
|
661
|
+
----------
|
|
662
|
+
t : float
|
|
663
|
+
The time value (in the common timeset) to change the reader simulation time to.
|
|
664
|
+
|
|
665
|
+
"""
|
|
666
|
+
# given the time float from the common timeline,
|
|
667
|
+
# change the timestep in all the timesets to match.
|
|
668
|
+
for timeset in range(1, len(self._timesets)):
|
|
669
|
+
# check for perfect match first (avoids rounding)
|
|
670
|
+
where = numpy.where(self._timesets[timeset] == t)
|
|
671
|
+
if len(where[0]):
|
|
672
|
+
timestep = where[0][0]
|
|
673
|
+
else:
|
|
674
|
+
timestep = numpy.searchsorted(self._timesets[timeset], t)
|
|
675
|
+
timestep = min(timestep, len(self._timesets[timeset]) - 1)
|
|
676
|
+
self.set_timestep(timestep, timeset=timeset)
|
|
604
677
|
|
|
605
678
|
def parts(self) -> List[Part]:
|
|
606
679
|
"""
|
|
@@ -671,6 +744,8 @@ class Reader(object):
|
|
|
671
744
|
int
|
|
672
745
|
The number of timesets.
|
|
673
746
|
"""
|
|
747
|
+
if len(self._timesets):
|
|
748
|
+
return len(self._timesets) - 1
|
|
674
749
|
self._userd.connect_check()
|
|
675
750
|
pb = libuserd_pb2.Reader_get_number_of_time_setsRequest()
|
|
676
751
|
try:
|
|
@@ -681,20 +756,27 @@ class Reader(object):
|
|
|
681
756
|
raise self._userd.libuserd_exception(e)
|
|
682
757
|
return reply.numberOfTimeSets
|
|
683
758
|
|
|
684
|
-
def timevalues(self, timeset: int =
|
|
759
|
+
def timevalues(self, timeset: int = 0) -> List[float]:
|
|
685
760
|
"""
|
|
686
|
-
Get a list of the time step values in this dataset.
|
|
761
|
+
Get a list of the time step values in this dataset for the specified timeset.
|
|
762
|
+
The default timeset is ``0`` which is a special, "common" timeset formed by
|
|
763
|
+
merging all the timesets in the data into a single timeset.
|
|
687
764
|
|
|
688
765
|
Parameters
|
|
689
766
|
----------
|
|
690
767
|
timeset : int, optional
|
|
691
|
-
The timestep to query (default is
|
|
768
|
+
The timestep to query (default is 0)
|
|
692
769
|
|
|
693
770
|
Returns
|
|
694
771
|
-------
|
|
695
|
-
|
|
696
|
-
|
|
772
|
+
numpy.array
|
|
773
|
+
The simulation time value floats.
|
|
697
774
|
"""
|
|
775
|
+
if timeset == 0:
|
|
776
|
+
try:
|
|
777
|
+
return self._timesets[timeset]
|
|
778
|
+
except IndexError:
|
|
779
|
+
return numpy.array([], dtype="float32")
|
|
698
780
|
self._userd.connect_check()
|
|
699
781
|
pb = libuserd_pb2.Reader_timevaluesRequest()
|
|
700
782
|
pb.timeSetNumber = timeset
|
|
@@ -704,18 +786,43 @@ class Reader(object):
|
|
|
704
786
|
raise self._userd.libuserd_exception(e)
|
|
705
787
|
return numpy.array(timevalues.timeValues)
|
|
706
788
|
|
|
707
|
-
def set_timevalue(self, timevalue: float, timeset: int =
|
|
789
|
+
def set_timevalue(self, timevalue: float, timeset: int = 0) -> None:
|
|
708
790
|
"""
|
|
709
|
-
Change the current time to the specified value.
|
|
710
|
-
|
|
791
|
+
Change the current time within the selected timeset to the specified value.
|
|
792
|
+
The default timeset selected is the merged "common" timeset ``0``. If the
|
|
793
|
+
"common" timeset is used, the appropriate time value will be set for
|
|
794
|
+
all timesets by this method.
|
|
711
795
|
|
|
712
796
|
Parameters
|
|
713
797
|
----------
|
|
714
798
|
timevalue : float
|
|
715
799
|
The time value to change the timestep closest to.
|
|
716
800
|
timeset : int, optional
|
|
717
|
-
The
|
|
718
|
-
|
|
801
|
+
The timeset to change (default is 0)
|
|
802
|
+
|
|
803
|
+
Examples
|
|
804
|
+
--------
|
|
805
|
+
>>> from ansys.pyensight.core import libuserd
|
|
806
|
+
>>> import numpy
|
|
807
|
+
>>> s = libuserd.LibUserd()
|
|
808
|
+
>>> s.initialize()
|
|
809
|
+
>>> opt = {'Long names': 0, 'Number of timesteps': 5, 'Number of scalars': 3,
|
|
810
|
+
... 'Number of spheres': 2, 'Number of cubes': 2}
|
|
811
|
+
>>> d = s.load_data("foo", file_format="Synthetic", reader_options=opt)
|
|
812
|
+
>>> parts = d.parts()
|
|
813
|
+
>>> for t in d.timevalues():
|
|
814
|
+
... d.set_timevalue(t)
|
|
815
|
+
... for p in parts:
|
|
816
|
+
... nodes = p.nodes()
|
|
817
|
+
... nodes.shape = (len(nodes)//3, 3)
|
|
818
|
+
... centroid = numpy.average(nodes, 0)
|
|
819
|
+
... print(f"Time: {t} Part: {p.name} Centroid: {centroid}")
|
|
820
|
+
>>> s.shutdown()
|
|
821
|
+
|
|
822
|
+
"""
|
|
823
|
+
if timeset == 0:
|
|
824
|
+
self._common_set_time(timevalue)
|
|
825
|
+
return
|
|
719
826
|
self._userd.connect_check()
|
|
720
827
|
pb = libuserd_pb2.Reader_set_timevalueRequest()
|
|
721
828
|
pb.timesetNumber = timeset
|
|
@@ -725,18 +832,24 @@ class Reader(object):
|
|
|
725
832
|
except grpc.RpcError as e:
|
|
726
833
|
raise self._userd.libuserd_exception(e)
|
|
727
834
|
|
|
728
|
-
def set_timestep(self, timestep: int, timeset: int =
|
|
835
|
+
def set_timestep(self, timestep: int, timeset: int = 0) -> None:
|
|
729
836
|
"""
|
|
730
837
|
Change the current time to the specified timestep. This call is the same as:
|
|
731
838
|
``reader.set_timevalue(reader.timevalues()[timestep])``.
|
|
839
|
+
The default timeset selected is the merged "common" timeset ``0``. If the
|
|
840
|
+
"common" timeset is used, the appropriate time value will be set for
|
|
841
|
+
all timesets by this method.
|
|
732
842
|
|
|
733
843
|
Parameters
|
|
734
844
|
----------
|
|
735
845
|
timestep : int
|
|
736
846
|
The timestep to change to.
|
|
737
847
|
timeset : int, optional
|
|
738
|
-
The
|
|
848
|
+
The timeset to change (default is 0)
|
|
739
849
|
"""
|
|
850
|
+
if timeset == 0:
|
|
851
|
+
self._common_set_step(timestep)
|
|
852
|
+
return
|
|
740
853
|
self._userd.connect_check()
|
|
741
854
|
pb = libuserd_pb2.Reader_set_timestepRequest()
|
|
742
855
|
pb.timeSetNumber = timeset
|
|
@@ -1733,7 +1846,7 @@ class LibUserd(object):
|
|
|
1733
1846
|
try:
|
|
1734
1847
|
output = the_reader.read_dataset(data_file, result_file)
|
|
1735
1848
|
except Exception:
|
|
1736
|
-
raise RuntimeError("Unable to open the specified dataset.")
|
|
1849
|
+
raise RuntimeError("Unable to open the specified dataset.") from None
|
|
1737
1850
|
|
|
1738
1851
|
return output
|
|
1739
1852
|
|
|
@@ -44,7 +44,7 @@ class Omniverse:
|
|
|
44
44
|
>>> from ansys.pyensight.core import LocalLauncher
|
|
45
45
|
>>> session = LocalLauncher().start()
|
|
46
46
|
>>> ov = session.ensight.utils.omniverse
|
|
47
|
-
>>> ov.create_connection()
|
|
47
|
+
>>> ov.create_connection(r"D:\Omniverse\Example")
|
|
48
48
|
>>> ov.update()
|
|
49
49
|
>>> ov.close_connection()
|
|
50
50
|
|
|
@@ -202,8 +202,8 @@ class Omniverse:
|
|
|
202
202
|
Parameters
|
|
203
203
|
----------
|
|
204
204
|
omniverse_path : str
|
|
205
|
-
The
|
|
206
|
-
"
|
|
205
|
+
The directory name where the USD files should be saved. For example:
|
|
206
|
+
"C:/Users/test/OV/usdfiles"
|
|
207
207
|
include_camera : bool
|
|
208
208
|
If True, apply the EnSight camera to the Omniverse scene. This option
|
|
209
209
|
should be used if the target viewer is in AR/VR mode. Defaults to False.
|
|
@@ -8,7 +8,7 @@ ansys/pyensight/core/ensight_grpc.py,sha256=BJaErleSPrtI8myTIh0m9awFWPaUxrQmHpbu
|
|
|
8
8
|
ansys/pyensight/core/ensobj.py,sha256=uDtM2KHcAwd4hu5pcUYWbSD729ApHGIvuqZhEq8PxTI,18558
|
|
9
9
|
ansys/pyensight/core/launch_ensight.py,sha256=iZJM6GdpzGRDLzrv1V2QZ5veIOpNSB5xPpJUFY7rBuo,10254
|
|
10
10
|
ansys/pyensight/core/launcher.py,sha256=ymwfixwoHO7_c4qOetqccQbZjGT1HjeA7jwPi2JxlmE,10585
|
|
11
|
-
ansys/pyensight/core/libuserd.py,sha256=
|
|
11
|
+
ansys/pyensight/core/libuserd.py,sha256=P5ewBFey_a9YYhRhbWSCCy2KXtyccsJyyLWlYh-Hxgo,72592
|
|
12
12
|
ansys/pyensight/core/listobj.py,sha256=Trw87IxIMXtmUd1DzywRmMzORU704AG4scX4fqYmO6M,9340
|
|
13
13
|
ansys/pyensight/core/locallauncher.py,sha256=MnSyKVe0JGXN0YJ9f_msw_TBbLGfqDpjWWC4-haAjJ4,16205
|
|
14
14
|
ansys/pyensight/core/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -19,7 +19,7 @@ ansys/pyensight/core/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJ
|
|
|
19
19
|
ansys/pyensight/core/utils/adr.py,sha256=XslZhlwcrSGzOlnhzprOv3ju_ppxxsWBjCnQL5KiNms,3570
|
|
20
20
|
ansys/pyensight/core/utils/dsg_server.py,sha256=zPvIHlgiJxiy0NQm3uIsh2nPY8TyAHaHaXtDMN28jiY,38869
|
|
21
21
|
ansys/pyensight/core/utils/export.py,sha256=ZNpU3earAnRMBHZa6I8nTwMYY54WctXApJfMTkREBNA,23189
|
|
22
|
-
ansys/pyensight/core/utils/omniverse.py,sha256=
|
|
22
|
+
ansys/pyensight/core/utils/omniverse.py,sha256=k3SxbK_BDmwbiUPr9PLKEswZAyri6EEiT_gaMWIu6zw,14250
|
|
23
23
|
ansys/pyensight/core/utils/omniverse_cli.py,sha256=aePr-2AWla2mMgPx8NlwIApAD1rAdVLmNOBWKjMXNQA,18786
|
|
24
24
|
ansys/pyensight/core/utils/omniverse_dsg_server.py,sha256=SjKY8-q-M26tge13HW6Js71RoQnFgkjWELtHpXk707c,28185
|
|
25
25
|
ansys/pyensight/core/utils/omniverse_glb_server.py,sha256=VYSbIwKMZASAmgYwRGbN5PrCjbSdaL7MaFxMnOJlTFg,9793
|
|
@@ -30,7 +30,7 @@ ansys/pyensight/core/utils/support.py,sha256=QI3z9ex7zJxjFbkCPba9DWqWgPFIThORqr0
|
|
|
30
30
|
ansys/pyensight/core/utils/variables.py,sha256=T96aL-qR2FtxH6QafeD9ddcWL9BB6IRSOYs2JauRTlg,95133
|
|
31
31
|
ansys/pyensight/core/utils/views.py,sha256=ZKhJ6vMT7Rdd4bwJ0egMYTV7-D7Q7I19fF2_j_CMQ0o,12489
|
|
32
32
|
ansys/pyensight/core/utils/resources/Materials/000_sky.exr,sha256=xAR1gFd2uxPZDnvgfegdhEhRaqKtZldQDiR_-1rHKO0,8819933
|
|
33
|
-
ansys_pyensight_core-0.8.
|
|
34
|
-
ansys_pyensight_core-0.8.
|
|
35
|
-
ansys_pyensight_core-0.8.
|
|
36
|
-
ansys_pyensight_core-0.8.
|
|
33
|
+
ansys_pyensight_core-0.8.11.dist-info/LICENSE,sha256=qQWivZ12ETN5l3QxvTARY-QI5eoRRlyHdwLlAj0Bg5I,1089
|
|
34
|
+
ansys_pyensight_core-0.8.11.dist-info/WHEEL,sha256=EZbGkh7Ie4PoZfRQ8I0ZuP9VklN_TvcZ6DSE5Uar4z4,81
|
|
35
|
+
ansys_pyensight_core-0.8.11.dist-info/METADATA,sha256=7HoVAVfhnAucYeDmIIrcRhCXjcObDnISxnMQHENPKgM,11999
|
|
36
|
+
ansys_pyensight_core-0.8.11.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|