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/.
| Notebook | What it shows |
|---|---|
01_read_and_visualize.ipynb | Read the Gmsh file with meshio++, inspect the mesh, and render it with PyVista (full view + a clipped interior view). |
02_convert_and_inspect.ipynb | Convert the geometry to VTU / VTK / XDMF / Gmsh / PLY, compare file sizes, and verify the round trip. |
03_mesh_operations.ipynb | Tour 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.ipynb | Hand 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.ipynb | Read 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.ipynb | Read 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.ipynb | Read 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.ipynb | Write 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.ipynb | Roadmap §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.ipynb | I-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.ipynb | MSC 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.ipynb | Code_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.ipynb | Altair 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.ipynb | Elmer 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.ipynb | Ansys 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.ipynb | Interchange 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.ipynb | FEM 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.ipynb | v16.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.ipynb | v16.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.ipynb | v16.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.ipynb | v16.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.ipynb | v16.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.ipynb | v16.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.ipynb | v16.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.ipynb | v16.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.ipynb | v16.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.ipynb | v16.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.ipynb | v16.39.0 to v16.44.0: 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, then split freeform faces, rolling-ball fillets (of one radius and of a varying one), a blend between freeform faces and helical thread faces (straight flanks, and a rounded thread with no cylinder) |
35_kratos_iga_cad_json.ipynb | Unreleased: 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 |
36_iga_refine_evaluate.ipynb | Unreleased: the isogeometric layer — a NURBS disc refined by knot insertion and degree elevation with its control nets plotted over the unchanged surface (positions and first derivatives agree to rounding), derivatives and unit normals of the Scordelis-Lo roof, a trimmed plate with a hole refined while its trimming loops stay exact and iga_evaluate reports the inside test, and a refined MFEM pipe written back as an MFEM NURBS mesh. |
37_parity_tier_closed.ipynb | Unreleased: the parity tier closed — a vtx file of several cell types and of several parts (one block each, the shared points welded back on read) and the reuse mesh policy, szplt variables in their own TecIO types and partitioned zones, nastran_h5 and nastran_op2 ply and station values with the MSC table layout, and an xplt remeshed series. |
38_octree.ipynb | Unreleased: octree — a quadtree around a circle and an octree around a sphere, hanging nodes, the area and volume converging to pi and 4/3 pi, a uniform tree equal to the voxel grid, and 2-D voxelize pixels. |
40_primitives.ipynb | Unreleased: the parametric primitives — rectangle and its four triangle layouts, a box of hexahedra, tetrahedra or wedges with one colour per side region, disk, uv_sphere, icosa_sphere and cylinder, the six planar domains (reference_triangle, ngon, annulus, lshape, plate_with_hole, honeycomb), order=2 cells whose mid-edge nodes lie exactly on the sphere, the spheres from the other seeds (cube_sphere, geo_sphere, tetra_sphere), torus, cone and capsule, a Moebius band whose inconsistent_pairs follow its twist count, the five platonic solids, the solids cut open (the butterfly ball, a graded spherical_shell, pipe, fichera, solid_torus), curves and seeded point clouds, full-Lagrange and order-4 VTK_LAGRANGE_* cells, a gallery of reference_cells, and the cross-checks (box against grid, a closed outward icosphere, a named max_cells refusal). |
41_octree_mesh.ipynb | Unreleased: octree_mesh — castellated cells of a sphere with the surrogate_boundary region and sdf:distance, their volume converging to 4/3 pi as curvature_angle tightens; the default graded tetrahedra, their dihedral angles before and after optimisation and the uniform-grading bound; a cube with its corners and edges kept; all-hexahedra with their pillow layer, with and without it; nested spheres as two cleaved materials; and a holed skin. |
42_mesh_cad_surface.ipynb | v17.13.0: mesh_cad_surface — the CAD JSON cube, capped cylinder and sphere meshed watertight, their area and volume converging at second order; the trimmed plate against the read's staircase lattice; the Scordelis-Lo roof's fortyfold-stretched parameters and the two-patch beam's shared edge; a failed face reported by reason; triangulate_polygon_2d; and, with OpenCASCADE, a STEP box against BRepMesh. v17.14.0: the beam's embedded edge, a hole 0.02 from its rim split rather than refused, and a cap started a quarter turn later. v17.15.0: refinement to min_angle = 25 with angle histograms before and after, the sphere's poles reported with their reach, guarded Laplacian and ODT smoothing, and the interpolation error's second-order convergence. Later: curved elements, size sources, untangling (nodes on the faces and sliding along the edges), quads paired greedily and by a maximum matching, curved quad9 converging at fourth order, project_to_cad restoring a smoothed sphere and cylinder to the model, and boundary layers grown out of the cube and the cylinder and into the sphere. |
45_extrude_revolve_mirror.ipynb | Unreleased: extrude (graded layers, triangles to wedges, a curve to a tube wall, extrude(rectangle) == box), revolve (a full turn with wedges on the axis, a sector with start/end, a semicircle of lines into a sphere) and mirror (a reflecting transform inverts every cell, mirror does not; a half box welded into a whole), and the three as pipeline steps. |
46_mmg.ipynb | Unreleased: the MMG backend — a rectangle adapted to the metric of a Hessian (long thin triangles along a front), a disc cut out of a square by discretize_levelset with its inside area, an annulus triangulated by mesh_domain with and without its hole point, and a square hole carried through a mesh by move (ELAS), every triangle right side out. Needs a build with MMG. |
47_intersections_thickness.ipynb | Unreleased: find_intersections and thickness — two overlapping spheres with their crossing segments on the circle where they meet, a sphere whose cap is pushed through its far side, the wall thickness of a sphere with an off-centre cavity coloured on its skin, the clearance from one part to another, and both as pipeline gates. |
67_scan_deviation.ipynb | Unreleased: scan inspection — fit_primitives' form error and extremes, deviation of a scanned plate against its nominal with its histogram and map, deviation_regions finding the bump and the dent, deviation against a fitted plane, and colorize / exaggerate to show the map.; a seeded, sigma-trimmed cylinder fit; and alignment: a scan turned 150 degrees registered with register_rigid(initial="auto") and deviation(register=True), auto_align and find_symmetry_plane with mirror. |
68_scan_measurement.ipynb | Unreleased: measuring a scan — measure on a scanned block (four fitted planes, their edge, a height and a corner angle with nominals, flatness, perpendicularity and parallelism under the minimum-zone criterion, PASS/FAIL per row), deviation from a fitted element, least squares against minimum zone, align_datums into the 3-2-1 frame, and thickness by ray, sphere and cone on a wedge plate. |
69_sections_to_sketches.ipynb | Unreleased: from a scanned shaft to a sketch — slice(chain=True) and sections, fit_curves (lines and fillet arcs on the axial section, circles across it), silhouette and its clearance envelope, the sketch written as DXF (checked by ezdxf's audit) and as STEP curves, and a fitted cylinder written by write_step_elements. |
70_scan_editing_reverse_engineering.ipynb | Unreleased: editing a raw scan and closing the reverse-engineering loop — remove_islands, repair's fan, flat and curved fills, clip with a cap, offset_surface, thicken, hollow, flip_normals, decimate(max_deviation=...), then face_support on a box scanned from above, fit_cad_iterate on a bent box, constrain_primitives with forced and forbidden relations, and profile_solid revolving a fitted half profile through OpenCASCADE. |
71_adapt_volume.ipynb | Unreleased: size-field tetrahedral remeshing — octree_mesh's tetrahedra remeshed by adapt_volume with the input boundary's sizes and with boundary_sizing="geometry" at two gradations, the dihedral-angle histograms and a cut-away coloured by each tetrahedron's least angle, nested shells keeping their materials and interfaces, a box coarsened to a few hundred tetrahedra, octree_mesh(post_adapt=True), and MMG's mmg3d beside it when the add-on or the program is present. |
72_tetrahedralize_backends.ipynb | Unreleased: the tetrahedral meshers compared — octree (plain and post_adapt), Netgen, TetGen and Gmsh on a sphere, a cube, a cylinder and the Stanford bunny, with element counts, time, skin kept, dihedral angles, slivers and scaled-Jacobian and aspect-ratio distributions; the tables are in doc/tetrahedralize.md |
73_mass_properties.ipynb | Unreleased: mass, centre of mass, inertia tensor and principal axes of a box, a bar of two densities, a UV sphere and a shell, checked against closed forms, with the centre of mass drawn beside the mean of the points. |
74_ray_queries.ipynb | Unreleased: rays at a sphere (hit distance against the analytic distance, normals, cells hit), seams and limits, and point location in a hexahedral mesh with barycentric weights that reproduce interpolate bit for bit. |
75_filter_points.ipynb | Unreleased: a noisy sphere scan cleaned of stray points (statistical and radius outlier removal), thinned by voxel and Poisson-disk sampling, and reconstructed. |
76_iga_extras.ipynb | Unreleased: the second derivatives of a rational arc (its curvature), the Bezier cells of a refined annulus and their VTU round trip, knot removal undoing a refinement and removing a needed knot within a tolerance, and the closest points of a curve and a surface. |
78_tier9_operations.ipynb | Unreleased: Loop and Catmull-Clark subdivision with creases, the hexahedron mixed-green closure, field units and CRS reprojection, a reusable SurfaceQuery, and Manifold surface booleans with their volume identities. |
Other languages
- C++ —
example/cpp/, the same tour written directly against the C++ core (no Python), running on the xeus-cpp Jupyter kernel (07_terminal_rendering.ipynbshows the software rasterizer, inline PNG frames included;08_iga_refine_evaluate.ipynbthe isogeometric layer;09_skin_to_cad_features.ipynbthe skins offit_cad's fillets, blends and rounded threads); seeexample/cpp/README.md. - Julia —
example/julia/(04_terminal_rendering.ipynbshows the software rasterizer, inline PNG frames included); seeexample/julia/README.md. - R —
example/r/(04_terminal_rendering.ipynbshows the software rasterizer, inline PNG frames included); seeexample/r/README.md. - Octave / MATLAB —
example/octave/(04_terminal_rendering.ipynbshows the software rasterizer throughimage); seeexample/octave/README.md.
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/*.ipynbPyVista 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.