sfepy.mesh.mesh_tools module

sfepy.mesh.mesh_tools.elems_q2t(el)[source]
sfepy.mesh.mesh_tools.expand2d(mesh2d, dist, rep)[source]

Expand a 2D planar mesh into a 3D volume, convert triangular/quad elements to tetrahedrons/hexahedrons.

Parameters:
mesh2dMesh

The 2D mesh.

distfloat

The elements size in the 3rd direction.

repint

The number of elements in the 3rd direction.

Returns:
mesh3dMesh

The 3D mesh.

sfepy.mesh.mesh_tools.extract_edges(mesh, eps=1e-16)[source]

Extract outline edges of a given mesh. The outline edge is an edge for which norm(nvec_1 - nvec_2) < eps, where nvec_1 and nvec_2 are the normal vectors of the incident facets.

Parameters:
meshMesh

The 3D or 2D mesh.

epsfloat

The tolerance parameter of the outline edge searching algorithm.

Returns:
mesh_outtuple

The data of the outline mesh, Mesh.from_data() format, i.e. (coors, ngroups, ed_conns, mat_ids, descs).

sfepy.mesh.mesh_tools.extrude(mesh, cline, twist=None, scale=None, nvec=None, wedge_to_tetra=True)[source]

Create a solid 3D mesh from a given planar 2D mesh by extruding it. The new points in each layer lie in a plane perpendicular to one of the cline segments. Each layer can be twisted and scaled.

Parameters:
mesh: Mesh

2D planar FE mesh (tri or quad elements)

cline: list of coordinates

Points of central line.

twist: float, or array

Angle of twist in each layer.

scale: float, or array

Scale factor in each layer.

nvec: array

Normal vectors of layers.

wedge_to_tetra: bool

If True, convert wedge elements to tetrahedrons.

Returns:
out: Mesh

3D FE mesh

sfepy.mesh.mesh_tools.get_cell_vertices_only(mesh)[source]

Remove vertices not used in any cell.

Parameters:
mesh: Mesh

FE mesh

Returns:
out: Mesh

FE mesh

sfepy.mesh.mesh_tools.get_mesh_by_cgroup(mesh, value, cell_vertices_only=True)[source]

Extract mesh cells using cell_group value(s).

Parameters:
mesh: Mesh

FE mesh

value: int, list, or tuple

Select cells with a given value, list, or range: (value[0], value[1])

cell_vertices_only: bool

If True, remove free vertices

Returns:
out: Mesh

FE mesh

sfepy.mesh.mesh_tools.get_mesh_by_ngroup(mesh, value, cell_vertices_only=True)[source]

Extract mesh cells using cell_group value(s).

Parameters:
mesh: Mesh

FE mesh

value: int, list, or tuple

Select nodes with a given value, list, or range: (value[0], value[1])

cell_vertices_only: bool

If True, remove free vertices

Returns:
out: Mesh

FE mesh

sfepy.mesh.mesh_tools.get_surface_faces(domain)[source]
sfepy.mesh.mesh_tools.get_unique_coor_map(coors, eps=1e-18)[source]
sfepy.mesh.mesh_tools.merge_lines(mesh, eps=1e-18)[source]

Merge edges of an edge-only mesh that are in the same direction w.r.t. the tolerance eps.

sfepy.mesh.mesh_tools.merge_nodes(mesh, eps=1e-12)[source]

Merge duplicate mesh nodes.

Parameters:
mesh: Mesh

FE mesh.

eps: float

Tolerance for duplicity search.

Returns:
mesh: Mesh

FE mesh.

sfepy.mesh.mesh_tools.mirror(mesh, p, v)[source]

Duplicate the mesh by mirroring it. The mirror plane is defined by a point in the plane and by a normal vector to that plane.

Parameters:
mesh: Mesh

FE mesh.

p: list, tuple, or numpy.ndarray

Coordinates of a point at the mirror plane.

v: list, tuple, or numpy.ndarray

Normal vector of the mirror plane.

Returns:
out: Mesh

FE mesh.

sfepy.mesh.mesh_tools.revolve(mesh, nphi, p, v=(1, 0, 0), phi_max=None, wedge_to_tetra=True)[source]

Create a solid 3D mesh from a given planar 2D mesh by revolving it around the axis defined by a vector.

Parameters:
mesh: Mesh

2D planar FE mesh.

nphi: int

Number of elements in the circumferential direction

p: list, tuple, or numpy.ndarray

Coordinates of a point on the axis of rotation

v: list, tuple, or numpy.ndarray

Directional vector of the axis of rotation

phi_max: float or None

Angle of the revolution, if None, 360 degrees is used (closed loop)

wedge_to_tetra: bool

If True, convert wedge elements to tetrahedrons.

Returns:
out: Mesh

3D FE mesh.

sfepy.mesh.mesh_tools.smooth_mesh(mesh, n_iter=4, lam=0.6307, mu=-0.6347, weights=None, bconstr=True, volume_corr=False)[source]

FE mesh smoothing.

Based on:

[1] Steven K. Boyd, Ralph Muller, Smooth surface meshing for automated finite element model generation from 3D image data, Journal of Biomechanics, Volume 39, Issue 7, 2006, Pages 1287-1295, ISSN 0021-9290, 10.1016/j.jbiomech.2005.03.006. (http://www.sciencedirect.com/science/article/pii/S0021929005001442)

Parameters:
meshmesh

FE mesh.

n_iterinteger, optional

Number of iteration steps.

lamfloat, optional

Smoothing factor, see [1].

mufloat, optional

Unshrinking factor, see [1].

weightsarray, optional

Edge weights, see [1].

bconstr: logical, optional

Boundary constraints, if True only surface smoothing performed.

volume_corr: logical, optional

Correct volume after smoothing process.

Returns:
coorsarray

Coordinates of mesh nodes.

sfepy.mesh.mesh_tools.stack_descs(conns, mat_ids, descs)[source]
sfepy.mesh.mesh_tools.surface_components(gr_s, surf_faces)[source]

Determine surface components given surface mesh connectivity graph.

sfepy.mesh.mesh_tools.surface_graph(surf_faces, n_nod)[source]
sfepy.mesh.mesh_tools.triangulate(mesh, verbose=False)[source]

Triangulate a 2D or 3D tensor product mesh: quadrilaterals->triangles, hexahedrons->tetrahedrons.

Parameters:
meshMesh

The input mesh.

Returns:
meshMesh

The triangulated mesh.