mymesh.primitives.Cylinder#

mymesh.primitives.Cylinder(center, radius, height, theta_resolution=20, axial_resolution=10, radial_resolution=10, axis=2, cap=True, ElemType=None, Type='surf')[source]#

Generate an axis-aligned cylindrical mesh

Parameters:
  • center (array_like) – Coordinates of the center of the circle at the base of the cylinder (x,y,z).

  • radius (scalar or array_like) – The radius of the cylinder. Radius can be specified as a scalar radius of the cylinder or a two element array of half-axes for a cylinder with an elliptical cross-section. For elliptical cross-sections, the two elements correspond to the two axes in the plane perpendicular to <axis> (e.g. if axis=2, (r1, r2) specify the x, y radii, respectively; if axis=1, (r1, r2) specify the x, z radii, respectively, etc.).

  • height (float) – height of the cylinder. Cylinder will be extruded from <center> by <height> in the <axis> direction. To extrude in the negative-<axis> direction, a negative height can be given.

  • theta_resolution (int, optional) – Number of points in the circumference of the cylinder, by default 20.

  • axial_resolution (int, optional) – Number of points along the axis of the cylinder, by default 10.

  • radial_resolution (int, optional) – Number of radial points from center to edge, by default 10. Only relevant if Type=’vol’.

  • axis (int, optional) – Long axis of the cylinder (i.e. the circular ends will lie in the plane of the other two axes). Must be 0, 1, or 2 (x, y, z), by default 2

  • cap (bool, optional) – If True, will close the ends of the cylinder, otherwise it will leave them open, by default True.

  • ElemType (str, optional) – Specify the element type of the mesh. If Type=’surf’ (default), ElemType can be ‘tri’, which will produce a purely triangular mesh or None, which will produce a quad-dominant mesh with some triangles. If Type=’vol’, ElemType can be ‘tet’, which will produce a purely tetrahedral mesh or None, which will produce a hex-dominant mesh with some tetrahedra. By default, None.

  • Type (str, optional) – Mesh type of the final mesh. This could be ‘surf’ for a surface mesh or ‘vol’ for a volumetric mesh, by default ‘surf’.

Returns:

cylinder – Mesh object containing the cylinder mesh.

Return type:

mymesh.mesh

Note

Due to the ability to unpack the mesh object to NodeCoords and NodeConn, the NodeCoords and NodeConn array can be returned directly (instead of the mesh object) by running: NodeCoords, NodeConn = primitives.Cylinder(...)

Examples

cylinder = primitives.Cylinder([0,0,0], 1, 2, 20, axis=2)
cylinder.plot(bgcolor='w', show_edges=True)
../../_images/mymesh-primitives-Cylinder-1.png