Skip to content

Example notebooks ​

Jupyter notebooks demonstrating meshio++'s Python bindings on the bundled example.msh (a Gmsh 4.1 mesh of a mechanical bracket, ~52k nodes / ~298k elements), committed with their outputs so they render on GitHub with no setup — the links below go straight there. Source: example/python/.

NotebookWhat it shows
01_read_and_visualize.ipynbRead the Gmsh file with meshio++, inspect the mesh, and render it with PyVista (full view + a clipped interior view).
02_convert_and_inspect.ipynbConvert the geometry to VTU / VTK / XDMF / Gmsh / PLY, compare file sizes, and verify the round trip.
03_mesh_operations.ipynbTour of the operations layer -- surface/skin extraction, quality, reorder, diff, transform, clean, crop (bounding box / half-space / data predicate), merge, split, stats, convert_cells, refine, partition, smooth, interpolate, regular grids and signed distance fields (grid, voxelize, compute_sdf voxel/octree, .vti), slice, isosurface, gradient, the settings pipeline, sequences, the data operations, and selective reads -- each rendered with PyVista.
04_interop.ipynbHand the mesh to PyVista, trimesh and Arrow/Parquet with no file round-trip -- shared buffers checked with np.shares_memory, zero_copy_only, regions through a PyVista round-trip, and a Parquet export read back with pandas. Needs meshioplusplus[interop].
05_point_clouds.ipynbRead PCL's own .pcd files (ASCII, binary, binary_compressed, organised), render the colour-coded cloud, write every DATA mode and compare sizes, then subsample_points → proximity_graph, and the column rules and chemistry-XYZ refusal of .xyz.
06_lsdyna_decks.ipynbRead a multi-file LS-DYNA keyword deck (long-format nodes, I10 solids, free-format shells, *INCLUDE_PATH), render it one colour per *PART, see the tetra/pyramid/wedge collapse with a positive-volume check, the four card formats reading to one mesh, *SET_* as point/cell/side regions, and a write → read round trip.
07_calculix_frd.ipynbRead CalculiX .frd results written by ccx: the increments as sequence steps, the deformed cantilever coloured by von Mises (with a beam-theory check), the first four bending modes of the same beam, read_sequence → {step} files, shells and beams that ccx expands into solids, the he20/pe15/be3 node permutations checked geometrically, the short layout and the cgx shell types, derived fields against NumPy, and the tensor_invariants data operation (mises/principal/hydrostatic/deviatoric) reproducing derived=True's output exactly.
08_gltf_export.ipynbWrite a mesh as glTF 2.0 and look at what a viewer sees: an L-bracket with two cell regions and a boundary patch, the skin's point normals smooth versus split at a crease angle (compute_normals), a temperature field baked into an unlit COLOR_0, the .glb decoded by hand (root node rotation, scale, recentring; linear colours displayed as sRGB), the source coordinates recovered exactly, and a point cloud exported as POINTS with normals.
09_format_half_gaps.ipynbRoadmap §1.1's other four items, each a small self-contained mesh: SU2 multizone (NZONE=, unwelded zones, su2:zone), Tecplot multiple zones (mixed cell types sharing points via VARSHARELIST, one region per zone), EnSight Gold variable write (scalar/tensor point_data and field_data, binary, round-tripped), and OpenFOAM binary write (label_bits/scalar_bits, bit-exact against the ASCII write, file-size comparison).
10_unv_universal_files.ipynbI-DEAS universal files (.unv/.uff) from gmsh and pyuff: quadratic tetrahedra and wedges with their groups as regions, three mode shapes of a 2414 file read as steps and warped, a measured FRF set (dataset 58 and binary 58b) read as a frequency sequence and plotted, and a write-back of groups and one result step.
11_nastran_h5.ipynbMSC Nastran HDF5 results (.h5) written by MSC Nastran 2020: the model with its element and property ids and one region per property, static displacements and per-cell shell stress, the steps of six solution sequences, four buckling modes of a SOL 105 file warped, the real and imaginary parts of a frequency response, a thermal transient, a bit-for-bit check against pyNastran, and one .vtu per mode.
12_code_aster.ipynbCode_Aster native meshes (.mail): a HEXA20 block with a face group and a node group sharing one name, one element of each of the twenty keywords from POI1 to HEXA27, Code_Aster's node order against MED's and meshio++'s with a mid-edge check, a .mail → .med → .mail round trip, and what the writer emits (80 columns, sanitised group names).
13_optistruct_comsol.ipynbAltair OptiStruct decks and COMSOL meshes: HyperMesh components (by $HMMOVE and by property) and OptiStruct SETs as regions, a real OptiStruct deck from pyNastran, regions written back as components by both engines; COMSOL domains, boundary entities and Selections, COMSOL's quadratic node order with a mid-edge check, .mphtxt against .mphbin, and an OptiStruct deck converted to COMSOL.
14_elmer_febio.ipynbElmer mesh directories read with no format (the directory is sniffed), bodies and boundaries as regions, a quadratic beam written for ElmerSolver with its 820 node order and regenerated boundary parents, ElmerGrid partitions merged back; an FEBio .feb with every solid type, sets, surfaces and MeshData, written back as spec 4.0; FEBio .xplt results, compressed and not, rendered state by state and converted to a .vtu sequence.
15_ansys.ipynbAnsys MAPDL: a .cdb deck's degenerate SOLID186 wedge, pyramid and tetrahedron read from their repeated nodes, components as regions, missing midside nodes created, a deck written with MAPDL's own layouts and read back; .rst results, a modal analysis rendered mode by mode and converted to a .vtu sequence, and an .rth temperature field.
16_patran_femap_mfem.ipynbInterchange files: a Patran neutral file's packets and components as regions, its quadratic cells read from Patran's own node order; a Femap model's property titles and groups, its degenerate-brick node slots, and EMSolution's output sets read as steps in both result encodings; MFEM's curved order-2 meshes in MFEM's degree-of-freedom numbering, with grid functions, written back with their .gf files.
17_libmesh_z88_fil_radioss.ipynbFEM formats of v16.7.0: a libMesh mesh read the same from .xda and .xdr, a refined mesh reduced to its active cells with its boundary carried down; a Z88 cantilever with Z88R's displacements and stresses, found by its file name and written back; an Abaqus .fil file's increments as steps in ASCII and both binary byte orders, real Abaqus output checked against pybaqus; an OpenRadioss starter deck's cards, parts, groups and surfaces.
18_marc_ansys_results.ipynbv16.8.0: an MSC Marc deck read from fixed, extended and free-format cards with its element and node sets, a .dat told apart from Tecplot's; a Marc .t19 post file's increments as steps with its stress tensor at the integration points; Ansys .rst element stresses and strains per element node and averaged, nodal forces in equilibrium with the reactions, a distributed solve merged to MAPDL's combined file, and a cyclic sector expanded to the full rotor.
19_d3plot_op2_results.ipynbv16.9.0: an LS-DYNA d3plot family read state by state, its deleted elements removed through the lsdyna:alive mask and its plastic strain per integration point or layer; real LS-DYNA output and its global energies over a sequence; a Nastran OP2 SOL 101 model with its property regions and stresses, three mode shapes as steps, and an OP2 whose mesh comes from the input deck beside it.
20_tecplot_nastran_fluent_elmer_febio.ipynbv16.10.0: binary Tecplot .plt files with ordered zones, read like their ASCII twins, and a transient .plt as a sequence; Nastran coordinate systems checked against pyNastran, composite ply and solid corner stresses and grid point forces; a 2-D mesh written as a face-based Fluent .msh with named zones; an Elmer mesh written partitioned and read back, and ElmerGrid's binary files; FEBio MeshData written; .xplt surface variables on facet blocks and a remeshed run state by state.
21_format_halves.ipynbv16.11.0: Tecplot polyhedral zones, MFEM meshes and fields of any order as VTK Lagrange cells, a non-conforming mesh's leaves and a parallel run merged, Elmer halo elements, .xplt edges, a real Patran export and a written Femap output set, libMesh written gzip-compressed with edge and shell-face sets, the whole Z88 deck with beam, truss and plate results, and OpenRadioss animation files as a sequence
22_section_a.ipynbv16.12.0: MFEM NURBS meshes as Lagrange cells, a Tecplot 7 binary file, WARP3D's Patran result files, the modes of a real Abaqus buckling run, an OpenRadioss time history, Z88 16-node plates, a libMesh refinement tree written back, a Marc deck with INCLUDE and a remeshing post file, SPH particles, complex Nastran modes and a full cyclic rotor
23_dolfinx_vtx.ipynbv16.13.0: a DOLFINx heat equation and a P2 elasticity run read from ADIOS2 .bp directories step by step, a two-rank run merged or welded to the serial mesh, a Tecplot SZL file read through TecIO like its ASCII twin, and the .pvd series a vendor-runtime route writes
24_format_parity.ipynbv16.17.0: .dat writes going to Tecplot, an OpenRadioss starter deck written with placeholder materials and read back, gmsh hexahedron20 as /BRIC20, a Marc deck written and read back with its sets, a Femap series with one output set per step, EnSight Fortran binary read by VTK, Exodus quadratic bricks in Exodus order, and why each read-only format is read-only
31_terminal_rendering.ipynbv16.33.0: the software rasterizer beside PyVista -- render_image as an array, camera, shading and edge options, data colouring with the new colormaps and a colour bar, the terminal form embedded as HTML, and PNG and asciinema files from snapshot
32_interactive_terminal.ipynbv16.35.0: the interactive terminal viewer — a recorded mouse-and-key session replayed through tui, the resulting camera beside PyVista, the cell diff that keeps the link usable, and the view(backend="auto") order
33_interactive_session.ipynbv16.36.0: the terminal viewer, part two — probing a cell and pinning two, the : command line and a saved session, cut-aways beside PyVista's clip, two meshes and their difference, and a time series with one colour range
34_skin_to_cad.ipynbUnreleased: skin to CAD — a noisy turned part segmented into smooth patches by crease and curvature, a plane, sphere, cylinder, cone and torus fitted to them with their residuals, the closed skin handed to CAD as a faceted STEP solid, and, with the OpenCASCADE backend, fit_cad's analytic solid of six CAD faces
35_kratos_iga_cad_json.ipynbUnreleased: Kratos IGA geometry — a trimmed plate with a hole sampled from Kratos CAD JSON (cells the trim crosses, subdivision and trim=False), the Scordelis-Lo roof exact to rounding, a two-patch beam with a coupling edge rewritten byte for byte, the geometry beside an MDPA deck, and, with the OpenCASCADE backend, fit_cad's freeform face written as CAD JSON and a STEP file read back with its B-rep

Other languages ​

Running them ​

sh
uv pip install --python .venv pyvista matplotlib jupyter nbconvert ipykernel
PYVISTA_OFF_SCREEN=true \
  .venv/bin/jupyter nbconvert --to notebook --execute --inplace example/python/*.ipynb

PyVista renders off-screen through VTK's EGL backend (VTK >= 9.5), so no display or xvfb is required; if GL is unavailable the notebook falls back to a matplotlib surface plot.

Released under the MIT License.