cashocs.geometry.mesh.regular_mesh#

cashocs.geometry.mesh.regular_mesh(n: int = 10, length_x: float = 1.0, length_y: float = 1.0, length_z: float | None = None, diagonal: Literal['left', 'right', 'left/right', 'right/left', 'crossed'] = 'right', comm: MPI.Comm | None = None) _typing.MeshTuple[source]#

Creates a mesh corresponding to a rectangle or cube.

This function creates a uniform mesh of either a rectangle or a cube, starting at the origin and having length specified in length_x, length_y, and length_z. The resulting mesh uses n elements along the shortest direction and accordingly many along the longer ones. The resulting domain is

\[\begin{split}\begin{alignedat}{2} &[0, length_x] \times [0, length_y] \quad &&\text{ in } 2D, \\ &[0, length_x] \times [0, length_y] \times [0, length_z] \quad &&\text{ in } 3D. \end{alignedat}\end{split}\]

The boundary markers are ordered as follows:

  • 1 corresponds to \(x=0\).

  • 2 corresponds to \(x=length_x\).

  • 3 corresponds to \(y=0\).

  • 4 corresponds to \(y=length_y\).

  • 5 corresponds to \(z=0\) (only in 3D).

  • 6 corresponds to \(z=length_z\) (only in 3D).

Parameters:
  • n (int) – Number of elements in the shortest coordinate direction.

  • length_x (float) – Length in x-direction.

  • length_y (float) – Length in y-direction.

  • length_z (float | None) – Length in z-direction, if this is None, then the geometry will be two-dimensional (default is None).

  • diagonal (Literal['left', 'right', 'left/right', 'right/left', 'crossed']) – This defines the type of diagonal used to create the box mesh in 2D. This can be one of "right", "left", "left/right", "right/left" or "crossed".

  • comm (MPI.Comm | None) – MPI communicator that is to be used for creating the mesh.

Returns:

A tuple (mesh, subdomains, boundaries, dx, ds, dS), where mesh is the imported FEM mesh, subdomains is a mesh function for the subdomains, boundaries is a mesh function for the boundaries, dx is a volume measure, ds is a surface measure, and dS is a measure for the interior facets.

Return type:

_typing.MeshTuple