shapes.rectangle#
- shapes.rectangle(dim=(1.0, 1.0), corner=(0.0, 0.0, 0.0), div=1, eltype='line2')#
Create a rectangle mesh in the xy-plane.
Parameters#
- dimtuple of float, optional
Dimensions of the rectangle. First value specifies the width along the x-axis, second value the height along the y-axis. Default is (1.0, 1.0).
- cornerarray_like of shape (3,), optional
Coordinates of the bottom-left corner of the rectangle. Default is (0.0, 0.0, 0.0).
- divseed or list of two seeds, optional
Subdivision specification along the width and height. div can be any of the values accepted by
smartSeed(), or a list of two such values. If only one seed is given, it is applied to both directions.Accepted values for each seed are:
If int: number of equal subdivisions.
If list of floats: explicit subdivision values (must start with 0.0 and end with 1.0).
If tuple: (n, bias_start, bias_end), see
smartSeed().
- eltype{“quad4”, “tri3”, “line2”}, optional
Output element type:
“quad4”: quadrilateral surface mesh (default).
“tri3”: triangular surface mesh (each quad split into triangles).
“line2”: line mesh representing the boundary edges only.
Returns#
- Mesh
Mesh representation of the rectangle in the specified element type.
Examples#
>>> M1 = rectangle(div=[3, 1], eltype="quad4") >>> print(M1) Mesh: n_nodes: 8, n_elems: 3, plexitude: 4, level: 2, eltype: quad4 BBox: [0. 0. 0.], [1. 1. 0.] Size: [1. 1. 0.] Length: 4.0 Area: 1.0
Rectangle consisting of triangular elements:
>>> M2 = rectangle(div=2, eltype="tri3") >>> print(M2) Mesh: n_nodes: 9, n_elems: 8, plexitude: 3, level: 2, eltype: tri3 BBox: [0. 0. 0.], [1. 1. 0.] Size: [1. 1. 0.] Length: 4.0 Area: 1.0
Contour of a rectangle (line elements):
>>> M3 = rectangle(dim=(3.0, 2.0), corner=(1.0, 1.0, 0.0), eltype="line2") >>> print(M3) Mesh: n_nodes: 4, n_elems: 4, plexitude: 2, level: 1, eltype: line2 BBox: [1. 1. 0.], [4. 3. 0.] Size: [3. 2. 0.] Length: 10.0