Skip to content

Commit

Permalink
Merge pull request #1232 from nschloe/cellblock-tags
Browse files Browse the repository at this point in the history
Cellblock tags
  • Loading branch information
nschloe authored Dec 10, 2021
2 parents 16d3308 + 239383f commit 514995f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 21 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ meshio can read and write all of the following and smoothly converts between the
> ANSYS msh (`.msh`),
> [AVS-UCD](https://lanl.github.io/LaGriT/pages/docs/read_avs.html) (`.avs`),
> [CGNS](https://cgns.github.io/) (`.cgns`),
> [DOLFIN XML](https://manpages.ubuntu.com/manpages/disco/man1/dolfin-convert.1.html) (`.xml`),
> [DOLFIN XML](https://manpages.ubuntu.com/manpages/jammy/en/man1/dolfin-convert.1.html) (`.xml`),
> [Exodus](https://nschloe.github.io/meshio/exodus.pdf) (`.e`, `.exo`),
> [FLAC3D](https://www.itascacg.com/software/flac3d) (`.f3grid`),
> [H5M](https://www.mcs.anl.gov/~fathom/moab-docs/h5mmain.html) (`.h5m`),
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = meshio
version = 5.0.5
version = 5.0.6
author = Nico Schlömer et al.
author_email = [email protected]
description = I/O for many mesh formats
Expand Down
47 changes: 28 additions & 19 deletions src/meshio/_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import warnings

import numpy as np
from numpy.typing import ArrayLike

from ._common import num_nodes_per_cell

Expand All @@ -20,13 +21,13 @@ def __len__(self):
class Mesh:
def __init__(
self,
points,
cells,
point_data=None,
cell_data=None,
points: ArrayLike,
cells: dict[str, ArrayLike] | list[tuple[str, ArrayLike] | CellBlock],
point_data: dict[str, ArrayLike] | None = None,
cell_data: dict[str, list[ArrayLike]] | None = None,
field_data=None,
point_sets=None,
cell_sets=None,
point_sets: dict[str, ArrayLike] | None = None,
cell_sets: dict[str, list[ArrayLike]] | None = None,
gmsh_periodic=None,
info=None,
):
Expand All @@ -40,20 +41,28 @@ def __init__(
# DeprecationWarning,
# )
# old dict, deprecated
self.cells = [
CellBlock(cell_type, np.asarray(data))
for cell_type, data in cells.items()
]
else:
self.cells = [
CellBlock(
cell_type,
# polyhedron data cannot be convert to numpy arrays because the
# sublists don't all have the same length
data if cell_type.startswith("polyhedron") else np.asarray(data),
#
# convert dict to list of tuples
cells = list(cells.items())

self.cells = []
for cell_block in cells:
if isinstance(cell_block, tuple):
cell_type, data = cell_block
self.cells.append(
CellBlock(
cell_type,
# polyhedron data cannot be converted to numpy
# arrays because the sublists don't all have the
# same length
data
if cell_type.startswith("polyhedron")
else np.asarray(data),
)
)
for cell_type, data in cells
]
else:
self.cells.append(cell_block)

self.point_data = {} if point_data is None else point_data
self.cell_data = {} if cell_data is None else cell_data
self.field_data = {} if field_data is None else field_data
Expand Down

0 comments on commit 514995f

Please sign in to comment.