felupe.mesh#

class felupe.mesh.Line(a=0, b=1, n=2)[source]#
add_midpoints_edges(cells, cell_type)#

“Add midpoints on edges for given points and cells and update cell_type accordingly.

add_midpoints_faces(cells, cell_type)#

“Add midpoints on faces for given points and cells and update cell_type accordingly.

add_midpoints_volumes(cells, cell_type)#

“Add midpoints on volumes for given points and cells and update cell_type accordingly.

add_runouts(cells, cell_type, values=[0.1, 0.1], centerpoint=[0, 0, 0], axis=0, exponent=5, mask=slice(None, None, None))#

Add simple rubber-runouts for realistic rubber-metal structures.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • values (list or ndarray, optional) – Relative amount of runouts (per coordinate) perpendicular to the axis (default is 10% per coordinate, i.e. [0.1, 0.1]).

  • centerpoint (list or ndarray, optional) – Center-point coordinates (default is [0, 0, 0]).

  • axis (int or None, optional) – Axis (default is 0).

  • exponent (int, optional) – Positive exponent to control the shape of the runout. The higher the exponent, the steeper the transition (default is 5).

  • mask (list or None, optional) – List of points to be considered (default is None).

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (ndarray) – Modified point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

as_meshio(**kwargs)#

Export the mesh as meshio.Mesh.

collect_edges(cells, cell_type)#

“Collect all unique edges, calculate and return midpoints on edges as well as the additional cells array.

collect_faces(cells, cell_type)#

“Collect all unique faces, calculate and return midpoints on faces as well as the additional cells array.

collect_volumes(cells, cell_type)#

“Collect all volumes, calculate and return midpoints on volumes as well as the additional cells array.

convert(cells, cell_type, order=0, calc_points=False, calc_midfaces=False, calc_midvolumes=False)#

Convert mesh to a given order (only order=0 and order=2 from order=1 are supported).

copy()#

Return a deepcopy of the mesh.

Returns:

A deepcopy of the mesh.

Return type:

Mesh

disconnect(points_per_cell=None, calc_points=True)#

Return a new instance of a Mesh with disconnected cells. Optionally, the points-per-cell may be specified (must be lower or equal the number of points- per-cell of the original Mesh). If the Mesh is to be used as a dual Mesh, then the point-coordinates do not have to be re-created because they are not used.

dual(cells, cell_type, points_per_cell=None, disconnect=True, calc_points=False, offset=0, npoints=None)#

Create a new dual mesh with given points per cell. The point coordinates are not used in a dual mesh and hence, by default they are all zero.

expand(cells, cell_type, n=11, z=1)#

Expand a 1d-Line to a 2d-Quad or a 2d-Quad to a 3d-Hexahedron Mesh.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • n (int, optional) – Number of n-point repetitions or (n-1)-cell repetitions, default is 11.

  • z (float or ndarray, optional) – Total expand dimension as float (edge length in expand direction is z / n), default is 1. Optionally, if an array is passed these entries are taken as expansion and n is ignored.

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (ndarray) – Modified point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

flip(cells, cell_type, mask=None)#

Ensure positive cell volumes for tria, tetra, quad and hexahedron cell types.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • mask (list or ndarray, optional) – Boolean mask for selected cells to flip.

Returns:

  • points (ndarray) – Point coordinates.

  • cells (ndarray) – Modified point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

mirror(cells, cell_type, normal=[1, 0, 0], centerpoint=[0, 0, 0], axis=None)#

Mirror points by plane normal and ensure positive cell volumes for tria, tetra, quad and hexahedron cell types.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • normal (list or ndarray, optional) – Mirror-plane normal vector (default is [1, 0, 0]).

  • centerpoint (list or ndarray, optional) – Center-point coordinates on the mirror plane (default is [0, 0, 0]).

  • axis (int or None, optional) – Mirror axis (default is None).

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (ndarray) – Modified point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

revolve(cells, cell_type, n=11, phi=180, axis=0)#

Revolve a 2d-Quad to a 3d-Hexahedron Mesh.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • n (int, optional) – Number of n-point revolutions (or (n-1) cell revolutions), default is 11.

  • phi (float or ndarray, optional) – Revolution angle in degree (default is 180).

  • axis (int, optional) – Revolution axis (default is 0).

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (list or ndarray) – Modified point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

rotate(cells, cell_type, angle_deg, axis, center=None)#

Rotate a Mesh.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • angle_deg (int) – Rotation angle in degree.

  • axis (int) – Rotation axis.

  • center (list or ndarray or None, optional) – Center point coordinates (default is None).

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

save(filename='mesh.vtk', **kwargs)#

Export the mesh as VTK file. For XDMF-export please ensure to have h5py (as an optional dependancy of meshio) installed.

Parameters:

filename (str, optional) – The filename of the mesh (default is mesh.vtk).

sweep(cells, cell_type, decimals=None)#

Sweep duplicated points and update cells of a Mesh.

WARNING: This function sorts points.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • decimals (int or None, optional) – Number of decimals for point coordinate comparison (default is None).

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (list or ndarray) – Modified point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

translate(cells, cell_type, move, axis)#

Translate (move) a Mesh.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • move (float) – Translation along given axis.

  • axis (int) – Translation axis.

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

triangulate(cells, cell_type, mode=3)#

Triangulate a quad or a hex mesh.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • mode (int, optional) – Choose a mode how to convert hexahedrons to tets [1] (default is 3).

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (ndarray) – Modified point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

References

[1] Dompierre, J., Labbé, P., Vallet, M. G., & Camarero, R. (1999). How to Subdivide Pyramids, Prisms, and Hexahedra into Tetrahedra. IMR, 99, 195.

update(cells, cell_type=None)#

Update the cell and dimension attributes with a given cell array.

class felupe.mesh.Rectangle(a=(0, 0), b=(1, 1), n=(2, 2))[source]#
add_midpoints_edges(cells, cell_type)#

“Add midpoints on edges for given points and cells and update cell_type accordingly.

add_midpoints_faces(cells, cell_type)#

“Add midpoints on faces for given points and cells and update cell_type accordingly.

add_midpoints_volumes(cells, cell_type)#

“Add midpoints on volumes for given points and cells and update cell_type accordingly.

add_runouts(cells, cell_type, values=[0.1, 0.1], centerpoint=[0, 0, 0], axis=0, exponent=5, mask=slice(None, None, None))#

Add simple rubber-runouts for realistic rubber-metal structures.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • values (list or ndarray, optional) – Relative amount of runouts (per coordinate) perpendicular to the axis (default is 10% per coordinate, i.e. [0.1, 0.1]).

  • centerpoint (list or ndarray, optional) – Center-point coordinates (default is [0, 0, 0]).

  • axis (int or None, optional) – Axis (default is 0).

  • exponent (int, optional) – Positive exponent to control the shape of the runout. The higher the exponent, the steeper the transition (default is 5).

  • mask (list or None, optional) – List of points to be considered (default is None).

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (ndarray) – Modified point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

as_meshio(**kwargs)#

Export the mesh as meshio.Mesh.

collect_edges(cells, cell_type)#

“Collect all unique edges, calculate and return midpoints on edges as well as the additional cells array.

collect_faces(cells, cell_type)#

“Collect all unique faces, calculate and return midpoints on faces as well as the additional cells array.

collect_volumes(cells, cell_type)#

“Collect all volumes, calculate and return midpoints on volumes as well as the additional cells array.

convert(cells, cell_type, order=0, calc_points=False, calc_midfaces=False, calc_midvolumes=False)#

Convert mesh to a given order (only order=0 and order=2 from order=1 are supported).

copy()#

Return a deepcopy of the mesh.

Returns:

A deepcopy of the mesh.

Return type:

Mesh

disconnect(points_per_cell=None, calc_points=True)#

Return a new instance of a Mesh with disconnected cells. Optionally, the points-per-cell may be specified (must be lower or equal the number of points- per-cell of the original Mesh). If the Mesh is to be used as a dual Mesh, then the point-coordinates do not have to be re-created because they are not used.

dual(cells, cell_type, points_per_cell=None, disconnect=True, calc_points=False, offset=0, npoints=None)#

Create a new dual mesh with given points per cell. The point coordinates are not used in a dual mesh and hence, by default they are all zero.

expand(cells, cell_type, n=11, z=1)#

Expand a 1d-Line to a 2d-Quad or a 2d-Quad to a 3d-Hexahedron Mesh.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • n (int, optional) – Number of n-point repetitions or (n-1)-cell repetitions, default is 11.

  • z (float or ndarray, optional) – Total expand dimension as float (edge length in expand direction is z / n), default is 1. Optionally, if an array is passed these entries are taken as expansion and n is ignored.

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (ndarray) – Modified point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

flip(cells, cell_type, mask=None)#

Ensure positive cell volumes for tria, tetra, quad and hexahedron cell types.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • mask (list or ndarray, optional) – Boolean mask for selected cells to flip.

Returns:

  • points (ndarray) – Point coordinates.

  • cells (ndarray) – Modified point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

mirror(cells, cell_type, normal=[1, 0, 0], centerpoint=[0, 0, 0], axis=None)#

Mirror points by plane normal and ensure positive cell volumes for tria, tetra, quad and hexahedron cell types.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • normal (list or ndarray, optional) – Mirror-plane normal vector (default is [1, 0, 0]).

  • centerpoint (list or ndarray, optional) – Center-point coordinates on the mirror plane (default is [0, 0, 0]).

  • axis (int or None, optional) – Mirror axis (default is None).

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (ndarray) – Modified point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

revolve(cells, cell_type, n=11, phi=180, axis=0)#

Revolve a 2d-Quad to a 3d-Hexahedron Mesh.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • n (int, optional) – Number of n-point revolutions (or (n-1) cell revolutions), default is 11.

  • phi (float or ndarray, optional) – Revolution angle in degree (default is 180).

  • axis (int, optional) – Revolution axis (default is 0).

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (list or ndarray) – Modified point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

rotate(cells, cell_type, angle_deg, axis, center=None)#

Rotate a Mesh.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • angle_deg (int) – Rotation angle in degree.

  • axis (int) – Rotation axis.

  • center (list or ndarray or None, optional) – Center point coordinates (default is None).

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

save(filename='mesh.vtk', **kwargs)#

Export the mesh as VTK file. For XDMF-export please ensure to have h5py (as an optional dependancy of meshio) installed.

Parameters:

filename (str, optional) – The filename of the mesh (default is mesh.vtk).

sweep(cells, cell_type, decimals=None)#

Sweep duplicated points and update cells of a Mesh.

WARNING: This function sorts points.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • decimals (int or None, optional) – Number of decimals for point coordinate comparison (default is None).

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (list or ndarray) – Modified point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

translate(cells, cell_type, move, axis)#

Translate (move) a Mesh.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • move (float) – Translation along given axis.

  • axis (int) – Translation axis.

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

triangulate(cells, cell_type, mode=3)#

Triangulate a quad or a hex mesh.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • mode (int, optional) – Choose a mode how to convert hexahedrons to tets [1] (default is 3).

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (ndarray) – Modified point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

References

[1] Dompierre, J., Labbé, P., Vallet, M. G., & Camarero, R. (1999). How to Subdivide Pyramids, Prisms, and Hexahedra into Tetrahedra. IMR, 99, 195.

update(cells, cell_type=None)#

Update the cell and dimension attributes with a given cell array.

class felupe.mesh.Cube(a=(0, 0, 0), b=(1, 1, 1), n=(2, 2, 2))[source]#
add_midpoints_edges(cells, cell_type)#

“Add midpoints on edges for given points and cells and update cell_type accordingly.

add_midpoints_faces(cells, cell_type)#

“Add midpoints on faces for given points and cells and update cell_type accordingly.

add_midpoints_volumes(cells, cell_type)#

“Add midpoints on volumes for given points and cells and update cell_type accordingly.

add_runouts(cells, cell_type, values=[0.1, 0.1], centerpoint=[0, 0, 0], axis=0, exponent=5, mask=slice(None, None, None))#

Add simple rubber-runouts for realistic rubber-metal structures.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • values (list or ndarray, optional) – Relative amount of runouts (per coordinate) perpendicular to the axis (default is 10% per coordinate, i.e. [0.1, 0.1]).

  • centerpoint (list or ndarray, optional) – Center-point coordinates (default is [0, 0, 0]).

  • axis (int or None, optional) – Axis (default is 0).

  • exponent (int, optional) – Positive exponent to control the shape of the runout. The higher the exponent, the steeper the transition (default is 5).

  • mask (list or None, optional) – List of points to be considered (default is None).

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (ndarray) – Modified point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

as_meshio(**kwargs)#

Export the mesh as meshio.Mesh.

collect_edges(cells, cell_type)#

“Collect all unique edges, calculate and return midpoints on edges as well as the additional cells array.

collect_faces(cells, cell_type)#

“Collect all unique faces, calculate and return midpoints on faces as well as the additional cells array.

collect_volumes(cells, cell_type)#

“Collect all volumes, calculate and return midpoints on volumes as well as the additional cells array.

convert(cells, cell_type, order=0, calc_points=False, calc_midfaces=False, calc_midvolumes=False)#

Convert mesh to a given order (only order=0 and order=2 from order=1 are supported).

copy()#

Return a deepcopy of the mesh.

Returns:

A deepcopy of the mesh.

Return type:

Mesh

disconnect(points_per_cell=None, calc_points=True)#

Return a new instance of a Mesh with disconnected cells. Optionally, the points-per-cell may be specified (must be lower or equal the number of points- per-cell of the original Mesh). If the Mesh is to be used as a dual Mesh, then the point-coordinates do not have to be re-created because they are not used.

dual(cells, cell_type, points_per_cell=None, disconnect=True, calc_points=False, offset=0, npoints=None)#

Create a new dual mesh with given points per cell. The point coordinates are not used in a dual mesh and hence, by default they are all zero.

expand(cells, cell_type, n=11, z=1)#

Expand a 1d-Line to a 2d-Quad or a 2d-Quad to a 3d-Hexahedron Mesh.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • n (int, optional) – Number of n-point repetitions or (n-1)-cell repetitions, default is 11.

  • z (float or ndarray, optional) – Total expand dimension as float (edge length in expand direction is z / n), default is 1. Optionally, if an array is passed these entries are taken as expansion and n is ignored.

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (ndarray) – Modified point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

flip(cells, cell_type, mask=None)#

Ensure positive cell volumes for tria, tetra, quad and hexahedron cell types.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • mask (list or ndarray, optional) – Boolean mask for selected cells to flip.

Returns:

  • points (ndarray) – Point coordinates.

  • cells (ndarray) – Modified point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

mirror(cells, cell_type, normal=[1, 0, 0], centerpoint=[0, 0, 0], axis=None)#

Mirror points by plane normal and ensure positive cell volumes for tria, tetra, quad and hexahedron cell types.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • normal (list or ndarray, optional) – Mirror-plane normal vector (default is [1, 0, 0]).

  • centerpoint (list or ndarray, optional) – Center-point coordinates on the mirror plane (default is [0, 0, 0]).

  • axis (int or None, optional) – Mirror axis (default is None).

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (ndarray) – Modified point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

revolve(cells, cell_type, n=11, phi=180, axis=0)#

Revolve a 2d-Quad to a 3d-Hexahedron Mesh.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • n (int, optional) – Number of n-point revolutions (or (n-1) cell revolutions), default is 11.

  • phi (float or ndarray, optional) – Revolution angle in degree (default is 180).

  • axis (int, optional) – Revolution axis (default is 0).

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (list or ndarray) – Modified point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

rotate(cells, cell_type, angle_deg, axis, center=None)#

Rotate a Mesh.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • angle_deg (int) – Rotation angle in degree.

  • axis (int) – Rotation axis.

  • center (list or ndarray or None, optional) – Center point coordinates (default is None).

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

save(filename='mesh.vtk', **kwargs)#

Export the mesh as VTK file. For XDMF-export please ensure to have h5py (as an optional dependancy of meshio) installed.

Parameters:

filename (str, optional) – The filename of the mesh (default is mesh.vtk).

sweep(cells, cell_type, decimals=None)#

Sweep duplicated points and update cells of a Mesh.

WARNING: This function sorts points.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • decimals (int or None, optional) – Number of decimals for point coordinate comparison (default is None).

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (list or ndarray) – Modified point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

translate(cells, cell_type, move, axis)#

Translate (move) a Mesh.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • move (float) – Translation along given axis.

  • axis (int) – Translation axis.

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

triangulate(cells, cell_type, mode=3)#

Triangulate a quad or a hex mesh.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • mode (int, optional) – Choose a mode how to convert hexahedrons to tets [1] (default is 3).

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (ndarray) – Modified point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

References

[1] Dompierre, J., Labbé, P., Vallet, M. G., & Camarero, R. (1999). How to Subdivide Pyramids, Prisms, and Hexahedra into Tetrahedra. IMR, 99, 195.

update(cells, cell_type=None)#

Update the cell and dimension attributes with a given cell array.

class felupe.mesh.Grid(*xi, indexing='ij', **kwargs)[source]#
add_midpoints_edges(cells, cell_type)#

“Add midpoints on edges for given points and cells and update cell_type accordingly.

add_midpoints_faces(cells, cell_type)#

“Add midpoints on faces for given points and cells and update cell_type accordingly.

add_midpoints_volumes(cells, cell_type)#

“Add midpoints on volumes for given points and cells and update cell_type accordingly.

add_runouts(cells, cell_type, values=[0.1, 0.1], centerpoint=[0, 0, 0], axis=0, exponent=5, mask=slice(None, None, None))#

Add simple rubber-runouts for realistic rubber-metal structures.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • values (list or ndarray, optional) – Relative amount of runouts (per coordinate) perpendicular to the axis (default is 10% per coordinate, i.e. [0.1, 0.1]).

  • centerpoint (list or ndarray, optional) – Center-point coordinates (default is [0, 0, 0]).

  • axis (int or None, optional) – Axis (default is 0).

  • exponent (int, optional) – Positive exponent to control the shape of the runout. The higher the exponent, the steeper the transition (default is 5).

  • mask (list or None, optional) – List of points to be considered (default is None).

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (ndarray) – Modified point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

as_meshio(**kwargs)#

Export the mesh as meshio.Mesh.

collect_edges(cells, cell_type)#

“Collect all unique edges, calculate and return midpoints on edges as well as the additional cells array.

collect_faces(cells, cell_type)#

“Collect all unique faces, calculate and return midpoints on faces as well as the additional cells array.

collect_volumes(cells, cell_type)#

“Collect all volumes, calculate and return midpoints on volumes as well as the additional cells array.

convert(cells, cell_type, order=0, calc_points=False, calc_midfaces=False, calc_midvolumes=False)#

Convert mesh to a given order (only order=0 and order=2 from order=1 are supported).

copy()#

Return a deepcopy of the mesh.

Returns:

A deepcopy of the mesh.

Return type:

Mesh

disconnect(points_per_cell=None, calc_points=True)#

Return a new instance of a Mesh with disconnected cells. Optionally, the points-per-cell may be specified (must be lower or equal the number of points- per-cell of the original Mesh). If the Mesh is to be used as a dual Mesh, then the point-coordinates do not have to be re-created because they are not used.

dual(cells, cell_type, points_per_cell=None, disconnect=True, calc_points=False, offset=0, npoints=None)#

Create a new dual mesh with given points per cell. The point coordinates are not used in a dual mesh and hence, by default they are all zero.

expand(cells, cell_type, n=11, z=1)#

Expand a 1d-Line to a 2d-Quad or a 2d-Quad to a 3d-Hexahedron Mesh.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • n (int, optional) – Number of n-point repetitions or (n-1)-cell repetitions, default is 11.

  • z (float or ndarray, optional) – Total expand dimension as float (edge length in expand direction is z / n), default is 1. Optionally, if an array is passed these entries are taken as expansion and n is ignored.

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (ndarray) – Modified point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

flip(cells, cell_type, mask=None)#

Ensure positive cell volumes for tria, tetra, quad and hexahedron cell types.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • mask (list or ndarray, optional) – Boolean mask for selected cells to flip.

Returns:

  • points (ndarray) – Point coordinates.

  • cells (ndarray) – Modified point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

mirror(cells, cell_type, normal=[1, 0, 0], centerpoint=[0, 0, 0], axis=None)#

Mirror points by plane normal and ensure positive cell volumes for tria, tetra, quad and hexahedron cell types.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • normal (list or ndarray, optional) – Mirror-plane normal vector (default is [1, 0, 0]).

  • centerpoint (list or ndarray, optional) – Center-point coordinates on the mirror plane (default is [0, 0, 0]).

  • axis (int or None, optional) – Mirror axis (default is None).

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (ndarray) – Modified point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

revolve(cells, cell_type, n=11, phi=180, axis=0)#

Revolve a 2d-Quad to a 3d-Hexahedron Mesh.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • n (int, optional) – Number of n-point revolutions (or (n-1) cell revolutions), default is 11.

  • phi (float or ndarray, optional) – Revolution angle in degree (default is 180).

  • axis (int, optional) – Revolution axis (default is 0).

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (list or ndarray) – Modified point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

rotate(cells, cell_type, angle_deg, axis, center=None)#

Rotate a Mesh.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • angle_deg (int) – Rotation angle in degree.

  • axis (int) – Rotation axis.

  • center (list or ndarray or None, optional) – Center point coordinates (default is None).

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

save(filename='mesh.vtk', **kwargs)#

Export the mesh as VTK file. For XDMF-export please ensure to have h5py (as an optional dependancy of meshio) installed.

Parameters:

filename (str, optional) – The filename of the mesh (default is mesh.vtk).

sweep(cells, cell_type, decimals=None)#

Sweep duplicated points and update cells of a Mesh.

WARNING: This function sorts points.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • decimals (int or None, optional) – Number of decimals for point coordinate comparison (default is None).

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (list or ndarray) – Modified point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

translate(cells, cell_type, move, axis)#

Translate (move) a Mesh.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • move (float) – Translation along given axis.

  • axis (int) – Translation axis.

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

triangulate(cells, cell_type, mode=3)#

Triangulate a quad or a hex mesh.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • mode (int, optional) – Choose a mode how to convert hexahedrons to tets [1] (default is 3).

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (ndarray) – Modified point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

References

[1] Dompierre, J., Labbé, P., Vallet, M. G., & Camarero, R. (1999). How to Subdivide Pyramids, Prisms, and Hexahedra into Tetrahedra. IMR, 99, 195.

update(cells, cell_type=None)#

Update the cell and dimension attributes with a given cell array.

class felupe.mesh.RectangleArbitraryOrderQuad(a=(0, 0), b=(1, 1), order=2)[source]#
add_midpoints_edges(cells, cell_type)#

“Add midpoints on edges for given points and cells and update cell_type accordingly.

add_midpoints_faces(cells, cell_type)#

“Add midpoints on faces for given points and cells and update cell_type accordingly.

add_midpoints_volumes(cells, cell_type)#

“Add midpoints on volumes for given points and cells and update cell_type accordingly.

add_runouts(cells, cell_type, values=[0.1, 0.1], centerpoint=[0, 0, 0], axis=0, exponent=5, mask=slice(None, None, None))#

Add simple rubber-runouts for realistic rubber-metal structures.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • values (list or ndarray, optional) – Relative amount of runouts (per coordinate) perpendicular to the axis (default is 10% per coordinate, i.e. [0.1, 0.1]).

  • centerpoint (list or ndarray, optional) – Center-point coordinates (default is [0, 0, 0]).

  • axis (int or None, optional) – Axis (default is 0).

  • exponent (int, optional) – Positive exponent to control the shape of the runout. The higher the exponent, the steeper the transition (default is 5).

  • mask (list or None, optional) – List of points to be considered (default is None).

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (ndarray) – Modified point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

as_meshio(**kwargs)#

Export the mesh as meshio.Mesh.

collect_edges(cells, cell_type)#

“Collect all unique edges, calculate and return midpoints on edges as well as the additional cells array.

collect_faces(cells, cell_type)#

“Collect all unique faces, calculate and return midpoints on faces as well as the additional cells array.

collect_volumes(cells, cell_type)#

“Collect all volumes, calculate and return midpoints on volumes as well as the additional cells array.

convert(cells, cell_type, order=0, calc_points=False, calc_midfaces=False, calc_midvolumes=False)#

Convert mesh to a given order (only order=0 and order=2 from order=1 are supported).

copy()#

Return a deepcopy of the mesh.

Returns:

A deepcopy of the mesh.

Return type:

Mesh

disconnect(points_per_cell=None, calc_points=True)#

Return a new instance of a Mesh with disconnected cells. Optionally, the points-per-cell may be specified (must be lower or equal the number of points- per-cell of the original Mesh). If the Mesh is to be used as a dual Mesh, then the point-coordinates do not have to be re-created because they are not used.

dual(cells, cell_type, points_per_cell=None, disconnect=True, calc_points=False, offset=0, npoints=None)#

Create a new dual mesh with given points per cell. The point coordinates are not used in a dual mesh and hence, by default they are all zero.

expand(cells, cell_type, n=11, z=1)#

Expand a 1d-Line to a 2d-Quad or a 2d-Quad to a 3d-Hexahedron Mesh.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • n (int, optional) – Number of n-point repetitions or (n-1)-cell repetitions, default is 11.

  • z (float or ndarray, optional) – Total expand dimension as float (edge length in expand direction is z / n), default is 1. Optionally, if an array is passed these entries are taken as expansion and n is ignored.

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (ndarray) – Modified point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

flip(cells, cell_type, mask=None)#

Ensure positive cell volumes for tria, tetra, quad and hexahedron cell types.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • mask (list or ndarray, optional) – Boolean mask for selected cells to flip.

Returns:

  • points (ndarray) – Point coordinates.

  • cells (ndarray) – Modified point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

mirror(cells, cell_type, normal=[1, 0, 0], centerpoint=[0, 0, 0], axis=None)#

Mirror points by plane normal and ensure positive cell volumes for tria, tetra, quad and hexahedron cell types.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • normal (list or ndarray, optional) – Mirror-plane normal vector (default is [1, 0, 0]).

  • centerpoint (list or ndarray, optional) – Center-point coordinates on the mirror plane (default is [0, 0, 0]).

  • axis (int or None, optional) – Mirror axis (default is None).

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (ndarray) – Modified point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

revolve(cells, cell_type, n=11, phi=180, axis=0)#

Revolve a 2d-Quad to a 3d-Hexahedron Mesh.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • n (int, optional) – Number of n-point revolutions (or (n-1) cell revolutions), default is 11.

  • phi (float or ndarray, optional) – Revolution angle in degree (default is 180).

  • axis (int, optional) – Revolution axis (default is 0).

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (list or ndarray) – Modified point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

rotate(cells, cell_type, angle_deg, axis, center=None)#

Rotate a Mesh.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • angle_deg (int) – Rotation angle in degree.

  • axis (int) – Rotation axis.

  • center (list or ndarray or None, optional) – Center point coordinates (default is None).

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

save(filename='mesh.vtk', **kwargs)#

Export the mesh as VTK file. For XDMF-export please ensure to have h5py (as an optional dependancy of meshio) installed.

Parameters:

filename (str, optional) – The filename of the mesh (default is mesh.vtk).

sweep(cells, cell_type, decimals=None)#

Sweep duplicated points and update cells of a Mesh.

WARNING: This function sorts points.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • decimals (int or None, optional) – Number of decimals for point coordinate comparison (default is None).

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (list or ndarray) – Modified point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

translate(cells, cell_type, move, axis)#

Translate (move) a Mesh.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • move (float) – Translation along given axis.

  • axis (int) – Translation axis.

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

triangulate(cells, cell_type, mode=3)#

Triangulate a quad or a hex mesh.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • mode (int, optional) – Choose a mode how to convert hexahedrons to tets [1] (default is 3).

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (ndarray) – Modified point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

References

[1] Dompierre, J., Labbé, P., Vallet, M. G., & Camarero, R. (1999). How to Subdivide Pyramids, Prisms, and Hexahedra into Tetrahedra. IMR, 99, 195.

update(cells, cell_type=None)#

Update the cell and dimension attributes with a given cell array.

class felupe.mesh.CubeArbitraryOrderHexahedron(a=(0, 0, 0), b=(1, 1, 1), order=2)[source]#
add_midpoints_edges(cells, cell_type)#

“Add midpoints on edges for given points and cells and update cell_type accordingly.

add_midpoints_faces(cells, cell_type)#

“Add midpoints on faces for given points and cells and update cell_type accordingly.

add_midpoints_volumes(cells, cell_type)#

“Add midpoints on volumes for given points and cells and update cell_type accordingly.

add_runouts(cells, cell_type, values=[0.1, 0.1], centerpoint=[0, 0, 0], axis=0, exponent=5, mask=slice(None, None, None))#

Add simple rubber-runouts for realistic rubber-metal structures.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • values (list or ndarray, optional) – Relative amount of runouts (per coordinate) perpendicular to the axis (default is 10% per coordinate, i.e. [0.1, 0.1]).

  • centerpoint (list or ndarray, optional) – Center-point coordinates (default is [0, 0, 0]).

  • axis (int or None, optional) – Axis (default is 0).

  • exponent (int, optional) – Positive exponent to control the shape of the runout. The higher the exponent, the steeper the transition (default is 5).

  • mask (list or None, optional) – List of points to be considered (default is None).

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (ndarray) – Modified point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

as_meshio(**kwargs)#

Export the mesh as meshio.Mesh.

collect_edges(cells, cell_type)#

“Collect all unique edges, calculate and return midpoints on edges as well as the additional cells array.

collect_faces(cells, cell_type)#

“Collect all unique faces, calculate and return midpoints on faces as well as the additional cells array.

collect_volumes(cells, cell_type)#

“Collect all volumes, calculate and return midpoints on volumes as well as the additional cells array.

convert(cells, cell_type, order=0, calc_points=False, calc_midfaces=False, calc_midvolumes=False)#

Convert mesh to a given order (only order=0 and order=2 from order=1 are supported).

copy()#

Return a deepcopy of the mesh.

Returns:

A deepcopy of the mesh.

Return type:

Mesh

disconnect(points_per_cell=None, calc_points=True)#

Return a new instance of a Mesh with disconnected cells. Optionally, the points-per-cell may be specified (must be lower or equal the number of points- per-cell of the original Mesh). If the Mesh is to be used as a dual Mesh, then the point-coordinates do not have to be re-created because they are not used.

dual(cells, cell_type, points_per_cell=None, disconnect=True, calc_points=False, offset=0, npoints=None)#

Create a new dual mesh with given points per cell. The point coordinates are not used in a dual mesh and hence, by default they are all zero.

expand(cells, cell_type, n=11, z=1)#

Expand a 1d-Line to a 2d-Quad or a 2d-Quad to a 3d-Hexahedron Mesh.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • n (int, optional) – Number of n-point repetitions or (n-1)-cell repetitions, default is 11.

  • z (float or ndarray, optional) – Total expand dimension as float (edge length in expand direction is z / n), default is 1. Optionally, if an array is passed these entries are taken as expansion and n is ignored.

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (ndarray) – Modified point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

flip(cells, cell_type, mask=None)#

Ensure positive cell volumes for tria, tetra, quad and hexahedron cell types.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • mask (list or ndarray, optional) – Boolean mask for selected cells to flip.

Returns:

  • points (ndarray) – Point coordinates.

  • cells (ndarray) – Modified point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

mirror(cells, cell_type, normal=[1, 0, 0], centerpoint=[0, 0, 0], axis=None)#

Mirror points by plane normal and ensure positive cell volumes for tria, tetra, quad and hexahedron cell types.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • normal (list or ndarray, optional) – Mirror-plane normal vector (default is [1, 0, 0]).

  • centerpoint (list or ndarray, optional) – Center-point coordinates on the mirror plane (default is [0, 0, 0]).

  • axis (int or None, optional) – Mirror axis (default is None).

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (ndarray) – Modified point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

revolve(cells, cell_type, n=11, phi=180, axis=0)#

Revolve a 2d-Quad to a 3d-Hexahedron Mesh.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • n (int, optional) – Number of n-point revolutions (or (n-1) cell revolutions), default is 11.

  • phi (float or ndarray, optional) – Revolution angle in degree (default is 180).

  • axis (int, optional) – Revolution axis (default is 0).

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (list or ndarray) – Modified point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

rotate(cells, cell_type, angle_deg, axis, center=None)#

Rotate a Mesh.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • angle_deg (int) – Rotation angle in degree.

  • axis (int) – Rotation axis.

  • center (list or ndarray or None, optional) – Center point coordinates (default is None).

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

save(filename='mesh.vtk', **kwargs)#

Export the mesh as VTK file. For XDMF-export please ensure to have h5py (as an optional dependancy of meshio) installed.

Parameters:

filename (str, optional) – The filename of the mesh (default is mesh.vtk).

sweep(cells, cell_type, decimals=None)#

Sweep duplicated points and update cells of a Mesh.

WARNING: This function sorts points.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • decimals (int or None, optional) – Number of decimals for point coordinate comparison (default is None).

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (list or ndarray) – Modified point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

translate(cells, cell_type, move, axis)#

Translate (move) a Mesh.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • move (float) – Translation along given axis.

  • axis (int) – Translation axis.

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

triangulate(cells, cell_type, mode=3)#

Triangulate a quad or a hex mesh.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • mode (int, optional) – Choose a mode how to convert hexahedrons to tets [1] (default is 3).

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (ndarray) – Modified point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

References

[1] Dompierre, J., Labbé, P., Vallet, M. G., & Camarero, R. (1999). How to Subdivide Pyramids, Prisms, and Hexahedra into Tetrahedra. IMR, 99, 195.

update(cells, cell_type=None)#

Update the cell and dimension attributes with a given cell array.

felupe.mesh.add_midpoints_edges(points, cells, cell_type)[source]#

“Add midpoints on edges for given points and cells and update cell_type accordingly.

felupe.mesh.add_midpoints_faces(points, cells, cell_type)[source]#

“Add midpoints on faces for given points and cells and update cell_type accordingly.

felupe.mesh.add_midpoints_volumes(points, cells, cell_type)[source]#

“Add midpoints on volumes for given points and cells and update cell_type accordingly.

felupe.mesh.collect_edges(points, cells, cell_type)[source]#

“Collect all unique edges, calculate and return midpoints on edges as well as the additional cells array.

felupe.mesh.collect_faces(points, cells, cell_type)[source]#

“Collect all unique faces, calculate and return midpoints on faces as well as the additional cells array.

felupe.mesh.collect_volumes(points, cells, cell_type)[source]#

“Collect all volumes, calculate and return midpoints on volumes as well as the additional cells array.

felupe.mesh.concatenate(meshes)[source]#

Join a sequence of meshes with identical cell types.

felupe.mesh.convert(points, cells, cell_type, order=0, calc_points=False, calc_midfaces=False, calc_midvolumes=False)[source]#

Convert mesh to a given order (only order=0 and order=2 from order=1 are supported).

felupe.mesh.expand(points, cells, cell_type, n=11, z=1)[source]#

Expand a 1d-Line to a 2d-Quad or a 2d-Quad to a 3d-Hexahedron Mesh.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • n (int, optional) – Number of n-point repetitions or (n-1)-cell repetitions, default is 11.

  • z (float or ndarray, optional) – Total expand dimension as float (edge length in expand direction is z / n), default is 1. Optionally, if an array is passed these entries are taken as expansion and n is ignored.

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (ndarray) – Modified point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

felupe.mesh.mirror(points, cells, cell_type, normal=[1, 0, 0], centerpoint=[0, 0, 0], axis=None)[source]#

Mirror points by plane normal and ensure positive cell volumes for tria, tetra, quad and hexahedron cell types.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • normal (list or ndarray, optional) – Mirror-plane normal vector (default is [1, 0, 0]).

  • centerpoint (list or ndarray, optional) – Center-point coordinates on the mirror plane (default is [0, 0, 0]).

  • axis (int or None, optional) – Mirror axis (default is None).

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (ndarray) – Modified point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

felupe.mesh.revolve(points, cells, cell_type, n=11, phi=180, axis=0)[source]#

Revolve a 2d-Quad to a 3d-Hexahedron Mesh.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • n (int, optional) – Number of n-point revolutions (or (n-1) cell revolutions), default is 11.

  • phi (float or ndarray, optional) – Revolution angle in degree (default is 180).

  • axis (int, optional) – Revolution axis (default is 0).

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (list or ndarray) – Modified point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

felupe.mesh.rotate(points, cells, cell_type, angle_deg, axis, center=None)[source]#

Rotate a Mesh.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • angle_deg (int) – Rotation angle in degree.

  • axis (int) – Rotation axis.

  • center (list or ndarray or None, optional) – Center point coordinates (default is None).

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

felupe.mesh.runouts(points, cells, cell_type, values=[0.1, 0.1], centerpoint=[0, 0, 0], axis=0, exponent=5, mask=slice(None, None, None))[source]#

Add simple rubber-runouts for realistic rubber-metal structures.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • values (list or ndarray, optional) – Relative amount of runouts (per coordinate) perpendicular to the axis (default is 10% per coordinate, i.e. [0.1, 0.1]).

  • centerpoint (list or ndarray, optional) – Center-point coordinates (default is [0, 0, 0]).

  • axis (int or None, optional) – Axis (default is 0).

  • exponent (int, optional) – Positive exponent to control the shape of the runout. The higher the exponent, the steeper the transition (default is 5).

  • mask (list or None, optional) – List of points to be considered (default is None).

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (ndarray) – Modified point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

felupe.mesh.sweep(points, cells, cell_type, decimals=None)[source]#

Sweep duplicated points and update cells of a Mesh.

WARNING: This function sorts points.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • decimals (int or None, optional) – Number of decimals for point coordinate comparison (default is None).

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (list or ndarray) – Modified point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

felupe.mesh.triangulate(points, cells, cell_type, mode=3)[source]#

Triangulate a quad or a hex mesh.

Parameters:
  • points (list or ndarray) – Original point coordinates.

  • cells (list or ndarray) – Original point-connectivity of cells.

  • cell_type (str) – A string in VTK-convention that specifies the cell type.

  • mode (int, optional) – Choose a mode how to convert hexahedrons to tets [1] (default is 3).

Returns:

  • points (ndarray) – Modified point coordinates.

  • cells (ndarray) – Modified point-connectivity of cells.

  • cell_type (str or None) – A string in VTK-convention that specifies the cell type.

References

[1] Dompierre, J., Labbé, P., Vallet, M. G., & Camarero, R. (1999). How to Subdivide Pyramids, Prisms, and Hexahedra into Tetrahedra. IMR, 99, 195.