morphogen.io

Reading and writing images, meshes and geometries (format chosen by file extension).

Images

.vti (VTK XML), .vtk (legacy VTK), .mhd (MetaImage), .xdmf (XDMF with raw binary data), .npz (NumPy, round-trips metadata), .npy, .tif (tifffile)

Meshes

.inp (Abaqus/CalculiX), .msh (Gmsh 2.2), .vtu, .stl, .mesh (Medit, tetrahedra), .xdmf (tetrahedra with their cell and facet tags for FEniCSx), other extensions through meshio

Geometries

.json (full description), .csv (tables), .geo (Gmsh script)

Solvers

periodic equations (Abaqus/CalculiX), DAMASK grids and materials, Neper seeds (morphogen.io.solvers); the runs of AMITEX_FFTP and their results (morphogen.io.amitex); MFront sources of the nonlinear materials (morphogen.io.mfront); the inputs of OpenRadioss, the explicit solver, and its listings and time histories (morphogen.io.radioss, run by morphogen.dynamics)

Orientations

.ang (EDAX/TSL) and .ctf (Oxford Instruments/HKL) orientation maps of EBSD, and their grains (morphogen.io.ebsd)

Images larger than memory are written slab by slab by voxelize_to_file().

Public names

  • EBSDMap — An orientation map on a rectangular grid.

  • amitex_stiffness — The apparent stiffness (Voigt, engineering shears) of a run of the six unit strains: its column k is the stress at the end of the partial loading k (times).

  • export — Write obj to path in the format of its suffix (see the module); the options go to the writer.

  • mfront_source — The MFront source of the behaviour name of a material (see the module): von Mises plasticity, porous plasticity (the brick, or morphoGen’s kernel), crystal plasticity and the learned laws (morphogen.learning.mfront) in small or finite strains, and in finite strains Hencky’s elasticity of the elastic materials.

  • read_amitex — The averages over the unit cell of an AMITEX_FFTP run (<prefix>.std, the root of its results); small or finite strains are recognized from the header or the number of columns, unless given.

  • read_amitex_materials — The averages over each material (<prefix>.mstd), by material number.

  • read_amitex_run — The results of the runs of an export (<name>_amitex.json in directory; the only one there by default): the averages of each run whose results exist, and for the unit strains the apparent stiffness, the bulk modulus (C_ij summed over the normal components, over 9), the shear modulus (C66, plane 12), the moduli of its isotropic projection and its engineering constants.

  • read_amitex_zones — The averages over each zone of a material (<prefix>_<material>.zstd), by zone number; their internal variables in extra.

  • read_ebsd — The map of an .ang or a .ctf file (by its extension), its orientations in the axes of the map (axes="map"; setting: that of the system of an .ang file) or in those of the file (axes="file").

  • read_json — A microstructure read from a JSON file (from_dict()).

  • read_mhd — A voxel image read from a MetaImage header (.mhd) and its raw data (.raw, or .zraw compressed with zlib).

  • read_msh — Minimal reader of Gmsh 2.2 ASCII files (nodes and elements by type).

  • read_npy — A voxel image of the phases of a NumPy array (.npy), of unit spacing.

  • read_npz — A voxel image read back from the .npz archive of write_npz(), with its spacing, origin, periodicity, name and metadata.

  • read_radioss_listing — The cycles, times and errors of the listing of a Starter or Engine run (<name>_0000.out, <name>_0001.out).

  • read_radioss_th — The columns of a time history converted to CSV (th_to_csv): name -> values, the first column, the time, under "time" as well. The names are those of the header (stripped of their quotes and spaces); a header given twice gets #2…

  • read_stl — Binary STL reader (vertices are not merged).

  • read_table — The columns (name -> values) of a table written by write_table() (or any simple .csv, text or .xlsx table with a header row).

  • read_tet_mesh — Tetrahedral mesh written by morphoGen: .vtu (cell types 10 or 24 and a phase cell array; cell and euler for polycrystals) or Medit .mesh (tetrahedra references = phase + 1, or grain + 1 for polycrystals).

  • read_tiff — A voxel image read from a TIFF stack, with the spacing of its resolution tags (tifffile).

  • read_vti — Read the cell (or point) arrays of a VTK XML ImageData file (only those called names, if given: vti_names() lists them).

  • read_vtk — Read scalar arrays of a legacy STRUCTURED_POINTS file (cell or point data).

  • read_vtk_grid — A legacy VTK file of an unstructured grid (ASCII or binary; the cells as counts and nodes, or as the OFFSETS and CONNECTIVITY of VTK 5.1), e.g. an animation of OpenRadioss converted by its anim_to_vtk: points, offsets (n + 1), connectivity, types, cell_data and point_data (name -> values: SCALARS of one or more components, VECTORS, TENSORS (n, 9), NORMALS and the arrays of FIELD blocks) and field_data (the FIELD arrays given before the data of the points and cells). cells_of_type() picks the cells of one type.

  • read_vtu — Minimal reader of the files written by write_vtu() (points, cells, data).

  • read_xdmf — Image (array name, or the first one) of an XDMF file written by morphoGen.

  • voxelize_to_file — Phase (or with labels, cell label) image of a microstructure written to an .xdmf or .mhd file slab by slab along z: memory holds one slab (about max_voxels voxels, or slab layers), whatever the size of the image. The models whose images are computed pointwise give the same voxels as at once.

  • write_amitex — The inputs of AMITEX_FFTP runs of a periodic voxel image of phases (see the module): materials (phase -> Material), crystals turned by the orientations of their grains (grains: label of each voxel, orientations: Bunge angles of each label). The runs: the six unit strains of the apparent stiffness (stiffness; by default when no loading is given), the named loadings (Loading) and paths (LoadingPath). fields: stress and strain fields at every increment; tolerance: the convergence criterion of AMITEX (Default: 1e-4); library: the path of libUmatAmitex.so (empty: the native laws found through AMITEX_PATH); processes: MPI processes of the script. The nonlinear materials (von Mises and crystal plasticity) are MFront laws, which need loadings or paths (not the unit strains of the stiffness); elastic_only exports their elasticity instead. kinematics: small or finite strains (paths only; every phase but the voids an MFront law).

  • write_amitex_field — An integer field of the voxels as AMITEX_FFTP reads it: legacy VTK with exactly ten header lines (DIMENSIONS: the numbers of voxels plus one, cell data), then big-endian 32-bit integers, x varying fastest.

  • write_amitex_loading — A loading file of AMITEX_FFTP: segments lists the partial loadings, each a tuple (final time, number of increments, the six components at its end, which are strains (controls)). Components are morphoGen’s: Voigt order with engineering shear strains in small strains, the macroscopic components (11, 22, 33, 23, 13, 12) of the gradient and of the nominal stress in finite strains, the gradient upper triangular (as morphoGen’s). fields: the stress and strain fields at every increment.

  • write_csv — Tables of primitives or cells: <stem>_spheres.csv, <stem>_segments.csv, <stem>_cells.csv (only the relevant ones are written).

  • write_damask — DAMASK grid solver inputs: <stem>.vti (material of each voxel: its grain, numbered from 0 over the grains present) and <stem>_material.yaml (homogenization SX, one material per grain with its orientation and phase). grain_phases gives the phase of each grain label (default 1); phase_names the names of the phases; materials (phase -> Material) fills the elastic constants of the crystals (Hooke, in the units of the materials: DAMASK expects pascals); the plastic behaviour is left to the user.

  • write_ebsd — Writes a map as an .ang or a .ctf file (by its extension); axes and setting as in read_ebsd().

  • write_fenicsx — XDMF file of a tetrahedral mesh and its tags, as written and read by FEniCSx (dolfinx.io.XDMFFile, ASCII encoding): the grid mesh (linear tetrahedra), the cell tags phase (and grain for polycrystals) and the facet tags faces (the faces of the box: 1-6 for x0, x1, y0, y1, z0, z1; 1 for the faces bounding whole periodic cells). Reading:

  • write_geo — Gmsh (OpenCASCADE) script building phase 1 (the union of the primitives clipped by the box) or phase 0 (the box minus the union), for conforming tetrahedral meshing with gmsh -3 file.geo. Gmsh is an external program (GPL); nothing is linked.

  • write_inp — Abaqus / CalculiX input file: nodes, elements by phase, face node sets.

  • write_inp_tet — Abaqus / CalculiX input file of a tetrahedral mesh (C3D4 or C3D10 elements).

  • write_json — Full description of a realization; read_json() restores it exactly.

  • write_medit_tet — Medit file (MMG): tetrahedra with reference phase + 1, or grain + 1 for polycrystals (the phase of each grain is then given in a comment), corners only for 10-node meshes; boundary triangles with references 1-6 (faces x0, x1, …, z1), or 1 for the faces bounding whole periodic cells.

  • write_mfront — Write the MFront source of a material (mfront_source()); the name of the behaviour is the stem of path by default.

  • write_mhd — A voxel image written as a MetaImage header (.mhd) and its raw data (.raw, or .zraw compressed with zlib if compress), read by ITK, ParaView and 3D Slicer.

  • write_msh — Gmsh 2.2 ASCII file: hexahedra tagged by phase, optional boundary quadrangles.

  • write_msh_tet — Gmsh 2.2 ASCII file of a tetrahedral mesh (element types 4 and 11).

  • write_neper — Seeds (<stem>_seeds.txt, coordinates in the box), weights (_weights.txt: the radii of a Laguerre tessellation, sqrt of the morphoGen weights) and orientations (_ori.txt: Bunge angles in degrees) of a tessellation, and <stem>_neper.sh, the command building it with Neper (-morphooptiini). Germs outside the box (the window of a non-periodic tessellation) have no Neper equivalent: they are left out, which changes the cells next to the faces.

  • write_npy — The phases of a voxel image written as a NumPy array (.npy), without its spacing or metadata.

  • write_npz — A voxel image written as a NumPy archive (.npz, compressed if compress) with its spacing, origin, periodicity, name, metadata and the version of morphoGen.

  • write_periodic_equations — Abaqus/CalculiX include file of periodic boundary conditions (*INCLUDE it after the mesh): reference nodes REF_X, REF_Y, REF_Z (numbered after the nodes of the mesh), the node set CORNER (a node to fix against translation) and *EQUATION blocks u(n) - u(image of n) - sum_d s_d u(REF_d) = 0, with s_d the periods from the image to the node along each axis (1 for the upper faces of a mesh of the box holding the node; -1, 0 or 1 for whole periodic cells), degrees of freedom 1-3, or 11 for physics='thermal'.

  • write_periodic_pairs — CSV of facing nodes on opposite faces (1-based ids, as in .inp and .msh files). Meshes of whole periodic cells: each node of their boundary that is a translate of another, that node and the periods between them (x_node = x_image + shift * edges).

  • write_radioss — Write the inputs of a run of OpenRadioss for a mesh in directory.

  • write_stl — Binary STL.

  • write_table — Write a table to .csv, .txt/.tsv/.dat or .xlsx (by its suffix); precision significant digits for the text formats (all by default).

  • write_tables — Several tables: the sheets of one .xlsx workbook, or one text file each (<stem>_<name><suffix>).

  • write_tiff — A voxel image written as a TIFF stack (z, y, x) for ImageJ and Fiji, its spacing as resolution (tifffile).

  • write_vti — Write one or several images on the same grid to a VTK XML ImageData file.

  • write_vtk — Legacy VTK STRUCTURED_POINTS with cell data (big-endian binary or ASCII).

  • write_vtu — VTK XML UnstructuredGrid with a single cell type.

  • write_vtu_tet — VTK unstructured grid of a tetrahedral mesh (cell types 10 and 24) with its phases, the grains of polycrystals (cell) and their orientations (euler: Bunge angles in degrees), and optional fields.

  • write_xdmf — XDMF header path and one raw file per image (same grid): <stem>_<name>.raw.

morphogen.io.load_image(path, name: str | None = None) → VoxelImage[source]

Read an image (the array called name, or the first one).

morphogen.io.load_microstructure(path) → Microstructure[source]

A microstructure read back from the .json file that save_microstructure() wrote.

morphogen.io.save_image(images, path, **options) → Path[source]

Write an image, or several images on the same grid (formats .vti and .vtk).

morphogen.io.save_mesh(mesh, path, **options) → Path[source]

A mesh written to a file whose extension gives the format: a surface mesh as .stl, a tetrahedral mesh as .inp, .msh, .vtu, .mesh or .xdmf (FEniCSx), a voxel mesh as .inp, .msh or .vtu, and any of them in the other formats of meshio.

morphogen.io.save_microstructure(micro: Microstructure, path, **options)[source]

Write the explicit geometry of a realization (.json, .csv tables or .geo script).

Modules