tecio-python 0.4.0__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 +46 -2
- tecio/_constants.py +2 -2
- tecio/_dat_read.py +268 -17
- tecio/_dat_write.py +347 -10
- tecio/_elements.py +1311 -0
- tecio/_io.py +108 -31
- tecio/_meta.py +47 -20
- tecio/_plt_legacy.py +9 -1
- tecio/_plt_read.py +285 -89
- tecio/_plt_write.py +286 -9
- tecio/_reader.py +460 -19
- tecio/_szl_read.py +155 -17
- tecio/_szl_write.py +322 -11
- tecio/_utils.py +78 -15
- tecio/_writer.py +963 -102
- tecio/cli/tec2mat.py +69 -30
- tecio/cli/tecaux.py +24 -30
- tecio/cli/tecdump.py +67 -5
- tecio/cli/tecelretyp.py +1096 -0
- tecio/cli/tecextract.py +57 -14
- tecio/cli/tecfix.py +32 -14
- tecio/cli/tecmerge.py +289 -45
- tecio/cli/teconvert.py +29 -16
- tecio/cli/tecscale.py +40 -13
- tecio/cli/tecslice.py +158 -69
- tecio/cli/tecstats.py +6 -2
- tecio/libtecio.py +192 -67
- {tecio_python-0.4.0.data/data/share → tecio_python-0.4.2.data/data/share/tecio}/plugins/matlab/tecmat2struct.m +18 -18
- {tecio_python-0.4.0.data/data/share → tecio_python-0.4.2.data/data/share/tecio}/plugins/paraview/TecplotTecioReader.py +463 -38
- {tecio_python-0.4.0.data/data/share → tecio_python-0.4.2.data/data/share/tecio}/plugins/paraview/TecplotTecioWriter.py +459 -84
- {tecio_python-0.4.0.dist-info → tecio_python-0.4.2.dist-info}/METADATA +33 -17
- tecio_python-0.4.2.dist-info/RECORD +40 -0
- {tecio_python-0.4.0.dist-info → tecio_python-0.4.2.dist-info}/WHEEL +1 -1
- {tecio_python-0.4.0.dist-info → tecio_python-0.4.2.dist-info}/entry_points.txt +1 -0
- tecio_python-0.4.0.dist-info/RECORD +0 -38
- {tecio_python-0.4.0.data/data/share → tecio_python-0.4.2.data/data/share/tecio}/plugins/matlab/contourfe.m +0 -0
- {tecio_python-0.4.0.dist-info → tecio_python-0.4.2.dist-info}/licenses/LICENSE +0 -0
- {tecio_python-0.4.0.dist-info → tecio_python-0.4.2.dist-info}/licenses/NOTICE +0 -0
- {tecio_python-0.4.0.dist-info → tecio_python-0.4.2.dist-info}/top_level.txt +0 -0
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,
|
|
@@ -142,7 +146,11 @@ class TecplotSzlVariableReader(TecplotVariableReader):
|
|
|
142
146
|
return libtecio.tec_var_get_name(self._handle, self.var_index + 1)
|
|
143
147
|
|
|
144
148
|
def is_enabled(self) -> bool:
|
|
145
|
-
"""True if the variable is enabled (dataset-level flag, queried live).
|
|
149
|
+
"""True if the variable is enabled (dataset-level flag, queried live).
|
|
150
|
+
|
|
151
|
+
Returns:
|
|
152
|
+
bool: ``True`` for an enabled variable.
|
|
153
|
+
"""
|
|
146
154
|
return libtecio.tec_var_is_enabled(self._handle, self.var_index + 1)
|
|
147
155
|
|
|
148
156
|
@property
|
|
@@ -173,14 +181,22 @@ class TecplotSzlVariableReader(TecplotVariableReader):
|
|
|
173
181
|
)
|
|
174
182
|
|
|
175
183
|
def is_passive(self) -> bool:
|
|
176
|
-
"""True if this variable is passive in this zone.
|
|
184
|
+
"""True if this variable is passive in this zone.
|
|
185
|
+
|
|
186
|
+
Returns:
|
|
187
|
+
bool: ``True`` for a passive variable.
|
|
188
|
+
"""
|
|
177
189
|
return libtecio.tec_zone_var_is_passive(
|
|
178
190
|
self._handle, self.zone_index + 1, self.var_index + 1
|
|
179
191
|
)
|
|
180
192
|
|
|
181
193
|
@property
|
|
182
194
|
def num_values(self) -> int:
|
|
183
|
-
"""Number of values in the data array.
|
|
195
|
+
"""Number of values in the data array.
|
|
196
|
+
|
|
197
|
+
Returns:
|
|
198
|
+
int: Number of values.
|
|
199
|
+
"""
|
|
184
200
|
return libtecio.tec_zone_var_get_num_values(
|
|
185
201
|
self._handle, self._data_zone() + 1, self.var_index + 1
|
|
186
202
|
)
|
|
@@ -280,12 +296,20 @@ class TecplotSzlVariableReader(TecplotVariableReader):
|
|
|
280
296
|
def _load_szl_variables(
|
|
281
297
|
handle: ctypes.c_void_p, zone_index: int, num_vars: int
|
|
282
298
|
) -> list[TecplotVariableReader]:
|
|
283
|
-
"""Build this zone's variable readers. Shared by both SZL zone classes.
|
|
299
|
+
"""Build this zone's variable readers. Shared by both SZL zone classes.
|
|
300
|
+
|
|
301
|
+
Returns:
|
|
302
|
+
list: One reader per variable of the zone.
|
|
303
|
+
"""
|
|
284
304
|
return [TecplotSzlVariableReader(handle, zone_index, i) for i in range(num_vars)]
|
|
285
305
|
|
|
286
306
|
|
|
287
307
|
def _szl_zone_is_enabled(handle: ctypes.c_void_p, zone_index: int) -> bool:
|
|
288
|
-
"""Query the C library's per-zone enabled flag. Shared by both SZL zone classes.
|
|
308
|
+
"""Query the C library's per-zone enabled flag. Shared by both SZL zone classes.
|
|
309
|
+
|
|
310
|
+
Returns:
|
|
311
|
+
bool: ``True`` if the zone is enabled.
|
|
312
|
+
"""
|
|
289
313
|
return libtecio.tec_zone_is_enabled(handle, zone_index + 1)
|
|
290
314
|
|
|
291
315
|
|
|
@@ -296,9 +320,9 @@ class TecplotSzlOrderedZoneReader(TecplotOrderedZoneReader):
|
|
|
296
320
|
the base class. The variable list and aux data stay lazily loaded on first access.
|
|
297
321
|
"""
|
|
298
322
|
|
|
299
|
-
__slots__ = ("_handle", "
|
|
323
|
+
__slots__ = ("_handle", "_num_vars")
|
|
300
324
|
_handle: ctypes.c_void_p
|
|
301
|
-
|
|
325
|
+
_num_vars: int
|
|
302
326
|
|
|
303
327
|
def __init__(self, handle: ctypes.c_void_p, zone_index: int, num_vars: int) -> None:
|
|
304
328
|
zone_num = zone_index + 1
|
|
@@ -314,18 +338,21 @@ class TecplotSzlOrderedZoneReader(TecplotOrderedZoneReader):
|
|
|
314
338
|
k=k,
|
|
315
339
|
)
|
|
316
340
|
object.__setattr__(self, "_handle", handle)
|
|
317
|
-
object.__setattr__(self, "
|
|
341
|
+
object.__setattr__(self, "_num_vars", num_vars)
|
|
318
342
|
|
|
319
343
|
def is_enabled(self) -> bool:
|
|
320
344
|
"""True if the zone is enabled (queried live).
|
|
321
345
|
|
|
322
346
|
SZL is the only format with a genuine per-zone enabled flag; PLT and
|
|
323
347
|
DAT use the base class default of always True.
|
|
348
|
+
|
|
349
|
+
Returns:
|
|
350
|
+
bool: ``True`` for an enabled zone.
|
|
324
351
|
"""
|
|
325
352
|
return _szl_zone_is_enabled(self._handle, self.zone_index)
|
|
326
353
|
|
|
327
354
|
def _load_variables(self) -> list[TecplotVariableReader]:
|
|
328
|
-
return _load_szl_variables(self._handle, self.zone_index, self.
|
|
355
|
+
return _load_szl_variables(self._handle, self.zone_index, self._num_vars)
|
|
329
356
|
|
|
330
357
|
def _load_auxdata(self) -> TecplotAuxDataReader:
|
|
331
358
|
return TecplotSzlZoneAuxDataReader(self._handle, self.zone_index + 1)
|
|
@@ -339,9 +366,9 @@ class TecplotSzlFEZoneReader(TecplotFEZoneReader):
|
|
|
339
366
|
first access.
|
|
340
367
|
"""
|
|
341
368
|
|
|
342
|
-
__slots__ = ("_handle", "
|
|
369
|
+
__slots__ = ("_handle", "_num_vars")
|
|
343
370
|
_handle: ctypes.c_void_p
|
|
344
|
-
|
|
371
|
+
_num_vars: int
|
|
345
372
|
|
|
346
373
|
def __init__(self, handle: ctypes.c_void_p, zone_index: int, num_vars: int) -> None:
|
|
347
374
|
zone_num = zone_index + 1
|
|
@@ -361,18 +388,21 @@ class TecplotSzlFEZoneReader(TecplotFEZoneReader):
|
|
|
361
388
|
shared_connectivity=shared_connectivity,
|
|
362
389
|
)
|
|
363
390
|
object.__setattr__(self, "_handle", handle)
|
|
364
|
-
object.__setattr__(self, "
|
|
391
|
+
object.__setattr__(self, "_num_vars", num_vars)
|
|
365
392
|
|
|
366
393
|
def is_enabled(self) -> bool:
|
|
367
394
|
"""True if the zone is enabled (queried live).
|
|
368
395
|
|
|
369
396
|
SZL is the only format with a genuine per-zone enabled flag; PLT and DAT use the
|
|
370
397
|
base class default of always True.
|
|
398
|
+
|
|
399
|
+
Returns:
|
|
400
|
+
bool: ``True`` for an enabled zone.
|
|
371
401
|
"""
|
|
372
402
|
return _szl_zone_is_enabled(self._handle, self.zone_index)
|
|
373
403
|
|
|
374
404
|
def _load_variables(self) -> list[TecplotVariableReader]:
|
|
375
|
-
return _load_szl_variables(self._handle, self.zone_index, self.
|
|
405
|
+
return _load_szl_variables(self._handle, self.zone_index, self._num_vars)
|
|
376
406
|
|
|
377
407
|
def _connectivity_zone(self) -> int:
|
|
378
408
|
"""Return the 0-based zone index that holds this zone's connectivity."""
|
|
@@ -432,6 +462,96 @@ class TecplotSzlFEZoneReader(TecplotFEZoneReader):
|
|
|
432
462
|
return TecplotSzlZoneAuxDataReader(self._handle, self.zone_index + 1)
|
|
433
463
|
|
|
434
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
|
+
|
|
435
555
|
def _build_szl_zone(
|
|
436
556
|
handle: ctypes.c_void_p, zone_index: int, num_vars: int
|
|
437
557
|
) -> TecplotZoneReader:
|
|
@@ -440,10 +560,24 @@ def _build_szl_zone(
|
|
|
440
560
|
A single ``.szplt`` file commonly holds a mix of ORDERED and FE zones, so this
|
|
441
561
|
queries the C library for the zone type first, cheap, one call, then dispatches to
|
|
442
562
|
the matching class.
|
|
563
|
+
|
|
564
|
+
Returns:
|
|
565
|
+
TecplotZoneReader: The zone reader class that matches the zone type.
|
|
566
|
+
|
|
567
|
+
Raises:
|
|
568
|
+
NotImplementedError: For polygon and polyhedron zones, which only the PLT and
|
|
569
|
+
DAT readers support.
|
|
443
570
|
"""
|
|
444
571
|
zone_type = ZoneType(libtecio.tec_zone_get_type(handle, zone_index + 1))
|
|
445
572
|
if zone_type == ZoneType.ORDERED:
|
|
446
573
|
return TecplotSzlOrderedZoneReader(handle, zone_index, num_vars)
|
|
574
|
+
if zone_type in (ZoneType.FEPOLYGON, ZoneType.FEPOLYHEDRON): # pragma: no cover
|
|
575
|
+
raise NotImplementedError(
|
|
576
|
+
f"Zone {zone_index} is {zone_type.name}; polygon and polyhedron zones "
|
|
577
|
+
"are not yet supported in SZPLT files."
|
|
578
|
+
)
|
|
579
|
+
if zone_type == ZoneType.FEMIXED:
|
|
580
|
+
return TecplotSzlFEMixedZoneReader(handle, zone_index, num_vars)
|
|
447
581
|
return TecplotSzlFEZoneReader(handle, zone_index, num_vars)
|
|
448
582
|
|
|
449
583
|
|
|
@@ -478,7 +612,11 @@ class TecplotSzlReader(TecplotReader):
|
|
|
478
612
|
self._dataset_auxdata: TecplotAuxDataReader | None = None
|
|
479
613
|
|
|
480
614
|
def _check_handle(self) -> ctypes.c_void_p:
|
|
481
|
-
"""Return the file handle, or raise if the reader has been closed.
|
|
615
|
+
"""Return the file handle, or raise if the reader has been closed.
|
|
616
|
+
|
|
617
|
+
Raises:
|
|
618
|
+
ValueError: If the reader has been closed.
|
|
619
|
+
"""
|
|
482
620
|
if self._handle is None:
|
|
483
621
|
raise ValueError(f"I/O operation on closed file: '{self._path}'")
|
|
484
622
|
return self._handle
|