morphogen.io.meshes

Mesh files: Abaqus/CalculiX (.inp), Gmsh 2.2 (.msh), VTK (.vtu), Medit (.mesh), STL, and meshio.

Voxel meshes (8-node hexahedra) and conforming tetrahedral meshes (4- or 10-node tetrahedra) are written with their phases (element sets, physical groups or cell data) and the nodes or element faces lying on the six faces of the box, or, for meshes of whole periodic cells, on the boundary of the cells (outer).

morphogen.io.meshes.FACE_TAGS = {'outer': 107, 'x0': 101, 'x1': 102, 'y0': 103, 'y1': 104, 'z0': 105, 'z1': 106}

boundary of whole cells).

Type:

Physical tags of the box faces in Gmsh files (outer

morphogen.io.meshes.write_inp(path, mesh: VoxelMesh, *, element_type: str = 'C3D8', label_sets: bool = False, materials: dict | None = None, orientations=None, kinematics: str = 'small')[source]

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

Element sets PHASE_<p> (and CELL_<id> with label_sets), node sets X0, X1, Y0, Y1, Z0, Z1. orientations (Bunge angles of each label) adds the sets of the cells and their orientations ORI_<id>; materials the materials and the solid sections, as write_inp_tet() (one per cell, with its orientation, when orientations are given; one per phase otherwise), in small or finite strains (kinematics).

morphogen.io.meshes.write_msh(path, mesh: VoxelMesh, *, boundary: bool = True)[source]

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

Physical volumes phase_<p> have tag p + 1; the elementary tag is the cell label + 1 when labels are attached. Physical surfaces x0 ... z1 (tags 101-106) hold the element faces lying on the box faces.

morphogen.io.meshes.read_msh(path) → dict[source]

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

morphogen.io.meshes.write_vtu_mesh(path, mesh: VoxelMesh, *, compress: bool = True)[source]

A voxel mesh written as a VTK unstructured grid (.vtu) of hexahedra, with the phase of each element (and its cell, if labelled).

morphogen.io.meshes.write_periodic_pairs(path, mesh: VoxelMesh | TetMesh) → Path[source]

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).

morphogen.io.meshes.abaqus_anisotropic(stiffness) → list[float][source]

The 21 constants of Abaqus’s *ELASTIC, TYPE=ANISOTROPIC: D1111, D1122, D2222, D1133, D2233, D3333, D1112, D2212, D3312, D1212, D1113, D2213, D3313, D1213, D1313, D1123, D2223, D3323, D1223, D1323, D2323 (Abaqus’s components 11, 22, 33, 12, 13, 23, engineering shear strains), of a stiffness in morphoGen’s Voigt order (11, 22, 33, 23, 31, 12).

morphogen.io.meshes.write_inp_tet(path, mesh: TetMesh, *, materials: dict | None = None, kinematics: str = 'small') → Path[source]

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

Element sets PHASE_<p>, node sets X0, X1, Y0, Y1, Z0, Z1 (OUTER, the boundary of whole periodic cells). Meshes of polycrystals add one element set per grain, CELL_<id>, and the orientation of its crystal axes, ORI_<id> (rectangular system: the axes [100] and [010] of the crystal in the axes of the box). materials writes the solid sections, one per grain with its orientation for polycrystals: phase -> the name of a material defined elsewhere, or phase -> Material, defined in the file: *ELASTIC (isotropic, or the 21 constants of TYPE=ANISOTROPIC in the axes of the crystal: see abaqus_anisotropic()), *EXPANSION, *DENSITY, and the nonlinear materials as the MFront laws of the abaqus interface (morphogen.io.mfront, their sources in <stem>_mfront): the material ABAQUSBEHAVIOUR_<behaviour>_3D, its *DEPVAR and *USER MATERIAL (one constant, zero, which the interface asks of laws without material properties). Voids have no section. In finite strains (kinematics), every material is an MFront law (Hencky’s elasticity for the elastic ones; steps with NLGEOM=YES), and the orthotropic laws read the axes of their crystals in their first six state variables, which *INITIAL CONDITIONS, TYPE=SOLUTION gives (MFront’s abaqus interface takes no *ORIENTATION in finite strains). When a material expands, the nodes start at 293.15 K (*INITIAL CONDITIONS, TYPE=TEMPERATURE), from which the MFront laws count their expansion: the steps give absolute temperatures.

morphogen.io.meshes.write_msh_tet(path, mesh: TetMesh, *, boundary: bool = True) → Path[source]

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

Physical volumes phase_<p> have tag p + 1; the elementary tag is the grain + 1 for polycrystals; physical surfaces x0 ... z1 (tags 101-106) hold the element faces (3- or 6-node triangles) lying on the box faces, outer (tag 107) those bounding whole periodic cells.

morphogen.io.meshes.write_vtu_tet(path, mesh: TetMesh, cell_data: dict | None = None, point_data: dict | None = None, *, compress: bool = True) → Path[source]

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.

morphogen.io.meshes.write_medit_tet(path, mesh: TetMesh) → Path[source]

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.

morphogen.io.meshes.read_tet_mesh(path, *, box=None, periodic: bool | None = None) → TetMesh[source]

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).

The box ((lower, upper)) and the periodicity are read from the file when it records them (files written by morphoGen do); otherwise the box is the bounding box of the nodes, which is wrong when the meshed phases do not touch every face. Meshes of whole periodic cells keep the faces bounding them.

morphogen.io.meshes.write_stl(path, surface: SurfaceMesh, *, name: str = 'morphogen') → Path[source]

Binary STL.

morphogen.io.meshes.read_stl(path) → SurfaceMesh[source]

Binary STL reader (vertices are not merged).

morphogen.io.meshes.write_meshio(path, mesh: VoxelMesh | TetMesh | SurfaceMesh) → Path[source]

Any other format supported by the optional meshio package.