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/cli/tecextract.py
CHANGED
|
@@ -100,6 +100,7 @@ from typing import Any
|
|
|
100
100
|
import numpy as np
|
|
101
101
|
|
|
102
102
|
from .. import (
|
|
103
|
+
TecplotFEMixedZoneReader,
|
|
103
104
|
TecplotFEZoneReader,
|
|
104
105
|
TecplotOrderedZoneReader,
|
|
105
106
|
TecplotPolyZoneReader,
|
|
@@ -486,10 +487,28 @@ def main(argv: Sequence[str] | None = None) -> int:
|
|
|
486
487
|
con_sharing=con_remapped,
|
|
487
488
|
**fe_kw,
|
|
488
489
|
)
|
|
490
|
+
elif isinstance(zone, TecplotFEMixedZoneReader):
|
|
491
|
+
con_src = zone.shared_connectivity
|
|
492
|
+
con_remapped = (
|
|
493
|
+
zone_index_map.get(con_src) if con_src is not None else None
|
|
494
|
+
)
|
|
495
|
+
writer.write_femixed_zone(
|
|
496
|
+
data=data,
|
|
497
|
+
cell_shapes=(
|
|
498
|
+
None
|
|
499
|
+
if con_remapped is not None
|
|
500
|
+
else zone.section_shapes
|
|
501
|
+
),
|
|
502
|
+
node_maps=(
|
|
503
|
+
None if con_remapped is not None else zone.node_maps
|
|
504
|
+
),
|
|
505
|
+
con_sharing=con_remapped,
|
|
506
|
+
**common_kw,
|
|
507
|
+
)
|
|
489
508
|
else:
|
|
490
509
|
raise NotImplementedError(
|
|
491
|
-
f"Zone '{zone.title}' is neither an ordered, classic FE "
|
|
492
|
-
"nor poly zone; extraction is not supported for it."
|
|
510
|
+
f"Zone '{zone.title}' is neither an ordered, classic FE, "
|
|
511
|
+
"FEMIXED nor poly zone; extraction is not supported for it."
|
|
493
512
|
)
|
|
494
513
|
|
|
495
514
|
# Record where this source zone landed in the output, so a later
|
tecio/cli/tecfix.py
CHANGED
|
@@ -102,6 +102,7 @@ import numpy.typing as npt
|
|
|
102
102
|
|
|
103
103
|
from .. import (
|
|
104
104
|
DataType,
|
|
105
|
+
TecplotFEMixedZoneReader,
|
|
105
106
|
TecplotFEZoneReader,
|
|
106
107
|
TecplotOrderedZoneReader,
|
|
107
108
|
TecplotPolyZoneReader,
|
|
@@ -514,10 +515,24 @@ def main(argv: Sequence[str] | None = None) -> int:
|
|
|
514
515
|
con_sharing=con_sharing,
|
|
515
516
|
**fe_kw,
|
|
516
517
|
)
|
|
518
|
+
elif isinstance(zone, TecplotFEMixedZoneReader):
|
|
519
|
+
con_sharing = zone.shared_connectivity
|
|
520
|
+
writer.write_femixed_zone(
|
|
521
|
+
data=writer_data,
|
|
522
|
+
cell_shapes=(
|
|
523
|
+
None if con_sharing is not None else zone.section_shapes
|
|
524
|
+
),
|
|
525
|
+
node_maps=None
|
|
526
|
+
if con_sharing is not None
|
|
527
|
+
else zone.node_maps,
|
|
528
|
+
con_sharing=con_sharing,
|
|
529
|
+
**common_kw,
|
|
530
|
+
)
|
|
517
531
|
else:
|
|
518
532
|
raise NotImplementedError(
|
|
519
533
|
f"Zone '{zone.title}' is neither an ordered nor a "
|
|
520
|
-
"classic FE or poly zone; fixing is not supported
|
|
534
|
+
"classic FE, FEMIXED or poly zone; fixing is not supported "
|
|
535
|
+
"for it."
|
|
521
536
|
)
|
|
522
537
|
|
|
523
538
|
except Exception as exc: # noqa: BLE001
|
tecio/cli/tecmerge.py
CHANGED
|
@@ -78,19 +78,27 @@ duplicated in every merged zone.
|
|
|
78
78
|
|
|
79
79
|
``--merge-grid [LIST]``
|
|
80
80
|
Detect and share grid data (coordinate variables, and for FE zones,
|
|
81
|
-
connectivity) across zones with
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
81
|
+
connectivity) across zones with the same grid, instead of writing it fresh in
|
|
82
|
+
every merged zone. Zones are first grouped by a ``(zone_type, num_nodes,
|
|
83
|
+
num_elements)`` signature, then compared with every earlier zone of the group
|
|
84
|
+
that wrote its grid. A zone shares from the first one with the same grid and
|
|
85
|
+
writes its own grid if there is none, so blocks that only share their size are
|
|
86
|
+
never mixed up. Grid variables stored in the same order are equal when they
|
|
87
|
+
agree to within 1e-8 of their largest absolute value, which allows for text
|
|
88
|
+
files rounding their values.
|
|
89
|
+
|
|
90
|
+
FE zones whose nodes or cells are stored in another order, for example the same
|
|
91
|
+
mesh in a PLT and an SZPLT file, share the grid of the earlier zone too. Their
|
|
92
|
+
nodal and cell-centered variables are put in the order of that zone as they are
|
|
93
|
+
written. This needs coordinates that are exactly equal, and is not done for a
|
|
94
|
+
zone with face neighbor connections, which refer to its cells. Ordered zones
|
|
95
|
+
must match in their stored order. Polygon and polyhedron zones are matched on a
|
|
96
|
+
hash of their full face map and must also have the same grid variables. Poly
|
|
97
|
+
zones with boundary face connections cannot be shared because boundary
|
|
98
|
+
connections must be uniquely defined. A zone whose grid variables are missing
|
|
99
|
+
or passive can neither share nor be shared from. If a zone only contains grid
|
|
100
|
+
or passive variables, it cannot be merged because there would be no active data
|
|
101
|
+
in the zone.
|
|
94
102
|
|
|
95
103
|
Given with no value, grid variables are found automatically by name (``x``,
|
|
96
104
|
``X``, ``x-coordinate``, ``xgrid``, and similar common names for X/Y/Z). Given a
|
|
@@ -166,11 +174,13 @@ import glob
|
|
|
166
174
|
import sys
|
|
167
175
|
from collections.abc import Sequence
|
|
168
176
|
from pathlib import Path
|
|
169
|
-
from typing import Any
|
|
177
|
+
from typing import Any, NamedTuple, cast
|
|
170
178
|
|
|
171
179
|
import numpy as np
|
|
180
|
+
import numpy.typing as npt
|
|
172
181
|
|
|
173
182
|
from .. import (
|
|
183
|
+
TecplotFEMixedZoneReader,
|
|
174
184
|
TecplotFEZoneReader,
|
|
175
185
|
TecplotOrderedZoneReader,
|
|
176
186
|
TecplotPolyZoneReader,
|
|
@@ -178,6 +188,9 @@ from .. import (
|
|
|
178
188
|
TecplotSzlWriter,
|
|
179
189
|
TecplotWriter,
|
|
180
190
|
TecplotZoneReader,
|
|
191
|
+
ValueLocation,
|
|
192
|
+
match_cells,
|
|
193
|
+
match_nodes,
|
|
181
194
|
)
|
|
182
195
|
from .. import open as tecio_open
|
|
183
196
|
from .._writer import poly_face_kwargs
|
|
@@ -331,7 +344,8 @@ def _parse_args(argv: Sequence[str] | None = None) -> argparse.Namespace:
|
|
|
331
344
|
metavar="LIST",
|
|
332
345
|
help=(
|
|
333
346
|
"Detect and share the grid (coordinate variables, and connectivity for FE "
|
|
334
|
-
"zones)
|
|
347
|
+
"zones) of zones that have the same grid, even if an FE zone stores its "
|
|
348
|
+
"nodes and cells in another order. To manually specify grid "
|
|
335
349
|
"coordinates provide a comma-separated list of 1-based indices or exact "
|
|
336
350
|
"variable names (e.g. -merge-grid x,y,z or -merge-grid 1,2,3)."
|
|
337
351
|
),
|
|
@@ -567,6 +581,144 @@ def _build_var_union(
|
|
|
567
581
|
return union_vars, index_maps
|
|
568
582
|
|
|
569
583
|
|
|
584
|
+
# Grids stored in the same order are equal when no coordinate differs by more than this
|
|
585
|
+
# fraction of the largest absolute value of the variable. Text files round their values.
|
|
586
|
+
_GRID_RTOL = 1e-8
|
|
587
|
+
|
|
588
|
+
|
|
589
|
+
class _Grid(NamedTuple):
|
|
590
|
+
"""The grid variables of one zone, as read for comparing grids."""
|
|
591
|
+
|
|
592
|
+
locals: list[int]
|
|
593
|
+
arrays: list[npt.NDArray[Any]]
|
|
594
|
+
bounds: tuple[Any, ...]
|
|
595
|
+
|
|
596
|
+
|
|
597
|
+
class _GridSource(NamedTuple):
|
|
598
|
+
"""A zone already written with its own grid that later zones may share."""
|
|
599
|
+
|
|
600
|
+
output_zone: int
|
|
601
|
+
zone: TecplotZoneReader
|
|
602
|
+
locals: list[int]
|
|
603
|
+
bounds: tuple[Any, ...]
|
|
604
|
+
|
|
605
|
+
|
|
606
|
+
class _GridMatch(NamedTuple):
|
|
607
|
+
"""How the grid of a zone is ordered relative to a :class:`_GridSource`.
|
|
608
|
+
|
|
609
|
+
``None`` means the order is the same. Otherwise ``values[order]`` puts a nodal or
|
|
610
|
+
cell-centered array of the zone in the order of the source.
|
|
611
|
+
"""
|
|
612
|
+
|
|
613
|
+
node_order: npt.NDArray[np.intp] | None
|
|
614
|
+
cell_order: npt.NDArray[np.intp] | None
|
|
615
|
+
|
|
616
|
+
|
|
617
|
+
def _read_grid(
|
|
618
|
+
zone: TecplotZoneReader,
|
|
619
|
+
local_index_map: list[int | None],
|
|
620
|
+
grid_var_indices: set[int],
|
|
621
|
+
) -> _Grid | None:
|
|
622
|
+
"""Read the grid variables of *zone* so that its grid can be compared.
|
|
623
|
+
|
|
624
|
+
Returns:
|
|
625
|
+
The local variable indices, the values and their ``(min, max)`` bounds, or
|
|
626
|
+
``None`` if a grid variable is missing, passive or not nodal, so that the zone
|
|
627
|
+
has no grid to compare.
|
|
628
|
+
"""
|
|
629
|
+
locals_: list[int] = []
|
|
630
|
+
arrays: list[npt.NDArray[Any]] = []
|
|
631
|
+
bounds: list[Any] = []
|
|
632
|
+
for union_i, local_idx in enumerate(local_index_map, start=1):
|
|
633
|
+
if union_i not in grid_var_indices:
|
|
634
|
+
continue
|
|
635
|
+
if local_idx is None:
|
|
636
|
+
return None
|
|
637
|
+
var = zone.variables[local_idx]
|
|
638
|
+
values = None if var.is_passive() else var.values
|
|
639
|
+
if values is None or var.value_location != ValueLocation.NODAL:
|
|
640
|
+
return None
|
|
641
|
+
locals_.append(local_idx)
|
|
642
|
+
arrays.append(values)
|
|
643
|
+
bounds.append(
|
|
644
|
+
(float(values.min()), float(values.max())) if values.size else None
|
|
645
|
+
)
|
|
646
|
+
return _Grid(locals_, arrays, tuple(bounds))
|
|
647
|
+
|
|
648
|
+
|
|
649
|
+
def _match_grid(
|
|
650
|
+
source: _GridSource, zone: TecplotZoneReader, grid: _Grid
|
|
651
|
+
) -> _GridMatch | None:
|
|
652
|
+
"""Check that *zone* has the grid of *source*, in the same order or another.
|
|
653
|
+
|
|
654
|
+
Grid variables stored in the same order are equal when they agree to within
|
|
655
|
+
``_GRID_RTOL``. For a classic FE zone the node maps must also describe the same
|
|
656
|
+
cells. When the nodes or cells are in another order, the orders are found with
|
|
657
|
+
:func:`~tecio.match_nodes` and :func:`~tecio.match_cells`, which need coordinates
|
|
658
|
+
that are exactly equal. Ordered and poly zones are not reordered because their
|
|
659
|
+
structure fixes the order, and neither is a zone with face neighbor connections,
|
|
660
|
+
which refer to its cells.
|
|
661
|
+
|
|
662
|
+
Returns:
|
|
663
|
+
How to reorder the data of *zone* to share the grid, or ``None`` if the grids
|
|
664
|
+
differ and cannot be shared.
|
|
665
|
+
"""
|
|
666
|
+
tolerances = [
|
|
667
|
+
_GRID_RTOL * max(abs(b[0]), abs(b[1])) if b is not None else 0.0
|
|
668
|
+
for b in source.bounds
|
|
669
|
+
]
|
|
670
|
+
for ref_bounds, bounds, tol in zip(
|
|
671
|
+
source.bounds, grid.bounds, tolerances, strict=True
|
|
672
|
+
):
|
|
673
|
+
if ref_bounds != bounds and (
|
|
674
|
+
ref_bounds is None
|
|
675
|
+
or bounds is None
|
|
676
|
+
or any(abs(r - g) > tol for r, g in zip(ref_bounds, bounds, strict=True))
|
|
677
|
+
):
|
|
678
|
+
return None
|
|
679
|
+
# Registered sources only hold grid variables that have values
|
|
680
|
+
ref_arrays = [
|
|
681
|
+
cast(npt.NDArray[Any], source.zone.variables[i].values) for i in source.locals
|
|
682
|
+
]
|
|
683
|
+
ref_map = got_map = None
|
|
684
|
+
reorderable = False
|
|
685
|
+
if isinstance(zone, TecplotFEZoneReader) and isinstance(
|
|
686
|
+
source.zone, TecplotFEZoneReader
|
|
687
|
+
):
|
|
688
|
+
ref_map, got_map = source.zone.node_map, zone.node_map
|
|
689
|
+
reorderable = (
|
|
690
|
+
zone.face_neighbor_mode is None
|
|
691
|
+
and ref_map is not None
|
|
692
|
+
and got_map is not None
|
|
693
|
+
)
|
|
694
|
+
same_nodes = all(
|
|
695
|
+
np.allclose(g, r, rtol=0.0, atol=tol)
|
|
696
|
+
for r, g, tol in zip(ref_arrays, grid.arrays, tolerances, strict=True)
|
|
697
|
+
)
|
|
698
|
+
same_cells = (ref_map is None and got_map is None) or (
|
|
699
|
+
ref_map is not None and got_map is not None and np.array_equal(ref_map, got_map)
|
|
700
|
+
)
|
|
701
|
+
if same_nodes and same_cells:
|
|
702
|
+
return _GridMatch(None, None)
|
|
703
|
+
if not reorderable or ref_map is None or got_map is None:
|
|
704
|
+
return None
|
|
705
|
+
|
|
706
|
+
node_order = None
|
|
707
|
+
if ref_arrays and not same_nodes:
|
|
708
|
+
node_order = match_nodes(ref_arrays, grid.arrays)
|
|
709
|
+
if node_order is None:
|
|
710
|
+
return None
|
|
711
|
+
cell_order = match_cells([ref_map], [got_map], node_order)
|
|
712
|
+
if cell_order is None:
|
|
713
|
+
return None
|
|
714
|
+
# Orders that leave everything where it is need no reordering of the data
|
|
715
|
+
identity = [
|
|
716
|
+
None if o is None or np.array_equal(o, np.arange(len(o))) else o
|
|
717
|
+
for o in (node_order, cell_order)
|
|
718
|
+
]
|
|
719
|
+
return _GridMatch(*identity)
|
|
720
|
+
|
|
721
|
+
|
|
570
722
|
def _has_own_data(
|
|
571
723
|
zone: TecplotZoneReader,
|
|
572
724
|
local_index_map: list[int | None],
|
|
@@ -596,6 +748,7 @@ def _write_zone(
|
|
|
596
748
|
source_path: Path,
|
|
597
749
|
grid_var_indices: set[int] | None,
|
|
598
750
|
grid_reference: int | None,
|
|
751
|
+
grid_match: _GridMatch | None = None,
|
|
599
752
|
) -> None:
|
|
600
753
|
"""Write one zone to *writer* using the reconciled variable list.
|
|
601
754
|
|
|
@@ -619,11 +772,14 @@ def _write_zone(
|
|
|
619
772
|
or ``None`` if the feature is off.
|
|
620
773
|
grid_reference: 1-based output zone index to share this zone's grid variables
|
|
621
774
|
(and, for FE zones, connectivity) from, if an earlier zone
|
|
622
|
-
with
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
775
|
+
with the same grid was already written, else ``None`` (this
|
|
776
|
+
zone's grid is written fresh; the caller is responsible for
|
|
777
|
+
registering it afterward). Ignored entirely when
|
|
778
|
+
*grid_var_indices* is ``None``.
|
|
779
|
+
grid_match: How the grid of this zone is ordered relative to the zone of
|
|
780
|
+
*grid_reference*. The nodal and cell-centered variables
|
|
781
|
+
written for this zone are put in the order of that zone.
|
|
782
|
+
``None`` leaves them as they are.
|
|
627
783
|
"""
|
|
628
784
|
zt = zone.zone_type
|
|
629
785
|
|
|
@@ -637,8 +793,8 @@ def _write_zone(
|
|
|
637
793
|
is_grid_var = grid_var_indices is not None and union_i in grid_var_indices
|
|
638
794
|
|
|
639
795
|
if is_grid_var and grid_reference is not None:
|
|
640
|
-
# An earlier zone with the same
|
|
641
|
-
#
|
|
796
|
+
# An earlier zone with the same grid already wrote it so share rather than
|
|
797
|
+
# duplicate
|
|
642
798
|
var_sharing[name] = grid_reference
|
|
643
799
|
continue
|
|
644
800
|
|
|
@@ -666,6 +822,11 @@ def _write_zone(
|
|
|
666
822
|
if arr is None or arr.size == 0:
|
|
667
823
|
passive_vars.add(name)
|
|
668
824
|
else:
|
|
825
|
+
if grid_match is not None:
|
|
826
|
+
is_cell = var.value_location == ValueLocation.CELL_CENTERED
|
|
827
|
+
order = grid_match.cell_order if is_cell else grid_match.node_order
|
|
828
|
+
if order is not None:
|
|
829
|
+
arr = arr[order]
|
|
669
830
|
data.append(arr)
|
|
670
831
|
value_locations.append(var.value_location)
|
|
671
832
|
|
|
@@ -711,9 +872,8 @@ def _write_zone(
|
|
|
711
872
|
)
|
|
712
873
|
elif isinstance(zone, TecplotFEZoneReader):
|
|
713
874
|
if grid_var_indices is not None and grid_reference is not None:
|
|
714
|
-
# Share connectivity from the same reference zone as the grid variables,
|
|
715
|
-
#
|
|
716
|
-
# mesh, node map included.
|
|
875
|
+
# Share connectivity from the same reference zone as the grid variables,
|
|
876
|
+
# its node map describes the same cells.
|
|
717
877
|
con_remapped = grid_reference
|
|
718
878
|
else:
|
|
719
879
|
con_src = zone.shared_connectivity
|
|
@@ -733,9 +893,19 @@ def _write_zone(
|
|
|
733
893
|
con_sharing=con_remapped,
|
|
734
894
|
**fe_kw,
|
|
735
895
|
)
|
|
896
|
+
elif isinstance(zone, TecplotFEMixedZoneReader):
|
|
897
|
+
con_src = zone.shared_connectivity
|
|
898
|
+
con_remapped = zone_index_map.get(con_src) if con_src is not None else None
|
|
899
|
+
writer.write_femixed_zone(
|
|
900
|
+
data=data,
|
|
901
|
+
cell_shapes=None if con_remapped is not None else zone.section_shapes,
|
|
902
|
+
node_maps=None if con_remapped is not None else zone.node_maps,
|
|
903
|
+
con_sharing=con_remapped,
|
|
904
|
+
**common_kw,
|
|
905
|
+
)
|
|
736
906
|
else:
|
|
737
907
|
raise NotImplementedError(
|
|
738
|
-
f"Zone '{zone.title}' is neither an ordered, classic FE nor poly "
|
|
908
|
+
f"Zone '{zone.title}' is neither an ordered, classic FE, FEMIXED nor poly "
|
|
739
909
|
"zone; merging is not supported for it."
|
|
740
910
|
)
|
|
741
911
|
|
|
@@ -865,8 +1035,9 @@ def main(argv: Sequence[str] | None = None) -> int:
|
|
|
865
1035
|
writer.add_auxvar_dict(auxvar)
|
|
866
1036
|
|
|
867
1037
|
total_zones = 0
|
|
868
|
-
# Persists
|
|
869
|
-
|
|
1038
|
+
# Persists across every input file for merge grid option: the zones that
|
|
1039
|
+
# wrote a grid, by (zone_type, num_nodes, num_elements) or face map hash
|
|
1040
|
+
grid_registry: dict[tuple[Any, ...], list[_GridSource]] = {}
|
|
870
1041
|
for fi, (reader, imap) in enumerate(zip(readers, index_maps, strict=False)):
|
|
871
1042
|
sol_time = times[fi] if times is not None else None
|
|
872
1043
|
|
|
@@ -890,7 +1061,9 @@ def main(argv: Sequence[str] | None = None) -> int:
|
|
|
890
1061
|
s_id = zone_num + args.strand_offset
|
|
891
1062
|
|
|
892
1063
|
grid_reference: int | None = None
|
|
1064
|
+
grid_match: _GridMatch | None = None
|
|
893
1065
|
signature: tuple[Any, ...] | None = None
|
|
1066
|
+
grid: _Grid | None = None
|
|
894
1067
|
if grid_var_indices is not None:
|
|
895
1068
|
if isinstance(
|
|
896
1069
|
zone, (TecplotOrderedZoneReader, TecplotFEZoneReader)
|
|
@@ -905,14 +1078,23 @@ def main(argv: Sequence[str] | None = None) -> int:
|
|
|
905
1078
|
# sources, so they always write their own grid.
|
|
906
1079
|
signature = (zt, zone._face_map_digest())
|
|
907
1080
|
if signature is not None:
|
|
908
|
-
|
|
1081
|
+
grid = _read_grid(zone, imap, grid_var_indices)
|
|
1082
|
+
if grid is None:
|
|
1083
|
+
signature = None # no grid to compare, none to share
|
|
1084
|
+
else:
|
|
1085
|
+
# Zones with the same signature are compared grid for grid
|
|
1086
|
+
for source in grid_registry.get(signature, ()):
|
|
1087
|
+
grid_match = _match_grid(source, zone, grid)
|
|
1088
|
+
if grid_match is not None:
|
|
1089
|
+
grid_reference = source.output_zone
|
|
1090
|
+
break
|
|
909
1091
|
|
|
910
1092
|
# A zone that would hold no data of its own is skipped by the
|
|
911
1093
|
# writer, so write its grid fresh rather than lose the zone.
|
|
912
1094
|
if grid_reference is not None and not _has_own_data(
|
|
913
1095
|
zone, imap, grid_var_indices
|
|
914
1096
|
):
|
|
915
|
-
grid_reference = None
|
|
1097
|
+
grid_reference = grid_match = None
|
|
916
1098
|
|
|
917
1099
|
zones_before = writer.current_zone
|
|
918
1100
|
_write_zone(
|
|
@@ -926,15 +1108,25 @@ def main(argv: Sequence[str] | None = None) -> int:
|
|
|
926
1108
|
source_path=input_paths[fi],
|
|
927
1109
|
grid_var_indices=grid_var_indices,
|
|
928
1110
|
grid_reference=grid_reference,
|
|
1111
|
+
grid_match=grid_match,
|
|
929
1112
|
)
|
|
930
1113
|
if writer.current_zone == zones_before:
|
|
931
1114
|
continue # skipped as empty, nothing to map or register
|
|
932
1115
|
zone_index_map[zi] = writer.current_zone
|
|
933
|
-
if
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
1116
|
+
if (
|
|
1117
|
+
signature is not None
|
|
1118
|
+
and grid is not None
|
|
1119
|
+
and not grid_reference
|
|
1120
|
+
):
|
|
1121
|
+
# A zone that wrote its grid is a source for later zones with
|
|
1122
|
+
# the same grid
|
|
1123
|
+
grid_registry.setdefault(signature, []).append(
|
|
1124
|
+
_GridSource(
|
|
1125
|
+
writer.current_zone, zone, grid.locals, grid.bounds
|
|
1126
|
+
)
|
|
1127
|
+
)
|
|
937
1128
|
total_zones += 1
|
|
1129
|
+
grid = None
|
|
938
1130
|
|
|
939
1131
|
# Close all readers
|
|
940
1132
|
for reader in readers:
|
tecio/cli/teconvert.py
CHANGED
|
@@ -86,6 +86,7 @@ from typing import Any
|
|
|
86
86
|
import numpy as np
|
|
87
87
|
|
|
88
88
|
from .. import (
|
|
89
|
+
TecplotFEMixedZoneReader,
|
|
89
90
|
TecplotFEZoneReader,
|
|
90
91
|
TecplotOrderedZoneReader,
|
|
91
92
|
TecplotPolyZoneReader,
|
|
@@ -268,7 +269,7 @@ def _copy_zones(reader: TecplotReader, writer: TecplotWriter) -> None:
|
|
|
268
269
|
writer.write_fe_zone(
|
|
269
270
|
zone_type=zt,
|
|
270
271
|
data=data,
|
|
271
|
-
node_map=
|
|
272
|
+
node_map=zone.node_map if con_sharing is None else None,
|
|
272
273
|
con_sharing=con_sharing,
|
|
273
274
|
**fe_kw,
|
|
274
275
|
)
|
|
@@ -281,9 +282,18 @@ def _copy_zones(reader: TecplotReader, writer: TecplotWriter) -> None:
|
|
|
281
282
|
**({} if con_sharing is not None else poly_face_kwargs(zone)),
|
|
282
283
|
**common_kw,
|
|
283
284
|
)
|
|
285
|
+
elif isinstance(zone, TecplotFEMixedZoneReader):
|
|
286
|
+
con_sharing = zone.shared_connectivity
|
|
287
|
+
writer.write_femixed_zone(
|
|
288
|
+
data=data,
|
|
289
|
+
cell_shapes=None if con_sharing is not None else zone.section_shapes,
|
|
290
|
+
node_maps=None if con_sharing is not None else zone.node_maps,
|
|
291
|
+
con_sharing=con_sharing,
|
|
292
|
+
**common_kw,
|
|
293
|
+
)
|
|
284
294
|
else:
|
|
285
295
|
raise NotImplementedError(
|
|
286
|
-
f"Zone '{zone.title}' is not an ordered, FE or poly zone; "
|
|
296
|
+
f"Zone '{zone.title}' is not an ordered, FE, FEMIXED or poly zone; "
|
|
287
297
|
"conversion is not supported for it."
|
|
288
298
|
)
|
|
289
299
|
|
tecio/cli/tecscale.py
CHANGED
|
@@ -106,6 +106,7 @@ from typing import Any
|
|
|
106
106
|
import numpy as np
|
|
107
107
|
|
|
108
108
|
from .. import (
|
|
109
|
+
TecplotFEMixedZoneReader,
|
|
109
110
|
TecplotFEZoneReader,
|
|
110
111
|
TecplotOrderedZoneReader,
|
|
111
112
|
TecplotPolyZoneReader,
|
|
@@ -494,10 +495,24 @@ def main(argv: Sequence[str] | None = None) -> int:
|
|
|
494
495
|
con_sharing=con_sharing,
|
|
495
496
|
**fe_kw,
|
|
496
497
|
)
|
|
498
|
+
elif isinstance(zone, TecplotFEMixedZoneReader):
|
|
499
|
+
con_sharing = zone.shared_connectivity
|
|
500
|
+
writer.write_femixed_zone(
|
|
501
|
+
data=data,
|
|
502
|
+
cell_shapes=(
|
|
503
|
+
None if con_sharing is not None else zone.section_shapes
|
|
504
|
+
),
|
|
505
|
+
node_maps=None
|
|
506
|
+
if con_sharing is not None
|
|
507
|
+
else zone.node_maps,
|
|
508
|
+
con_sharing=con_sharing,
|
|
509
|
+
**common_kw,
|
|
510
|
+
)
|
|
497
511
|
else:
|
|
498
512
|
raise NotImplementedError(
|
|
499
513
|
f"Zone '{zone.title}' is neither an ordered nor a "
|
|
500
|
-
"classic FE or poly zone; scaling is not
|
|
514
|
+
"classic FE, FEMIXED or poly zone; scaling is not "
|
|
515
|
+
"supported for it."
|
|
501
516
|
)
|
|
502
517
|
|
|
503
518
|
except Exception as exc: # noqa: BLE001
|
tecio/cli/tecslice.py
CHANGED
|
@@ -134,6 +134,7 @@ from typing import Any, NamedTuple
|
|
|
134
134
|
import numpy as np
|
|
135
135
|
|
|
136
136
|
from .. import (
|
|
137
|
+
TecplotFEMixedZoneReader,
|
|
137
138
|
TecplotFEZoneReader,
|
|
138
139
|
TecplotOrderedZoneReader,
|
|
139
140
|
TecplotPolyZoneReader,
|
|
@@ -536,7 +537,9 @@ def _zone_sources(zone: TecplotZoneReader) -> dict[int, set[str]]:
|
|
|
536
537
|
if sv is not None:
|
|
537
538
|
sources.setdefault(sv, set()).add(var.name)
|
|
538
539
|
if (
|
|
539
|
-
isinstance(
|
|
540
|
+
isinstance(
|
|
541
|
+
zone, (TecplotFEZoneReader, TecplotFEMixedZoneReader, TecplotPolyZoneReader)
|
|
542
|
+
)
|
|
540
543
|
and zone.shared_connectivity is not None
|
|
541
544
|
):
|
|
542
545
|
sources.setdefault(zone.shared_connectivity, set())
|
|
@@ -692,9 +695,18 @@ def _write_zone_verbatim(
|
|
|
692
695
|
con_sharing=zone_map[con_sharing] if con_sharing is not None else None,
|
|
693
696
|
**fe_kw,
|
|
694
697
|
)
|
|
698
|
+
elif isinstance(zone, TecplotFEMixedZoneReader):
|
|
699
|
+
con_sharing = zone.shared_connectivity
|
|
700
|
+
writer.write_femixed_zone(
|
|
701
|
+
data=data,
|
|
702
|
+
cell_shapes=None if con_sharing is not None else zone.section_shapes,
|
|
703
|
+
node_maps=None if con_sharing is not None else zone.node_maps,
|
|
704
|
+
con_sharing=zone_map[con_sharing] if con_sharing is not None else None,
|
|
705
|
+
**kw,
|
|
706
|
+
)
|
|
695
707
|
else:
|
|
696
708
|
raise NotImplementedError(
|
|
697
|
-
f"Zone '{zone.title}' is neither an ordered, classic FE nor poly "
|
|
709
|
+
f"Zone '{zone.title}' is neither an ordered, classic FE, FEMIXED nor poly "
|
|
698
710
|
"zone; writing is not supported for it."
|
|
699
711
|
)
|
|
700
712
|
|
|
@@ -781,9 +793,18 @@ def _write_zone_protected(
|
|
|
781
793
|
con_sharing=con_sharing,
|
|
782
794
|
**fe_kw,
|
|
783
795
|
)
|
|
796
|
+
elif isinstance(zone, TecplotFEMixedZoneReader):
|
|
797
|
+
con_sharing = zone.shared_connectivity
|
|
798
|
+
writer.write_femixed_zone(
|
|
799
|
+
data=writer_data,
|
|
800
|
+
cell_shapes=None if con_sharing is not None else zone.section_shapes,
|
|
801
|
+
node_maps=None if con_sharing is not None else zone.node_maps,
|
|
802
|
+
con_sharing=con_sharing,
|
|
803
|
+
**kw,
|
|
804
|
+
)
|
|
784
805
|
else:
|
|
785
806
|
raise NotImplementedError(
|
|
786
|
-
f"Zone '{zone.title}' is neither an ordered, classic FE nor poly "
|
|
807
|
+
f"Zone '{zone.title}' is neither an ordered, classic FE, FEMIXED nor poly "
|
|
787
808
|
"zone; writing is not supported for it."
|
|
788
809
|
)
|
|
789
810
|
|