8.19.1 Mesh class: A mesh is a discrete geometrical model consisting of nodes and elements.

In the Mesh geometrical data model, coordinates of all points are gathered in a single twodimensional array 'coords' with shape (ncoords,3) and the individual geometrical elements are described by indices into the 'coords' array. This model has some advantages over the Formex data model, where all points of all element are stored by their coordinates: - compacter storage, because coordinates of coinciding points do not need to be repeated, - faster connectivity related algorithms. The downside is that geometry generating algorithms are far more complex and possibly slower.

In pyFormex we therefore mostly use the Formex data model when creating geometry, but when we come to the point of exporting the geometry to file (and to other programs), a Mesh data model may be more adequate.

The Mesh data model has at least the following attributes: coords: (ncoords,3) shaped Coords array, elems: (nelems,nplex) shaped array of int32 indices into coords. All values should be in the range 0 <= value < ncoords. prop: array of element property numbers, default None. eltype: string designing the element type, default None.

The Mesh class has this constructor:

class Mesh( coords=None,elems=None,prop=None,eltype=None)
Create a new Mesh from the specified data.

data is either a tuple of (coords,elems) arrays, or an object having a 'toMesh()' method, which should return such a tuple.

Mesh objects have the following methods:

copy( )
Return a copy using the same data arrays

toFormex( )
Convert a Mesh to a Formex.

The Formex inherits the element property numbers and eltype from the Mesh. Node property numbers however can not be translated to the Formex data model.

data( )
Return the mesh data as a tuple (coords,elems)

nelems( )

nplex( )

ncoords( )

shape( )

report( )

compact( )
Renumber the mesh and remove unconnected nodes.

extrude( n,step=1.,dir=0,autofix=True)
Extrude a Mesh in one of the axes directions.

Returns a new Mesh obtained by extruding the given Mesh over n steps of length step in direction of axis dir. The returned Mesh has double plexitude of the original.

This function is usually used to extrude points into lines, lines into surfaces and surfaces into volumes. By default it will try to fix the connectivity ordering where appropriate. If autofix is switched off, the connectivities are merely stacked, and the user may have to fix it himself.

Currently, this function correctly transforms: point1 to line2, line2 to quad4, tri3 to wedge6, quad4 to hex8.

sweep( path,eltype=None)
Sweep a mesh along a path, creating an extrusion

convert( fromtype,totype)
Convert a mesh from element type fromtype to type totype.

Currently defined conversions: 'quad4' -> 'tri3'

concatenate( clas,ML)
Concatenate a list of meshes of the same plexitude and eltype This is a class method, not an instance method.