tecio-python 0.4.1__py3-none-any.whl → 0.4.2__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.
- tecio/__init__.py +42 -1
- tecio/_constants.py +2 -2
- tecio/_dat_write.py +32 -0
- tecio/_elements.py +1311 -0
- tecio/_io.py +49 -4
- tecio/_meta.py +8 -0
- tecio/_plt_write.py +32 -0
- tecio/_reader.py +157 -3
- tecio/_szl_read.py +99 -3
- tecio/_szl_write.py +261 -0
- tecio/_utils.py +10 -10
- tecio/_writer.py +234 -3
- tecio/cli/tec2mat.py +20 -0
- tecio/cli/tecaux.py +11 -1
- tecio/cli/tecdump.py +24 -1
- tecio/cli/tecelretyp.py +1096 -0
- tecio/cli/tecextract.py +21 -2
- tecio/cli/tecfix.py +16 -1
- tecio/cli/tecmerge.py +226 -34
- tecio/cli/teconvert.py +12 -2
- tecio/cli/tecscale.py +16 -1
- tecio/cli/tecslice.py +24 -3
- tecio/libtecio.py +75 -6
- {tecio_python-0.4.1.data → tecio_python-0.4.2.data}/data/share/tecio/plugins/paraview/TecplotTecioReader.py +1 -1
- {tecio_python-0.4.1.dist-info → tecio_python-0.4.2.dist-info}/METADATA +9 -9
- tecio_python-0.4.2.dist-info/RECORD +40 -0
- {tecio_python-0.4.1.dist-info → tecio_python-0.4.2.dist-info}/entry_points.txt +1 -0
- tecio_python-0.4.1.dist-info/RECORD +0 -38
- {tecio_python-0.4.1.data → tecio_python-0.4.2.data}/data/share/tecio/plugins/matlab/contourfe.m +0 -0
- {tecio_python-0.4.1.data → tecio_python-0.4.2.data}/data/share/tecio/plugins/matlab/tecmat2struct.m +0 -0
- {tecio_python-0.4.1.data → tecio_python-0.4.2.data}/data/share/tecio/plugins/paraview/TecplotTecioWriter.py +0 -0
- {tecio_python-0.4.1.dist-info → tecio_python-0.4.2.dist-info}/WHEEL +0 -0
- {tecio_python-0.4.1.dist-info → tecio_python-0.4.2.dist-info}/licenses/LICENSE +0 -0
- {tecio_python-0.4.1.dist-info → tecio_python-0.4.2.dist-info}/licenses/NOTICE +0 -0
- {tecio_python-0.4.1.dist-info → tecio_python-0.4.2.dist-info}/top_level.txt +0 -0
tecio/_io.py
CHANGED
|
@@ -53,6 +53,7 @@ from ._plt_read import TecplotPltReader, _is_legacy_plt
|
|
|
53
53
|
from ._plt_write import TecplotPltWriter
|
|
54
54
|
from ._reader import (
|
|
55
55
|
TecplotAuxDataReader,
|
|
56
|
+
TecplotFEMixedZoneReader,
|
|
56
57
|
TecplotFEZoneReader,
|
|
57
58
|
TecplotOrderedZoneReader,
|
|
58
59
|
TecplotPolyZoneReader,
|
|
@@ -160,7 +161,8 @@ def _copy_zones(reader: TecplotReader, writer: TecplotWriter) -> None:
|
|
|
160
161
|
writer: An already-opened ``Write`` instance (file handle live).
|
|
161
162
|
|
|
162
163
|
Raises:
|
|
163
|
-
NotImplementedError: If a zone is neither ordered, finite-element, nor
|
|
164
|
+
NotImplementedError: If a zone is neither ordered, finite-element, FEMIXED, nor
|
|
165
|
+
poly, or if the writer's format cannot hold a FEMIXED zone (PLT and DAT).
|
|
164
166
|
|
|
165
167
|
"""
|
|
166
168
|
for zone in reader.zones:
|
|
@@ -213,10 +215,19 @@ def _copy_zones(reader: TecplotReader, writer: TecplotWriter) -> None:
|
|
|
213
215
|
con_sharing=con_sharing,
|
|
214
216
|
**common_kw,
|
|
215
217
|
)
|
|
218
|
+
elif isinstance(zone, TecplotFEMixedZoneReader):
|
|
219
|
+
con_sharing = zone.shared_connectivity
|
|
220
|
+
writer.write_femixed_zone(
|
|
221
|
+
data=data,
|
|
222
|
+
cell_shapes=None if con_sharing is not None else zone.section_shapes,
|
|
223
|
+
node_maps=None if con_sharing is not None else zone.node_maps,
|
|
224
|
+
con_sharing=con_sharing,
|
|
225
|
+
**common_kw,
|
|
226
|
+
)
|
|
216
227
|
else:
|
|
217
228
|
raise NotImplementedError(
|
|
218
|
-
f"Zone '{zone.title}' is neither an ordered, classic FE, nor
|
|
219
|
-
"zone, copying it is not supported by the Write API yet."
|
|
229
|
+
f"Zone '{zone.title}' is neither an ordered, classic FE, FEMIXED, nor "
|
|
230
|
+
"poly zone, copying it is not supported by the Write API yet."
|
|
220
231
|
)
|
|
221
232
|
|
|
222
233
|
|
|
@@ -372,6 +383,39 @@ class AppendWrite:
|
|
|
372
383
|
"""
|
|
373
384
|
self._writer.write_fe_zone(*args, **kwargs)
|
|
374
385
|
|
|
386
|
+
def write_femixed_zone(self, *args: Any, **kwargs: Any) -> None: # noqa: D417
|
|
387
|
+
"""Append a FEMIXED (mixed finite-element) zone.
|
|
388
|
+
|
|
389
|
+
Delegates to the underlying format writer's ``write_femixed_zone``
|
|
390
|
+
(e.g. :meth:`tecio.TecplotSzlWriter.write_femixed_zone`). The ``variables``
|
|
391
|
+
parameter is not meaningful here, the variable list is fixed from the existing
|
|
392
|
+
file. All indices are 0-based.
|
|
393
|
+
|
|
394
|
+
Args:
|
|
395
|
+
data (Sequence[ndarray]): One 1-D array per active variable. NODAL arrays
|
|
396
|
+
need ``num_nodes`` values, CELL_CENTERED arrays the total cell count
|
|
397
|
+
over all sections, both inferred from the node maps.
|
|
398
|
+
cell_shapes (Sequence[FeCellShape] | None): Cell shape of each section
|
|
399
|
+
(1 to 16), all of one spatial dimension.
|
|
400
|
+
node_maps (Sequence[array-like] | None): One ``(num_cells, nodes_per_cell)``
|
|
401
|
+
0-based integer array per section.
|
|
402
|
+
title (str | None): Zone title. Defaults to ``"FEMixed_Zone_{n}"``.
|
|
403
|
+
value_locations (Sequence[ValueLocation] | None): Per-variable value
|
|
404
|
+
location for active variables. Defaults to all NODAL.
|
|
405
|
+
passive_vars (list | tuple | set | None): Variables to mark passive.
|
|
406
|
+
var_sharing (dict[str | int, int] | None): ``{variable: source zone}``.
|
|
407
|
+
con_sharing (int | None): FEMIXED zone to share connectivity from (0-based),
|
|
408
|
+
in which case ``cell_shapes`` and ``node_maps`` must be omitted.
|
|
409
|
+
solution_time (float): Solution time. Defaults to ``0.0``.
|
|
410
|
+
strand_id (int): Strand ID. Defaults to ``0``.
|
|
411
|
+
aux (dict[str, str] | None): Zone-level auxiliary data.
|
|
412
|
+
|
|
413
|
+
Raises:
|
|
414
|
+
NotImplementedError: For PLT and DAT files, which cannot hold FEMIXED zones.
|
|
415
|
+
ValueError: On an inconsistent section layout.
|
|
416
|
+
"""
|
|
417
|
+
self._writer.write_femixed_zone(*args, **kwargs)
|
|
418
|
+
|
|
375
419
|
def write_poly_zone(self, *args: Any, **kwargs: Any) -> None: # noqa: D417
|
|
376
420
|
"""Append a polygon or polyhedron (face-based) zone.
|
|
377
421
|
|
|
@@ -776,7 +820,8 @@ def open(
|
|
|
776
820
|
- ``None``
|
|
777
821
|
- Variable name list. For SZL and PLT this may be deferred to the first
|
|
778
822
|
:meth:`~tecio.TecplotWriter.write_ordered_zone`,
|
|
779
|
-
:meth:`~tecio.TecplotWriter.write_fe_zone`,
|
|
823
|
+
:meth:`~tecio.TecplotWriter.write_fe_zone`,
|
|
824
|
+
:meth:`~tecio.TecplotWriter.write_femixed_zone`, or
|
|
780
825
|
:meth:`~tecio.TecplotWriter.write_poly_zone` call. Required at open time
|
|
781
826
|
for DAT.
|
|
782
827
|
* - ``file_type``
|
tecio/_meta.py
CHANGED
|
@@ -35,6 +35,7 @@ if TYPE_CHECKING:
|
|
|
35
35
|
from ._constants import (
|
|
36
36
|
DataType,
|
|
37
37
|
FaceNeighborMode,
|
|
38
|
+
FeCellShape,
|
|
38
39
|
FileType,
|
|
39
40
|
ValueLocation,
|
|
40
41
|
ZoneType,
|
|
@@ -75,6 +76,10 @@ class ZoneMeta:
|
|
|
75
76
|
num_boundary_faces: Boundary face count for poly zones, else ``None``.
|
|
76
77
|
num_boundary_connections: Total boundary connections for poly zones, else
|
|
77
78
|
``None``.
|
|
79
|
+
section_shapes: Cell shape of each section for FEMIXED zones, else
|
|
80
|
+
``None``.
|
|
81
|
+
section_num_elements: Cell count of each section for FEMIXED zones, else
|
|
82
|
+
``None``.
|
|
78
83
|
value_locations: Per-variable value location, full dataset length.
|
|
79
84
|
passive_vars: Per-variable passive flags, full dataset length.
|
|
80
85
|
shared_vars: Per-variable share-from zone index, or ``None`` for
|
|
@@ -99,6 +104,9 @@ class ZoneMeta:
|
|
|
99
104
|
total_face_nodes: int | None = None
|
|
100
105
|
num_boundary_faces: int | None = None
|
|
101
106
|
num_boundary_connections: int | None = None
|
|
107
|
+
# FEMIXED zones record their per-section layout.
|
|
108
|
+
section_shapes: tuple[FeCellShape, ...] | None = None
|
|
109
|
+
section_num_elements: tuple[int, ...] | None = None
|
|
102
110
|
# Per-variable descriptors (length == dataset variable count).
|
|
103
111
|
value_locations: tuple[ValueLocation, ...] = ()
|
|
104
112
|
passive_vars: tuple[bool, ...] = ()
|
tecio/_plt_write.py
CHANGED
|
@@ -21,6 +21,7 @@ from ._constants import (
|
|
|
21
21
|
DataPacking,
|
|
22
22
|
DataType,
|
|
23
23
|
FaceNeighborMode,
|
|
24
|
+
FeCellShape,
|
|
24
25
|
FileFormat,
|
|
25
26
|
FileType,
|
|
26
27
|
ValueLocation,
|
|
@@ -798,6 +799,37 @@ class TecplotPltWriter(TecplotWriter):
|
|
|
798
799
|
)
|
|
799
800
|
)
|
|
800
801
|
|
|
802
|
+
def write_femixed_zone(
|
|
803
|
+
self,
|
|
804
|
+
data: Sequence[npt.ArrayLike],
|
|
805
|
+
cell_shapes: Sequence[FeCellShape | int | str] | None = None,
|
|
806
|
+
node_maps: Sequence[npt.ArrayLike] | None = None,
|
|
807
|
+
*,
|
|
808
|
+
title: str | None = None,
|
|
809
|
+
variables: list[str] | None = None,
|
|
810
|
+
value_locations: Sequence[ValueLocation] | None = None,
|
|
811
|
+
passive_vars: PassiveVarsSpec | None = None,
|
|
812
|
+
var_sharing: VarSharingSpec | None = None,
|
|
813
|
+
con_sharing: int | None = None,
|
|
814
|
+
solution_time: float = 0.0,
|
|
815
|
+
strand_id: int = 0,
|
|
816
|
+
aux: dict[str, Any] | None = None,
|
|
817
|
+
datapacking: DataPacking | str = DataPacking.BLOCK,
|
|
818
|
+
) -> None:
|
|
819
|
+
"""Not supported: PLT files cannot hold FEMIXED zones.
|
|
820
|
+
|
|
821
|
+
The signature matches :meth:`TecplotSzlWriter.write_femixed_zone` so every
|
|
822
|
+
writer exposes the same interface.
|
|
823
|
+
|
|
824
|
+
Raises:
|
|
825
|
+
NotImplementedError: Always. Write a ``.szplt`` file instead, see
|
|
826
|
+
:meth:`TecplotSzlWriter.write_femixed_zone`.
|
|
827
|
+
"""
|
|
828
|
+
raise NotImplementedError(
|
|
829
|
+
"The PLT file format does not support FEMIXED (mixed finite-element) "
|
|
830
|
+
"zones. Write a .szplt file instead."
|
|
831
|
+
)
|
|
832
|
+
|
|
801
833
|
def write_poly_zone(
|
|
802
834
|
self,
|
|
803
835
|
data: Sequence[npt.ArrayLike],
|
tecio/_reader.py
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Every format's reader (SZL, PLT, DAT) exposes the same interface: :class:`TecplotReader`
|
|
4
4
|
(the open file/dataset), :class:`TecplotZoneReader` (one zone, split into
|
|
5
|
-
:class:`TecplotOrderedZoneReader`, :class:`TecplotFEZoneReader`,
|
|
6
|
-
:class:`TecplotPolyZoneReader` since the
|
|
7
|
-
dimensions or connectivity),
|
|
5
|
+
:class:`TecplotOrderedZoneReader`, :class:`TecplotFEZoneReader`,
|
|
6
|
+
:class:`TecplotFEMixedZoneReader`, and :class:`TecplotPolyZoneReader` since the
|
|
7
|
+
topologies don't share properties like dimensions or connectivity),
|
|
8
8
|
:class:`TecplotVariableReader` (one variable within a zone, not split by value location
|
|
9
9
|
or zone topology, neither changes which properties exist, only the shape
|
|
10
10
|
``get_values()`` returns, which the method already computes from
|
|
@@ -53,11 +53,13 @@ from ._constants import (
|
|
|
53
53
|
DataPacking,
|
|
54
54
|
DataType,
|
|
55
55
|
FaceNeighborMode,
|
|
56
|
+
FeCellShape,
|
|
56
57
|
FileType,
|
|
57
58
|
ValueLocation,
|
|
58
59
|
ZoneType,
|
|
59
60
|
)
|
|
60
61
|
from ._containers import VariableList, ZoneList, select_variable_arrays
|
|
62
|
+
from ._elements import faces_by_element, nodes_by_element
|
|
61
63
|
from ._utils import public_dir
|
|
62
64
|
|
|
63
65
|
# Nodes per element for the standard finite-element zone types. ORDERED zones are
|
|
@@ -959,6 +961,126 @@ class TecplotFEZoneReader(TecplotZoneReader):
|
|
|
959
961
|
)
|
|
960
962
|
|
|
961
963
|
|
|
964
|
+
# ======================================================================================
|
|
965
|
+
# TecplotFEMixedZoneReader
|
|
966
|
+
# ======================================================================================
|
|
967
|
+
|
|
968
|
+
|
|
969
|
+
class TecplotFEMixedZoneReader(TecplotZoneReader):
|
|
970
|
+
"""Read-only handle to one FEMIXED (mixed finite-element) zone.
|
|
971
|
+
|
|
972
|
+
A FEMIXED zone holds 1 to 16 sections. Every cell in a section has the same shape,
|
|
973
|
+
and all sections share one spatial dimension (all line, all surface or all volume
|
|
974
|
+
cells). Cell numbering runs through the sections in order, so cell-centered
|
|
975
|
+
variables hold ``num_elements`` values, the cells of section 0 first. All indices
|
|
976
|
+
are 0-based.
|
|
977
|
+
|
|
978
|
+
Args:
|
|
979
|
+
zone_index: 0-based zone index within the dataset.
|
|
980
|
+
title: Zone title.
|
|
981
|
+
solution_time: Solution time, 0.0 for static data.
|
|
982
|
+
strand_id: Strand ID, 0 for static data.
|
|
983
|
+
datapacking: On-disk value layout.
|
|
984
|
+
num_nodes: Number of nodes/points.
|
|
985
|
+
section_shapes: Cell shape of each section.
|
|
986
|
+
section_num_elements: Number of cells in each section.
|
|
987
|
+
shared_connectivity: 0-based source zone index if this zone's
|
|
988
|
+
connectivity is shared, else None.
|
|
989
|
+
"""
|
|
990
|
+
|
|
991
|
+
__slots__ = (
|
|
992
|
+
"_num_nodes",
|
|
993
|
+
"_section_shapes",
|
|
994
|
+
"_section_num_elements",
|
|
995
|
+
"_shared_connectivity",
|
|
996
|
+
"_node_maps_cache",
|
|
997
|
+
)
|
|
998
|
+
_num_nodes: int
|
|
999
|
+
_section_shapes: tuple[FeCellShape, ...]
|
|
1000
|
+
_section_num_elements: tuple[int, ...]
|
|
1001
|
+
_shared_connectivity: int | None
|
|
1002
|
+
_node_maps_cache: tuple[npt.NDArray[np.int64], ...] | None
|
|
1003
|
+
|
|
1004
|
+
def __init__(
|
|
1005
|
+
self,
|
|
1006
|
+
zone_index: int,
|
|
1007
|
+
title: str,
|
|
1008
|
+
solution_time: float,
|
|
1009
|
+
strand_id: int,
|
|
1010
|
+
datapacking: DataPacking,
|
|
1011
|
+
num_nodes: int,
|
|
1012
|
+
section_shapes: tuple[FeCellShape, ...],
|
|
1013
|
+
section_num_elements: tuple[int, ...],
|
|
1014
|
+
shared_connectivity: int | None,
|
|
1015
|
+
) -> None:
|
|
1016
|
+
super().__init__(
|
|
1017
|
+
zone_index=zone_index,
|
|
1018
|
+
title=title,
|
|
1019
|
+
zone_type=ZoneType.FEMIXED,
|
|
1020
|
+
solution_time=solution_time,
|
|
1021
|
+
strand_id=strand_id,
|
|
1022
|
+
datapacking=datapacking,
|
|
1023
|
+
)
|
|
1024
|
+
object.__setattr__(self, "_num_nodes", num_nodes)
|
|
1025
|
+
object.__setattr__(self, "_section_shapes", section_shapes)
|
|
1026
|
+
object.__setattr__(self, "_section_num_elements", section_num_elements)
|
|
1027
|
+
object.__setattr__(self, "_shared_connectivity", shared_connectivity)
|
|
1028
|
+
object.__setattr__(self, "_node_maps_cache", None)
|
|
1029
|
+
|
|
1030
|
+
def _repr_size(self) -> str:
|
|
1031
|
+
return (
|
|
1032
|
+
f"N={self._num_nodes}, E={self.num_elements}, S={len(self._section_shapes)}"
|
|
1033
|
+
)
|
|
1034
|
+
|
|
1035
|
+
@property
|
|
1036
|
+
def num_nodes(self) -> int:
|
|
1037
|
+
"""Number of nodes/points."""
|
|
1038
|
+
return self._num_nodes
|
|
1039
|
+
|
|
1040
|
+
@property
|
|
1041
|
+
def num_elements(self) -> int:
|
|
1042
|
+
"""Total number of elements/cells over all sections."""
|
|
1043
|
+
return sum(self._section_num_elements)
|
|
1044
|
+
|
|
1045
|
+
@property
|
|
1046
|
+
def num_sections(self) -> int:
|
|
1047
|
+
"""Number of sections, 1 to 16."""
|
|
1048
|
+
return len(self._section_shapes)
|
|
1049
|
+
|
|
1050
|
+
@property
|
|
1051
|
+
def section_shapes(self) -> tuple[FeCellShape, ...]:
|
|
1052
|
+
"""Cell shape of each section."""
|
|
1053
|
+
return self._section_shapes
|
|
1054
|
+
|
|
1055
|
+
@property
|
|
1056
|
+
def section_num_elements(self) -> tuple[int, ...]:
|
|
1057
|
+
"""Number of cells in each section."""
|
|
1058
|
+
return self._section_num_elements
|
|
1059
|
+
|
|
1060
|
+
@property
|
|
1061
|
+
def shared_connectivity(self) -> int | None:
|
|
1062
|
+
"""0-based source zone index if connectivity is shared, else None."""
|
|
1063
|
+
return self._shared_connectivity
|
|
1064
|
+
|
|
1065
|
+
@property
|
|
1066
|
+
def node_maps(self) -> tuple[npt.NDArray[np.int64], ...]:
|
|
1067
|
+
"""Node connectivity of each section, ``(section_num_elements, nodes)`` arrays.
|
|
1068
|
+
|
|
1069
|
+
The arrays are views of one allocation, loaded on first access. Node indices are
|
|
1070
|
+
0-based. Passing :attr:`section_shapes` and :attr:`node_maps` to
|
|
1071
|
+
:meth:`~tecio.TecplotSzlWriter.write_femixed_zone` writes the zone back.
|
|
1072
|
+
"""
|
|
1073
|
+
node_maps = self._node_maps_cache
|
|
1074
|
+
if node_maps is None:
|
|
1075
|
+
node_maps = self._load_node_maps()
|
|
1076
|
+
object.__setattr__(self, "_node_maps_cache", node_maps)
|
|
1077
|
+
return node_maps
|
|
1078
|
+
|
|
1079
|
+
@abstractmethod
|
|
1080
|
+
def _load_node_maps(self) -> tuple[npt.NDArray[np.int64], ...]:
|
|
1081
|
+
"""Read this zone's per-section connectivity. Called at most once, lazily."""
|
|
1082
|
+
|
|
1083
|
+
|
|
962
1084
|
# ======================================================================================
|
|
963
1085
|
# TecplotPolyZoneReader
|
|
964
1086
|
# ======================================================================================
|
|
@@ -1226,6 +1348,38 @@ class TecplotPolyZoneReader(TecplotZoneReader):
|
|
|
1226
1348
|
return np.zeros(0, dtype=np.int64)
|
|
1227
1349
|
return self._array("boundary_connection_zones")
|
|
1228
1350
|
|
|
1351
|
+
def element_faces(self) -> tuple[npt.NDArray[np.int64], npt.NDArray[np.int64]]:
|
|
1352
|
+
"""Return the faces of every element as ``(offsets, faces)``.
|
|
1353
|
+
|
|
1354
|
+
The faces of element ``e`` are ``faces[offsets[e]:offsets[e + 1]]``, in ascending
|
|
1355
|
+
face order. They come from :attr:`face_left_elements` and
|
|
1356
|
+
:attr:`face_right_elements`. A side that is no element of this zone (``-1`` or a
|
|
1357
|
+
boundary face reference) is skipped, so a face next to another zone is listed
|
|
1358
|
+
only for its own element. The arrays are computed on each call, not cached.
|
|
1359
|
+
|
|
1360
|
+
Returns:
|
|
1361
|
+
The ``offsets`` with shape ``(num_elements + 1,)`` and the flat ``faces``.
|
|
1362
|
+
"""
|
|
1363
|
+
return faces_by_element(
|
|
1364
|
+
self.face_left_elements, self.face_right_elements, self._num_elements
|
|
1365
|
+
)
|
|
1366
|
+
|
|
1367
|
+
def element_nodes(self) -> tuple[npt.NDArray[np.int64], npt.NDArray[np.int64]]:
|
|
1368
|
+
"""Return the distinct nodes of every element as ``(offsets, nodes)``.
|
|
1369
|
+
|
|
1370
|
+
The nodes of element ``e`` are ``nodes[offsets[e]:offsets[e + 1]]``. They are the
|
|
1371
|
+
nodes of the element's faces with repeats removed, in ascending order. That is a
|
|
1372
|
+
set, not a cell node order, because a polyhedron has no natural node order. The
|
|
1373
|
+
arrays are computed on each call, not cached.
|
|
1374
|
+
|
|
1375
|
+
Returns:
|
|
1376
|
+
The ``offsets`` with shape ``(num_elements + 1,)`` and the flat ``nodes``.
|
|
1377
|
+
"""
|
|
1378
|
+
offsets, faces = self.element_faces()
|
|
1379
|
+
return nodes_by_element(
|
|
1380
|
+
self.face_nodes, self.face_node_offsets, offsets, faces, self._num_nodes
|
|
1381
|
+
)
|
|
1382
|
+
|
|
1229
1383
|
|
|
1230
1384
|
# ======================================================================================
|
|
1231
1385
|
# TecplotReader
|
tecio/_szl_read.py
CHANGED
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
Small scalar zone metadata (title, type, dimensions or node/element counts, solution
|
|
4
4
|
time, strand ID, shared connectivity) is queried once, at zone construction, and frozen
|
|
5
5
|
by :class:`~tecio._reader.TecplotOrderedZoneReader` /
|
|
6
|
-
:class:`~tecio._reader.TecplotFEZoneReader
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
:class:`~tecio._reader.TecplotFEZoneReader` /
|
|
7
|
+
:class:`~tecio._reader.TecplotFEMixedZoneReader`. Variable metadata is queried live,
|
|
8
|
+
on each access, it's a single cheap C call either way. Variable data arrays and node
|
|
9
|
+
maps are read lazily, on first access, straight from the C library.
|
|
9
10
|
"""
|
|
10
11
|
|
|
11
12
|
from __future__ import annotations
|
|
@@ -22,13 +23,16 @@ from ._constants import (
|
|
|
22
23
|
DataPacking,
|
|
23
24
|
DataType,
|
|
24
25
|
FaceNeighborMode,
|
|
26
|
+
FeCellShape,
|
|
25
27
|
FileType,
|
|
26
28
|
ValueLocation,
|
|
27
29
|
ZoneType,
|
|
28
30
|
)
|
|
29
31
|
from ._containers import ZoneList
|
|
32
|
+
from ._elements import CELL_SHAPE_NUM_NODES
|
|
30
33
|
from ._reader import (
|
|
31
34
|
TecplotAuxDataReader,
|
|
35
|
+
TecplotFEMixedZoneReader,
|
|
32
36
|
TecplotFEZoneReader,
|
|
33
37
|
TecplotOrderedZoneReader,
|
|
34
38
|
TecplotReader,
|
|
@@ -458,6 +462,96 @@ class TecplotSzlFEZoneReader(TecplotFEZoneReader):
|
|
|
458
462
|
return TecplotSzlZoneAuxDataReader(self._handle, self.zone_index + 1)
|
|
459
463
|
|
|
460
464
|
|
|
465
|
+
class TecplotSzlFEMixedZoneReader(TecplotFEMixedZoneReader):
|
|
466
|
+
"""FEMIXED (mixed finite-element) zone reader for SZL files.
|
|
467
|
+
|
|
468
|
+
Scalar metadata and the section layout are queried from the C library once, at
|
|
469
|
+
construction, and frozen by the base class. The variable list, node maps, and aux
|
|
470
|
+
data stay lazily loaded on first access.
|
|
471
|
+
|
|
472
|
+
Raises:
|
|
473
|
+
NotImplementedError: If a section has a grid order above 1 (higher-order
|
|
474
|
+
elements) or a nonzero basis function.
|
|
475
|
+
"""
|
|
476
|
+
|
|
477
|
+
__slots__ = ("_handle", "_num_vars")
|
|
478
|
+
_handle: ctypes.c_void_p
|
|
479
|
+
_num_vars: int
|
|
480
|
+
|
|
481
|
+
def __init__(self, handle: ctypes.c_void_p, zone_index: int, num_vars: int) -> None:
|
|
482
|
+
zone_num = zone_index + 1
|
|
483
|
+
num_nodes, _, _ = libtecio.tec_zone_get_ijk(handle, zone_num)
|
|
484
|
+
shapes: list[FeCellShape] = []
|
|
485
|
+
counts: list[int] = []
|
|
486
|
+
for section in range(
|
|
487
|
+
1, libtecio.tec_zone_get_num_sections(handle, zone_num) + 1
|
|
488
|
+
):
|
|
489
|
+
shape, order, basis_fn, count, _ = libtecio.tec_zone_get_section_metrics(
|
|
490
|
+
handle, zone_num, section
|
|
491
|
+
)
|
|
492
|
+
if order != 1 or basis_fn != 0:
|
|
493
|
+
raise NotImplementedError(
|
|
494
|
+
f"Zone {zone_index} section {section - 1} has grid order {order} "
|
|
495
|
+
f"and basis function {basis_fn}; only linear sections (grid order "
|
|
496
|
+
"1, basis function 0) are supported."
|
|
497
|
+
)
|
|
498
|
+
shapes.append(shape)
|
|
499
|
+
counts.append(count)
|
|
500
|
+
raw_shared = libtecio.tec_zone_connectivity_get_shared_zone(handle, zone_num)
|
|
501
|
+
super().__init__(
|
|
502
|
+
zone_index=zone_index,
|
|
503
|
+
title=libtecio.tec_zone_get_title(handle, zone_num),
|
|
504
|
+
solution_time=libtecio.tec_zone_get_solution_time(handle, zone_num),
|
|
505
|
+
strand_id=libtecio.tec_zone_get_strand_id(handle, zone_num),
|
|
506
|
+
datapacking=DataPacking.BLOCK,
|
|
507
|
+
num_nodes=num_nodes,
|
|
508
|
+
section_shapes=tuple(shapes),
|
|
509
|
+
section_num_elements=tuple(counts),
|
|
510
|
+
shared_connectivity=raw_shared - 1 if raw_shared is not None else None,
|
|
511
|
+
)
|
|
512
|
+
object.__setattr__(self, "_handle", handle)
|
|
513
|
+
object.__setattr__(self, "_num_vars", num_vars)
|
|
514
|
+
|
|
515
|
+
def is_enabled(self) -> bool:
|
|
516
|
+
"""True if the zone is enabled (queried live).
|
|
517
|
+
|
|
518
|
+
SZL is the only format with a genuine per-zone enabled flag; PLT and DAT use the
|
|
519
|
+
base class default of always True.
|
|
520
|
+
|
|
521
|
+
Returns:
|
|
522
|
+
bool: ``True`` for an enabled zone.
|
|
523
|
+
"""
|
|
524
|
+
return _szl_zone_is_enabled(self._handle, self.zone_index)
|
|
525
|
+
|
|
526
|
+
def _load_variables(self) -> list[TecplotVariableReader]:
|
|
527
|
+
return _load_szl_variables(self._handle, self.zone_index, self._num_vars)
|
|
528
|
+
|
|
529
|
+
def _load_node_maps(self) -> tuple[npt.NDArray[np.int64], ...]:
|
|
530
|
+
shared = self.shared_connectivity
|
|
531
|
+
zone_num = (shared if shared is not None else self.zone_index) + 1
|
|
532
|
+
widths = [CELL_SHAPE_NUM_NODES[shape] for shape in self.section_shapes]
|
|
533
|
+
sizes = self.section_num_elements
|
|
534
|
+
raw = libtecio.tec_zone_node_map_get_flat(
|
|
535
|
+
self._handle,
|
|
536
|
+
zone_num,
|
|
537
|
+
self.num_elements,
|
|
538
|
+
sum(w * n for w, n in zip(widths, sizes, strict=True)),
|
|
539
|
+
libtecio.is_64bit(self._handle, zone_num),
|
|
540
|
+
)
|
|
541
|
+
# Node numbers from the C library are 1-based, convert to 0-based indices.
|
|
542
|
+
flat = np.subtract(raw, 1, dtype=np.int64)
|
|
543
|
+
maps: list[npt.NDArray[np.int64]] = []
|
|
544
|
+
start = 0
|
|
545
|
+
for width, size in zip(widths, sizes, strict=True):
|
|
546
|
+
stop = start + width * size
|
|
547
|
+
maps.append(flat[start:stop].reshape(size, width))
|
|
548
|
+
start = stop
|
|
549
|
+
return tuple(maps)
|
|
550
|
+
|
|
551
|
+
def _load_auxdata(self) -> TecplotAuxDataReader:
|
|
552
|
+
return TecplotSzlZoneAuxDataReader(self._handle, self.zone_index + 1)
|
|
553
|
+
|
|
554
|
+
|
|
461
555
|
def _build_szl_zone(
|
|
462
556
|
handle: ctypes.c_void_p, zone_index: int, num_vars: int
|
|
463
557
|
) -> TecplotZoneReader:
|
|
@@ -482,6 +576,8 @@ def _build_szl_zone(
|
|
|
482
576
|
f"Zone {zone_index} is {zone_type.name}; polygon and polyhedron zones "
|
|
483
577
|
"are not yet supported in SZPLT files."
|
|
484
578
|
)
|
|
579
|
+
if zone_type == ZoneType.FEMIXED:
|
|
580
|
+
return TecplotSzlFEMixedZoneReader(handle, zone_index, num_vars)
|
|
485
581
|
return TecplotSzlFEZoneReader(handle, zone_index, num_vars)
|
|
486
582
|
|
|
487
583
|
|