magnet.generate.generate_Heterogeneous_cube#

magnet.generate.generate_Heterogeneous_cube(output_path: str, N_parts: int, bounds: tuple[float, float] = (0.07, 0.47))#

Generate a heterogeneous mesh of the unit cube.

Generates a tetrahedral mesh of the unit cube divided into N_parts sections with alternating physical group (0 or 1). The interfaces between sections are generated randomly, as well as the size of the elements.

Parameters:
  • output_path (str) – File path where the mesh will be saved.

  • N_parts (int) – Number of parts in which to split the cube. The cube will be split along the z-axis (must be at least 1).

  • bounds (tuple[float, float], optional) – Bounds of the uniform distribution from which the mesh size parameter is sampled. The smaller this parameter, the smaller the elements of the mesh will be (default is (0.07, 0.47)).

Returns:

  • Adjacency (sparse.csr_matrix of np.uint8) – Adjacency matrix describing the generated mesh.

  • Coords (np.ndarray of float) – Centroid coordinates of each cell of the generated mesh.

  • Volumes (np.ndarray of float) – Volumes of the cells.

Notes

The sections are generated by uniformly sampling N_parts-1 points on each edge of the cube oriented along the z-axis, and then connecting 4 of them at a time in the order they apper from z=0 to z=1 to create an interface. The mesh will thus be made of ‘layers’ along this direction.