lsdyna-mesh-reader 0.1.4__tar.gz → 0.2.0__tar.gz

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.
Files changed (29) hide show
  1. lsdyna_mesh_reader-0.2.0/.gitattributes +6 -0
  2. {lsdyna-mesh-reader-0.1.4 → lsdyna_mesh_reader-0.2.0}/PKG-INFO +7 -4
  3. {lsdyna-mesh-reader-0.1.4 → lsdyna_mesh_reader-0.2.0}/pyproject.toml +19 -10
  4. lsdyna_mesh_reader-0.2.0/src/lsdyna_mesh_reader/_version.py +24 -0
  5. {lsdyna-mesh-reader-0.1.4 → lsdyna_mesh_reader-0.2.0}/src/lsdyna_mesh_reader/deck.py +68 -10
  6. lsdyna_mesh_reader-0.2.0/tools/extract-deps.py +8 -0
  7. {lsdyna-mesh-reader-0.1.4 → lsdyna_mesh_reader-0.2.0}/CMakeLists.txt +0 -0
  8. {lsdyna-mesh-reader-0.1.4 → lsdyna_mesh_reader-0.2.0}/LICENSE +0 -0
  9. {lsdyna-mesh-reader-0.1.4 → lsdyna_mesh_reader-0.2.0}/README.md +0 -0
  10. {lsdyna-mesh-reader-0.1.4 → lsdyna_mesh_reader-0.2.0}/docs/source/_templates/autosummary/base.rst +0 -0
  11. {lsdyna-mesh-reader-0.1.4 → lsdyna_mesh_reader-0.2.0}/docs/source/_templates/autosummary/class.rst +0 -0
  12. {lsdyna-mesh-reader-0.1.4 → lsdyna_mesh_reader-0.2.0}/docs/source/_templates/autosummary/module.rst +0 -0
  13. {lsdyna-mesh-reader-0.1.4 → lsdyna_mesh_reader-0.2.0}/docs/source/_templates/custom-class-template.rst +0 -0
  14. {lsdyna-mesh-reader-0.1.4 → lsdyna_mesh_reader-0.2.0}/docs/source/_templates/custom-module-template.rst +0 -0
  15. {lsdyna-mesh-reader-0.1.4 → lsdyna_mesh_reader-0.2.0}/docs/source/api.rst +0 -0
  16. {lsdyna-mesh-reader-0.1.4 → lsdyna_mesh_reader-0.2.0}/docs/source/conf.py +0 -0
  17. {lsdyna-mesh-reader-0.1.4 → lsdyna_mesh_reader-0.2.0}/docs/source/index.md +0 -0
  18. {lsdyna-mesh-reader-0.1.4 → lsdyna_mesh_reader-0.2.0}/src/array_support.h +0 -0
  19. {lsdyna-mesh-reader-0.1.4 → lsdyna_mesh_reader-0.2.0}/src/deck.cpp +0 -0
  20. {lsdyna-mesh-reader-0.1.4 → lsdyna_mesh_reader-0.2.0}/src/lsdyna_mesh_reader/__init__.py +0 -0
  21. {lsdyna-mesh-reader-0.1.4 → lsdyna_mesh_reader-0.2.0}/src/lsdyna_mesh_reader/_deck.pyi +0 -0
  22. {lsdyna-mesh-reader-0.1.4 → lsdyna_mesh_reader-0.2.0}/src/lsdyna_mesh_reader/examples/EXP_SC_JOINT_SCREW.key +0 -0
  23. {lsdyna-mesh-reader-0.1.4 → lsdyna_mesh_reader-0.2.0}/src/lsdyna_mesh_reader/examples/__init__.py +0 -0
  24. {lsdyna-mesh-reader-0.1.4 → lsdyna_mesh_reader-0.2.0}/src/lsdyna_mesh_reader/examples/bird.k +0 -0
  25. {lsdyna-mesh-reader-0.1.4 → lsdyna_mesh_reader-0.2.0}/src/lsdyna_mesh_reader/examples/birdball.k +0 -0
  26. {lsdyna-mesh-reader-0.1.4 → lsdyna_mesh_reader-0.2.0}/src/lsdyna_mesh_reader/examples/bracket.k +0 -0
  27. {lsdyna-mesh-reader-0.1.4 → lsdyna_mesh_reader-0.2.0}/src/lsdyna_mesh_reader/examples/ex_13_thick_shell_elform_2.k +0 -0
  28. {lsdyna-mesh-reader-0.1.4 → lsdyna_mesh_reader-0.2.0}/src/lsdyna_mesh_reader/examples/wheel.k +0 -0
  29. {lsdyna-mesh-reader-0.1.4 → lsdyna_mesh_reader-0.2.0}/src/lsdyna_mesh_reader/py.typed +0 -0
@@ -0,0 +1,6 @@
1
+ # LS-DYNA keyword decks are fixed-width: a field is identified by its column,
2
+ # so an end-of-line conversion on checkout would put a stray CR inside the last
3
+ # field of every line. Hand them over byte for byte on every platform.
4
+ *.k binary
5
+ *.key binary
6
+ *.dyn binary
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: lsdyna-mesh-reader
3
- Version: 0.1.4
3
+ Version: 0.2.0
4
4
  Summary: Read nodes and elements from LS-DYNA decks.
5
5
  Author-Email: Alex Kaszynski <akascap@gmail.com>
6
6
  Classifier: Development Status :: 4 - Beta
@@ -10,14 +10,14 @@ Classifier: License :: OSI Approved :: MIT License
10
10
  Classifier: Operating System :: Microsoft :: Windows
11
11
  Classifier: Operating System :: POSIX
12
12
  Classifier: Operating System :: MacOS
13
- Classifier: Programming Language :: Python :: 3.9
14
13
  Classifier: Programming Language :: Python :: 3.10
15
14
  Classifier: Programming Language :: Python :: 3.11
16
15
  Classifier: Programming Language :: Python :: 3.12
17
16
  Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Programming Language :: Python :: 3.14
18
18
  Project-URL: Documentation, https://akaszynski.github.io/lsdyna-mesh-reader/
19
19
  Project-URL: Repository, https://github.com/akaszynski/lsdyna-mesh-reader
20
- Requires-Python: >=3.9
20
+ Requires-Python: >=3.10
21
21
  Requires-Dist: numpy>=1.22.4
22
22
  Provides-Extra: docs
23
23
  Requires-Dist: pydata-sphinx-theme; extra == "docs"
@@ -27,6 +27,9 @@ Requires-Dist: sphinx-copybutton; extra == "docs"
27
27
  Requires-Dist: myst-parser; extra == "docs"
28
28
  Provides-Extra: pyvista
29
29
  Requires-Dist: pyvista; extra == "pyvista"
30
+ Provides-Extra: tests
31
+ Requires-Dist: pytest; extra == "tests"
32
+ Requires-Dist: pyvista; extra == "tests"
30
33
  Description-Content-Type: text/markdown
31
34
 
32
35
  # LS-DYNA Mesh Reader
@@ -1,6 +1,6 @@
1
1
  [build-system]
2
2
  build-backend = "scikit_build_core.build"
3
- requires = ["scikit-build-core >=0.4.3", "nanobind >=1.3.2"]
3
+ requires = ["scikit-build-core >=0.4.3", "nanobind >=1.3.2", "setuptools_scm"]
4
4
 
5
5
  [project]
6
6
  authors = [
@@ -14,24 +14,25 @@ classifiers = [
14
14
  "Operating System :: Microsoft :: Windows",
15
15
  "Operating System :: POSIX",
16
16
  "Operating System :: MacOS",
17
- "Programming Language :: Python :: 3.9",
18
17
  "Programming Language :: Python :: 3.10",
19
18
  "Programming Language :: Python :: 3.11",
20
19
  "Programming Language :: Python :: 3.12",
21
- "Programming Language :: Python :: 3.13"
20
+ "Programming Language :: Python :: 3.13",
21
+ "Programming Language :: Python :: 3.14"
22
22
  ]
23
23
  dependencies = [
24
24
  "numpy>=1.22.4"
25
25
  ]
26
26
  description = "Read nodes and elements from LS-DYNA decks."
27
+ dynamic = ["version"]
27
28
  name = "lsdyna-mesh-reader"
28
29
  readme = "README.md"
29
- requires-python = ">=3.9"
30
- version = "0.1.4"
30
+ requires-python = ">=3.10"
31
31
 
32
32
  [project.optional-dependencies]
33
33
  docs = ["pydata-sphinx-theme", "numpydoc", "sphinx", "sphinx-copybutton", "myst-parser"]
34
34
  pyvista = ["pyvista"]
35
+ tests = ["pytest", "pyvista"]
35
36
 
36
37
  [project.urls]
37
38
  Documentation = "https://akaszynski.github.io/lsdyna-mesh-reader/"
@@ -39,9 +40,10 @@ Repository = "https://github.com/akaszynski/lsdyna-mesh-reader"
39
40
 
40
41
  [tool.cibuildwheel]
41
42
  archs = ["auto64"] # 64-bit only
42
- skip = "cp38-* cp314-* pp* *musllinux*" # 3.9-3.13 and no PyPy and musl-based wheels
43
- test-command = "pytest {project}/tests -v"
44
- test-requires = "pytest pyvista"
43
+ build = "cp310-* cp311-* cp312-*" # Only build Python 3.10 - 3.12 since 3.12 is ABI3
44
+ skip = "*musllinux*"
45
+ test-command = "pytest {project}/tests -vv"
46
+ test-extras = ["tests"]
45
47
 
46
48
  [tool.cibuildwheel.macos]
47
49
  archs = ["native"]
@@ -75,6 +77,13 @@ extend-select = ["I"]
75
77
  [tool.scikit-build]
76
78
  # Setuptools-style build caching in a local directory
77
79
  build-dir = "build/{wheel_tag}"
78
- minimum-version = "0.4"
80
+ metadata.version.provider = "scikit_build_core.metadata.setuptools_scm"
79
81
  sdist.exclude = [".github", "*.png", "tests", ".mypy_cache", ".pre-commit-config.yaml", "*_cache", "CONTRIBUTING.md", ".gitignore"]
80
- sdist.include = ["*.cpp"]
82
+ sdist.include = ["*.cpp", "*.h", "src/lsdyna_mesh_reader/_version.py"]
83
+ wheel.py-api = "cp312"
84
+
85
+ [tool.setuptools_scm]
86
+ fallback_version = "0.0.0.dev0"
87
+ git_describe_command = "git describe --dirty --tags --long --match v*"
88
+ tag_regex = "^v(?P<version>[0-9]+\\.[0-9]+\\.[0-9]+(?:[abrc][0-9]+)?(?:\\.post[0-9]+)?(?:\\.dev[0-9]+)?)$"
89
+ version_file = "src/lsdyna_mesh_reader/_version.py"
@@ -0,0 +1,24 @@
1
+ # file generated by vcs-versioning
2
+ # don't change, don't track in version control
3
+ from __future__ import annotations
4
+
5
+ __all__ = [
6
+ "__version__",
7
+ "__version_tuple__",
8
+ "version",
9
+ "version_tuple",
10
+ "__commit_id__",
11
+ "commit_id",
12
+ ]
13
+
14
+ version: str
15
+ __version__: str
16
+ __version_tuple__: tuple[int | str, ...]
17
+ version_tuple: tuple[int | str, ...]
18
+ commit_id: str | None
19
+ __commit_id__: str | None
20
+
21
+ __version__ = version = '0.2.0'
22
+ __version_tuple__ = version_tuple = (0, 2, 0)
23
+
24
+ __commit_id__ = commit_id = 'g1af09ef'
@@ -21,6 +21,43 @@ if TYPE_CHECKING:
21
21
  pass
22
22
 
23
23
 
24
+ #: Largest value ``int32`` cell arrays can hold. VTK stores 32-bit offsets and
25
+ #: connectivity natively, at half the memory of the 64-bit ``ID_TYPE``, so the
26
+ #: grid is built from ``int32`` whenever the deck indexes fewer points than
27
+ #: this.
28
+ _INT32_MAX = np.iinfo(np.int32).max
29
+
30
+
31
+ def _uniform_cell_width(offsets: NDArray[np.integer]) -> Union[int, None]:
32
+ """Return the points per cell when every cell is the same width.
33
+
34
+ Parameters
35
+ ----------
36
+ offsets : numpy.ndarray
37
+ ``(n_cells + 1,)`` offsets into the connectivity.
38
+
39
+ Returns
40
+ -------
41
+ int | None
42
+ Points per cell, or ``None`` when the widths vary or there are no
43
+ cells. Every cell has to be the same width, so a deck of quads alone
44
+ or hexahedra alone is uniform, while one mixing quads with triangles,
45
+ or shells with solids, is not.
46
+
47
+ """
48
+ if offsets.size < 2:
49
+ return None
50
+
51
+ width = int(offsets[1] - offsets[0])
52
+
53
+ # a single subtraction rejects the mixed case before scanning every offset
54
+ if width * (offsets.size - 1) != int(offsets[-1] - offsets[0]):
55
+ return None
56
+ if (np.diff(offsets) != width).any():
57
+ return None
58
+ return width
59
+
60
+
24
61
  class Deck:
25
62
  r"""LS-DYNA deck.
26
63
 
@@ -194,19 +231,26 @@ class Deck:
194
231
  try:
195
232
  import pyvista as pv
196
233
  from pyvista import ID_TYPE, CellArray
234
+ from pyvista._vtk import numpy_to_vtk, vtkCellArray
197
235
  from pyvista.core.pointset import UnstructuredGrid
198
- from vtkmodules.util.numpy_support import numpy_to_vtk
199
- except ImportError:
200
- pass
236
+ except ImportError as exc:
237
+ msg = "Deck.to_grid requires PyVista. Install it with: pip install pyvista"
238
+ raise ImportError(msg) from exc
201
239
 
202
240
  if not self.node_sections:
203
241
  raise RuntimeError("Missing node sections. Unable to generate UnstructuredGrid.")
204
242
 
205
243
  node_section = self.node_sections[0]
206
244
 
245
+ n_points = len(node_section)
246
+
247
+ # Point indices only have to reach n_points, so int32 covers any deck
248
+ # short of 2**31 nodes and keeps the connectivity half the size.
249
+ index_dtype = np.int32 if n_points <= _INT32_MAX else ID_TYPE
250
+
207
251
  # map between the node ids and a sequential index
208
- id_map = np.empty(node_section.nid[-1] + 1, dtype=ID_TYPE)
209
- id_map[node_section.nid] = np.arange(len(node_section), dtype=ID_TYPE)
252
+ id_map = np.empty(node_section.nid[-1] + 1, dtype=index_dtype)
253
+ id_map[node_section.nid] = np.arange(n_points, dtype=index_dtype)
210
254
 
211
255
  element_sections = self.element_shell_sections + self.element_solid_sections
212
256
 
@@ -214,9 +258,9 @@ class Deck:
214
258
  raise NotImplementedError("Deck missing element sections")
215
259
 
216
260
  # add shell sections
217
- offsets: List[NDArray[np.int64]] = []
261
+ offsets: List[NDArray[np.integer]] = []
218
262
  celltypes: List[NDArray[np.uint8]] = []
219
- cells: List[NDArray[np.int64]] = []
263
+ cells: List[NDArray[np.integer]] = []
220
264
  part_ids = []
221
265
  for section in element_sections:
222
266
  section_cells, section_offset, section_celltypes = section.to_vtk()
@@ -230,14 +274,28 @@ class Deck:
230
274
  cells.append(id_map[section_cells])
231
275
  part_ids.append(section.pid)
232
276
 
233
- offsets_arr = np.hstack(offsets, dtype=ID_TYPE)
234
- cells_arr = np.hstack(cells, dtype=ID_TYPE)
277
+ cells_arr = np.hstack(cells, dtype=index_dtype)
278
+
279
+ # Offsets index the connectivity rather than the points, so they get
280
+ # their own check. VTK only drops to 32-bit storage when both arrays
281
+ # are int32, and a mismatch is promoted back to ID_TYPE.
282
+ offset_dtype = index_dtype if cells_arr.size <= _INT32_MAX else ID_TYPE
283
+ offsets_arr = np.hstack(offsets, dtype=offset_dtype)
235
284
  celltypes_arr = np.hstack(celltypes, dtype=np.uint8)
236
285
 
237
286
  grid = UnstructuredGrid()
238
287
  grid.points = pv.pyvista_ndarray(node_section.coordinates)
239
288
 
240
- vtk_cells = CellArray.from_arrays(offsets_arr, cells_arr, deep=False)
289
+ # VTK 9.6.2 can store one cell width in place of an offset per cell,
290
+ # which is an array shorter by n_cells + 1 to build and to hold. Decks
291
+ # of one cell type qualify; ones mixing widths keep the offsets.
292
+ width = _uniform_cell_width(offsets_arr)
293
+ if width is None:
294
+ vtk_cells = CellArray.from_arrays(offsets_arr, cells_arr, deep=False)
295
+ else:
296
+ vtk_cells = vtkCellArray()
297
+ vtk_cells.SetData(width, numpy_to_vtk(cells_arr, deep=False))
298
+
241
299
  vtk_cell_type = numpy_to_vtk(celltypes_arr, deep=False)
242
300
  grid.SetCells(vtk_cell_type, vtk_cells)
243
301
 
@@ -0,0 +1,8 @@
1
+ """Create a requirements_testing.txt file directly from a pyproject.toml."""
2
+
3
+ import tomli
4
+
5
+ data = tomli.load(open("pyproject.toml", "rb"))
6
+ deps = data["project"]["optional-dependencies"]["tests"]
7
+ with open("requirements-tests.txt", "w") as f:
8
+ f.write("\n".join(deps))