cashocs.geometry.mesh#
Basic mesh generation.
Functions
|
Creates an 1D interval mesh starting at x=0 to x=length. |
|
Creates a mesh corresponding to a rectangle or cube. |
|
Creates a mesh corresponding to a rectangle or cube. |
Classes
|
Special type indicating an unconstrained type. |
- cashocs.geometry.mesh.interval_mesh(n=10, start=0.0, end=1.0, partitions=None, comm=None)[source]#
Creates an 1D interval mesh starting at x=0 to x=length.
This function creates a uniform mesh of a 1D interval, starting at the
start
and ending atend
. The resulting mesh usesn
sub-intervals to discretize the geometry. The boundary markers are as follows:1 corresponds to \(x=start\)
2 corresponds to \(x=end\)
- Parameters:
n (int) – Number of elements for discretizing the interval, default is 10
start (float) – The start of the interval, default is 0.0
end (float) – The end of the interval, default is 1.0
partitions (Optional[List[float]]) – Points in the interval at which a partition in subdomains should be made. The resulting volume measure is sorted ascendingly according to the sub-intervals defined in partitions (starting at 1). Defaults to
None
.comm (Optional[MPI.Comm]) – 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
- cashocs.geometry.mesh.regular_box_mesh(n=10, start_x=0.0, start_y=0.0, start_z=None, end_x=1.0, end_y=1.0, end_z=None, diagonal='right', comm=None)[source]#
Creates a mesh corresponding to a rectangle or cube.
This function creates a uniform mesh of either a rectangle or a cube, with specified start (
S_
) and end points (E_
). The resulting mesh usesn
elements along the shortest direction and accordingly many along the longer ones. The resulting domain is\[\begin{split}\begin{alignedat}{2} &[start_x, end_x] \times [start_y, end_y] \quad &&\text{ in } 2D, \\ &[start_x, end_x] \times [start_y, end_y] \times [start_z, end_z] \quad &&\text{ in } 3D. \end{alignedat}\end{split}\]The boundary markers are ordered as follows:
1 corresponds to \(x=start_x\).
2 corresponds to \(x=end_x\).
3 corresponds to \(y=start_y\).
4 corresponds to \(y=end_y\).
5 corresponds to \(z=start_z\) (only in 3D).
6 corresponds to \(z=end_z\) (only in 3D).
- Parameters:
n (int) – Number of elements in the shortest coordinate direction.
start_x (float) – Start of the x-interval.
start_y (float) – Start of the y-interval.
start_z (Optional[float]) – Start of the z-interval, mesh is 2D if this is
None
(default isNone
).end_x (float) – End of the x-interval.
end_y (float) – End of the y-interval.
end_z (Optional[float]) – End of the z-interval, mesh is 2D if this is
None
(default isNone
).diagonal (Literal['right', 'left', '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 (Optional[MPI.Comm]) – 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
- cashocs.geometry.mesh.regular_mesh(n=10, length_x=1.0, length_y=1.0, length_z=None, diagonal='right', comm=None)[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
, andlength_z
. The resulting mesh usesn
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 (Optional[float]) – Length in z-direction, if this is
None
, then the geometry will be two-dimensional (default isNone
).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 (Optional[MPI.Comm]) – 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