morphogen.io¶
Reading and writing images, meshes and geometries (format chosen by file extension).
Images |
|
Meshes |
|
Geometries |
|
Solvers |
periodic equations (Abaqus/CalculiX), DAMASK grids and materials, Neper
seeds ( |
Orientations |
|
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— Writeobjtopathin the format of its suffix (see the module); the options go to the writer.mfront_source— The MFront source of the behaviournameof 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.jsonindirectory; 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_ijsummed 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 inextra.read_ebsd— The map of an.angor a.ctffile (by its extension), its orientations in the axes of the map (axes="map";setting: that of the system of an.angfile) 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 ofwrite_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 bywrite_table()(or any simple.csv, text or.xlsxtable with a header row).read_tet_mesh— Tetrahedral mesh written by morphoGen:.vtu(cell types 10 or 24 and aphasecell array;cellandeulerfor 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 callednames, 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 theOFFSETSandCONNECTIVITYof VTK 5.1), e.g. an animation of OpenRadioss converted by itsanim_to_vtk:points,offsets(n + 1),connectivity,types,cell_dataandpoint_data(name -> values:SCALARSof one or more components,VECTORS,TENSORS(n, 9),NORMALSand the arrays ofFIELDblocks) andfield_data(theFIELDarrays 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 bywrite_vtu()(points, cells, data).read_xdmf— Image (arrayname, or the first one) of an XDMF file written by morphoGen.voxelize_to_file— Phase (or withlabels, cell label) image of a microstructure written to an.xdmfor.mhdfile slab by slab along z: memory holds one slab (aboutmax_voxelsvoxels, orslablayers), 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 namedloadings(Loading) andpaths(LoadingPath).fields: stress and strain fields at every increment;tolerance: the convergence criterion of AMITEX (Default: 1e-4);library: the path oflibUmatAmitex.so(empty: the native laws found throughAMITEX_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_onlyexports 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:segmentslists 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(materialof each voxel: its grain, numbered from 0 over the grains present) and<stem>_material.yaml(homogenizationSX, one material per grain with its orientation and phase).grain_phasesgives the phase of each grain label (default 1);phase_namesthe 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.angor a.ctffile (by its extension);axesandsettingas inread_ebsd().write_fenicsx— XDMF file of a tetrahedral mesh and its tags, as written and read by FEniCSx (dolfinx.io.XDMFFile, ASCII encoding): the gridmesh(linear tetrahedra), the cell tagsphase(andgrainfor polycrystals) and the facet tagsfaces(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 withgmsh -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 ofpathby default.write_mhd— A voxel image written as a MetaImage header (.mhd) and its raw data (.raw, or .zraw compressed with zlib ifcompress), 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 ifcompress) with its spacing, origin, periodicity, name, metadata and the version of morphoGen.write_periodic_equations— Abaqus/CalculiX include file of periodic boundary conditions (*INCLUDEit after the mesh): reference nodesREF_X,REF_Y,REF_Z(numbered after the nodes of the mesh), the node setCORNER(a node to fix against translation) and*EQUATIONblocksu(n) - u(image of n) - sum_d s_d u(REF_d) = 0, withs_dthe 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 forphysics='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 indirectory.write_stl— Binary STL.write_table— Write a table to.csv,.txt/.tsv/.dator.xlsx(by its suffix);precisionsignificant digits for the text formats (all by default).write_tables— Several tables: the sheets of one.xlsxworkbook, 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 headerpathand 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).