# 7. `mesh` — Finite element meshes in pyFormex.

This module defines the Mesh class, which can be used to describe discrete geometrical models like those used in Finite Element models. It also contains some useful functions to create such models.

class `mesh.``Mesh`(coords=None, elems=None, prop=None, eltype=None)

  A Mesh is a discrete geometrical model defined by nodes and elements.

  In the Mesh geometrical data model, the coordinates of all the points are gathered in a single twodimensional array with shape (ncoords,3). The individual geometrical elements are then described by indices into this coordinates array.

  This model has some advantages over the Formex data model (which stores all the points of all the elements by their coordinates):

  - a more compact storage, because coordinates of coinciding points are not repeated,
  - faster connectivity related algorithms.

  The downside is that geometry generating and replicating algorithms are often 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 needing connectivity related algorithms or exporting the geometry to file (and to other programs), a Mesh data model may be more adequate.

  Parameters: | coords (`Coords` or other object.) – Usually, a 2-dim Coords object holding the coordinates of all the nodes used in the Mesh geometry. See details below for different initialization methods. elems (`Connectivity` (nelems,nplex)) – A Connectivity object, defining the elements of the geometry by indices into the `coords` Coords array. All values in elems should be in the range 0 <= value < ncoords. prop (int array-like, optional) – 1-dim int array with non-negative element property numbers. If provided, `setProp()` will be called to assign the specified properties. eltype (str or `ElementType`, optional) – The element type of the geometric entities (elements). This is only needed if the element type has not yet been set in the `elems` Connectivity. See below.

  A Mesh object can be initialized in many different ways, depending on the values passed for the `coords` and `elems` arguments.

  - Coords, Connectivity: This is the most obvious case: `coords` is a 2-dim `Coords` object holding the coordinates of all the nodes in the Mesh, and `elems` is a `Connectivity` object describing the geometric elements by indices into the `coords`.
  - Coords, : If A Coords is passed as first argument, but no `elems`, the result is a Mesh of points, with plexitude 1. The Connectivity will be constructed automatically.
  - object with `toMesh`, : As a convenience, if another object is provided that has a `toMesh` method and `elems` is not provided, the result of the `toMesh` method will be used to initialize both `coords` and `elems`.
  - None: If neither `coords` nor `elems` are specified, but `eltype` is, a unit sized single element Mesh of the specified ElementType is created.
  - Specifying no parameters at all creates an empty Mesh, without any data.

  Setting the element type can also be done in different ways. If `elems` is a Connectivity, it will normally already have a element type. If not, it can be done by passing it in the `eltype` parameter. In case you pass a simple array or list in the `elems` parameter, an element type is required. Finally, the user can specify an eltype to override the one in the Connectivity. It should howver match the plexitude of the connectivity data.

  `eltype` should be one of the `ElementType` subclasses or the element name of such a subclass. If required but not provided, the pyFormex default is used, which is based on the plexitude: 1 = point, 2 = line segment, 3 = triangle, 4 or more is a polygon.

  A properly initialized Mesh has the following attributes:

  `coords`

    A 2-dim Coords object holding the coordinates of all the nodes used to describe the Mesh geometry.

    Type: | `Coords` (ncoords,3)

  `elems`

    A Connectivity object, defining the elements of the geometry by indices into the `coords` Coords array. All values in elems should be in the range 0 <= value < ncoords.

    The Connectivity also stores the element type of the Mesh.

    Type: | `Connectivity` (nelems,nplex)

  `prop`

    Element property numbers. See `geometry.Geometry.prop`.

    Type: | int array, optional

  `attrib`

    An Attributes object. See `geometry.Geometry.attrib`.

    Type: | `Attributes`

  `fields`

    The Fields defined on the Mesh. See `geometry.Geometry.fields`.

    Type: | OrderedDict

  Note

  The coords` attribute of a Mesh can hold points that are not used or needed to describe the Geometry. They do not influence the result of Mesh operations, but only use up some memory. If their number becomes large, you may want to free up that memory by calling the `compact()` method. Also, before exporting a Mesh (e.g. to a numerical simulation program), you may want to compact the Mesh first.

  Examples

  Create a Mesh with four points and two triangle elements of type ‘tri3’.

      >>> coords = Coords('0123')
      >>> elems = [[0,1,2], [0,2,3]]
      >>> M = Mesh(coords,elems,eltype='tri3')
      >>> print(M.report())
      Mesh: nnodes: 4, nelems: 2, nplex: 3, level: 2, eltype: tri3
        BBox: [ 0.  0.  0.], [ 1.  1.  0.]    Size: [ 1.  1.  0.]
        Coords: [[ 0.  0.  0.]
                 [ 1.  0.  0.]
                 [ 1.  1.  0.]
                 [ 0.  1.  0.]]
        Elems: [[0 1 2]
                [0 2 3]]

  `setType`(eltype=None)

    Set the eltype from a character string.

    Parameters: | eltype (str or `ElementType`, optional) – The element type to be set in the `elems` Connectivity. allows the user to change the element type of the Mesh. (This) – input is a character string with the name of one of the element (The) – in elements.py. The function will only allow to set a type (defined) – the plexitude of the Mesh. (matching) – method is seldom needed, because the applications should (This) – set the element type at Mesh/Connectivity creation time. (normally) –

  `elType`()

    Return the element type of the Mesh.

  `elName`()

    Return the element name of the Mesh.

  `setNormals`(normals=None)

    Set/Remove the normals of the mesh.

    For rendering purposes, it is possible to store a set of normals inside the Mesh object. If the user has better values than the automatically generated ones, this can be used to override them.

  `__getitem__`(i)

    Return element i of the Mesh.

    This allows addressing element i of Mesh M as M[i]. The return value is an array with the coordinates of all the points of the element. M[i][j] then will return the coordinates of node j of element i. This also allows to change the individual coordinates or nodes, by an assignment like M[i][j] = [1.,0.,0.].

  `shallowCopy`(prop=None)

    Return a shallow copy.

    A shallow copy of a Mesh is a Mesh object using the same data arrays as the original Mesh. The only thing that can be changed is the property array. This is a convenient method to use the same Mesh with different property attributes.

  `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.

  `toMesh`()

    Convert to a Mesh.

    This just returns the Mesh object itself. It is provided as a convenience for use in functions that want work on different Geometry types.

  `toSurface`()

    Convert a Mesh to a TriSurface.

    Only Meshes of level 2 (surface) and 3 (volume) can be converted to a TriSurface. For a level 3 Mesh, the border Mesh is taken first. A level 2 Mesh is converted to element type ‘tri3’ and then to a TriSurface. The resulting TriSurface is only fully equivalent with the input Mesh if the latter has element type ‘tri3’.

    On success, returns a TriSurface corresponding with the input Mesh. If the Mesh can not be converted to a TriSurface, an error is raised.

  `toCurve`(connect=False)

    Convert a Mesh to a Curve.

    If the element type is one of ‘line*’ types, the Mesh is converted to a Curve. The type of the returned Curve is dependent on the element type of the Mesh:

    - ‘line2’: PolyLine,
    - ‘line3’: BezierSpline (degree 2),
    - ‘line4’: BezierSpline (degree 3)

    If connect is False, this is equivalent with

        self.toFormex().toCurve()

    Any other type will raise an exception.

  `level`()

    Return the level of the elements in the Mesh

    Returns the dimensionality of the elements: 0 (point), 1(line), 2 (surface), 3 (volume).

  `nelems`()

    Return the number of elements in the Mesh

  `nplex`()

    Return the plexitude of the elements in the Mesh

  `ncoords`()

    Return the number of nodes in the Mesh

  `nnodes`()

    Return the number of nodes in the Mesh

  `npoints`()

    Return the number of nodes in the Mesh

  `nedges`()

    Return the number of edges.

    This returns the number of rows that would be in getEdges(), without actually constructing the edges. The edges are not fused!

  `info`()

    Return short info about the Mesh.

    This includes only the shape of the coords and elems arrays.

  `report`(full=True)

    Create a report on the Mesh shape and size.

    The report always contains the number of nodes, number of elements, plexitude, dimensionality, element type, bbox and size. If full==True(default), it also contains the nodal coordinate list and element connectivity table. Because the latter can be rather bulky, they can be switched off. (Though numpy will limit the printed output).

    TODO: We should add an option here to let numpy print the full tables.

  `centroids`()

    Return the centroids of all elements of the Mesh.

    The centroid of an element is the point whose coordinates are the mean values of all points of the element. The return value is a Coords object with nelems points.

  `bboxes`()

    Returns the bboxes of all elements in the Mesh.

    Returns a coords with shape (nelems,2,3). Along the axis 1 are stored the minimal and maximal values of the Coords in each of the elements of the Mesh.

  `getElems`()

    Get the elems data.

    Returns the element connectivity data as stored in the object.

  `getLowerEntities`(level=-1, unique=False)

    Get the entities of a lower dimensionality.

    If the element type is defined in the `elements` module, this returns a Connectivity table with the entities of a lower dimensionality. The full list of entities with increasing dimensionality 0,1,2,3 is:

        ['points', 'edges', 'faces', 'cells' ]

    If level is negative, the dimensionality returned is relative to that of the caller. If it is positive, it is taken absolute. Thus, for a Mesh with a 3D element type, getLowerEntities(-1) returns the faces, while for a 2D element type, it returns the edges. For both meshes however, getLowerEntities(+1) returns the edges.

    By default, all entities for all elements are returned and common entities will appear multiple times. Specifying unique=True will return only the unique ones.

    The return value may be an empty table, if the element type does not have the requested entities (e.g. the ‘point’ type). If the eltype is not defined, or the requested entity level is outside the range 0..3, the return value is None.

  `getNodes`()

    Return the set of unique node numbers in the Mesh.

    This returns only the node numbers that are effectively used in the connectivity table. For a compacted Mesh, it is equivalent to `arange(self.nelems)`. This function also stores the result internally so that future requests can return it without the need for computing it again.

  `getPoints`()

    Return the nodal coordinates of the Mesh.

    This returns only those points that are effectively used in the connectivity table. For a compacted Mesh, it is equal to the coords attribute.

  `getEdges`()

    Return the unique edges of all the elements in the Mesh.

    This is a convenient function to create a table with the element edges. It is equivalent to `self.getLowerEntities(1,unique=True)`, but this also stores the result internally so that future requests can return it without the need for computing it again.

  `getFaces`()

    Return the unique faces of all the elements in the Mesh.

    This is a convenient function to create a table with the element faces. It is equivalent to `self.getLowerEntities(2,unique=True)`, but this also stores the result internally so that future requests can return it without the need for computing it again.

  `getCells`()

    Return the cells of the elements.

    This is a convenient function to create a table with the element cells. It is equivalent to `self.getLowerEntities(3,unique=True)`, but this also stores the result internally so that future requests can return it without the need for computing it again.

  `edgeMesh`()

    Return a Mesh with the unique edges of the elements.

    This can only be used with a Mesh of level >= 1.

  `faceMesh`()

    Return a Mesh with the unique faces of the elements.

    This can only be used with a Mesh of level >= 2.

  `getElemEdges`()

    Defines the elements in function of its edges.

    This returns a Connectivity table with the elements defined in function of the edges. It returns the equivalent of `self.elems.insertLevel(self.elType().getEntities(1))` but as a side effect it also stores the definition of the edges and the returned element to edge connectivity in the attributes edges, resp. elem_edges.

  `getFreeEntities`(level=-1, return_indices=False)

    Return the border of the Mesh.

    Returns a Connectivity table with the free entities of the specified level of the Mesh. Free entities are entities that are only connected to a single element.

    If return_indices==True, also returns an (nentities,2) index for inverse lookup of the higher entity (column 0) and its local lower entity number (column 1).

  `getFreeEntitiesMesh`(level=-1, compact=True)

    Return a Mesh with lower entities.

    Returns a Mesh representing the lower entities of the specified level. If the Mesh has property numbers, the lower entities inherit the property of the element to which they belong.

    By default, the resulting Mesh is compacted. Compaction can be switched off by setting compact=False.

  `getBorder`(return_indices=False)

    Return the border of the Mesh.

    This returns a Connectivity table with the border of the Mesh. The border entities are of a lower hierarchical level than the mesh itself. These entities become part of the border if they are connected to only one element.

    If return_indices==True, it returns also an (nborder,2) index for inverse lookup of the higher entity (column 0) and its local border part number (column 1).

    This is a convenient shorthand for

        self.getFreeEntities(level=-1,return_indices=return_indices)

  `getBorderMesh`(compact=True)

    Return a Mesh with the border elements.

    The returned Mesh is of the next lower hierarchical level and contains all the free entitites of that level. If the Mesh has property numbers, the border elements inherit the property of the element to which they belong.

    By default, the resulting Mesh is compacted. Compaction can be switched off by setting compact=False.

    This is a convenient shorthand for

        self.getFreeEntitiesMesh(level=-1,compact=compact)

  `borderMesh`(compact=True)

    Return a Mesh with the border elements.

    The returned Mesh is of the next lower hierarchical level and contains all the free entitites of that level. If the Mesh has property numbers, the border elements inherit the property of the element to which they belong.

    By default, the resulting Mesh is compacted. Compaction can be switched off by setting compact=False.

    This is a convenient shorthand for

        self.getFreeEntitiesMesh(level=-1,compact=compact)

  `getBorderElems`()

    Return the elements that are on the border of the Mesh.

    This returns a list with the numbers of the elements that are on the border of the Mesh. Elements are considered to be at the border if they contain at least one complete element of the border Mesh (i.e. an element of the first lower hierarchical level). Thus, in a volume Mesh, elements only touching the border by a vertex or an edge are not considered border elements.

  `getBorderNodes`()

    Return the nodes that are on the border of the Mesh.

    This returns a list with the numbers of the nodes that are on the border of the Mesh.

  `peel`(nodal=False)

    Return a Mesh with the border elements removed.

    If nodal is True all elements connected to a border node are removed. If nodal is False, it is a convenient shorthand for

        self.cselect(self.getBorderElems())

  `getFreeEdgesMesh`(compact=True)

    Return a Mesh with the free edge elements.

    The returned Mesh is of the hierarchical level 1 (no mather what the level of the parent Mesh is) and contains all the free entitites of that level. If the Mesh has property numbers, the border elements inherit the property of the element to which they belong.

    By default, the resulting Mesh is compacted. Compaction can be switched off by setting compact=False.

    This is a convenient shorthand for

        self.getFreeEntitiesMesh(level=1,compact=compact)

  `connectedTo`(**_kargs)

    Select the elements connected to specific lower entities.

    entities: int or array_like, int. Entity selector. level: int. Entity level. Default 0 (nodes).

    Returns a list of the numbers of the elements that contain at least one of the specified lower entities.

  `adjacentTo`(elements, level=0)

    Select the elements adjacent to the specified elements.

    elements: int or array_like, int. Element selector. level: int. Entity level used to define adjacency. Default 0 (nodes).

    Returns a list of all the elements in the Mesh adjacent to any of the specified elements. The adjacency is defined over nodes, edges or faces, depending on the level.

  `reachableFrom`(elements, level=0)

    Select the elements reachable from the specified elements.

    - elements: int or array_like, int. Element selector.
    - level: int. Specify how elements can be reached: via node (0), edge (1) or face (2).

    Returns a list of all the elements in the Mesh reachable from any of the specified elements by walking over entities of the specified level. The list will include the original set of elements.

  `adjacency`(level=0, diflevel=-1)

    Create an element adjacency table.

    Two elements are said to be adjacent if they share a lower entity of the specified level. The level is one of the lower entities of the mesh.

    Parameters:

    - level: hierarchy of the geometric items connecting two elements: 0 = node, 1 = edge, 2 = face. Only values of a lower hierarchy than the elements of the Mesh itself make sense.
    - diflevel: if >= level, and smaller than the hierarchy of self.elems, elements that have a connection of this level are removed. Thus, in a Mesh with volume elements, self.adjacency(0,1) gives the adjacency of elements by a node but not by an edge.

    Returns an Adjacency with integers specifying for each element its neighbours connected by the specified geometrical subitems.

  `frontWalk`(level=0, startat=0, frontinc=1, partinc=1, maxval=-1, optim_mem=False)

    Visit all elements using a frontal walk.

    In a frontal walk a forward step is executed simultanuously from all the elements in the current front. The elements thus reached become the new front. An element can be reached from the current element if both are connected by a lower entity of the specified level. Default level is ‘point’.

    Parameters:

    - level: hierarchy of the geometric items connecting two elements: 0 = node, 1 = edge, 2 = face. Only values of a lower hierarchy than the elements of the Mesh itself make sense. There are no connections on the upper level.

    The remainder of the parameters are like in `adjacency.Adjacency.frontWalk()`.

    Returns an array of integers specifying for each element in which step the element was reached by the walker.

  `maskedEdgeFrontWalk`(mask=None, startat=0, frontinc=1, partinc=1, maxval=-1)

    Perform a front walk over masked edge connections.

    This is like frontWalk(level=1), but allows to specify a mask to select the edges that are used as connectors between elements.

    Parameters:

    - mask: Either None or a boolean array or index flagging the nodes which are to be considered connectors between elements. If None, all nodes are considered connections.

    The remainder of the parameters are like in `adjacency.Adjacency.frontWalk()`.

  `partitionByConnection`(level=0, startat=0, sort='number', nparts=-1)

    Detect the connected parts of a Mesh.

    Parameters:

    - sort: str. Weighted sorting method. It can assume values ‘number’ (default), ‘length’, ‘area’, ‘volume’.
    - nparts: is the equivalent of parameter maxval in `frontWalk()`. Maximum frontal value. If negative (default) the walk will continue until all elements have been reached. If non-negative, walking will stop as soon as the frontal value reaches this maximum.

    The remainder of the parameters are like in `frontWalk()`.

    The Mesh is partitioned in parts in which all elements are connected. Two elements are connected if it is possible to draw a continuous (poly)line from a point in one element to a point in the other element without leaving the Mesh. The partitioning is returned as a integer array having a value for each element corresponding to the part number it belongs to.

    By default the parts are sorted in decreasing order of the number of elements. If you specify nparts, you may wish to switch off the sorting by specifying sort=’‘.

  `splitByConnection`(level=0, startat=0, sort='number')

    Split the Mesh into connected parts.

    The parameters level and startat are like in `frontWalk()`. The parameter sort is like in `partitionByConnection()`.

    Returns a list of Meshes that each form a connected part. By default the parts are sorted in decreasing order of the number of elements.

  `largestByConnection`(level=0)

    Return the largest connected part of the Mesh.

    This is equivalent with, but more efficient than

        self.splitByConnection(level)[0]

  `growSelection`(sel, mode='node', nsteps=1)

    Grow a selection of a surface.

    p is a single element number or a list of numbers. The return value is a list of element numbers obtained by growing the front nsteps times. The mode argument specifies how a single frontal step is done:

    - ‘node’ : include all elements that have a node in common,
    - ‘edge’ : include all elements that have an edge in common.
  `partitionByAngle`(**kargs)

    Partition a level-2 Mesh by the angle between adjacent elements.

    The Mesh is partitioned in parts bounded by the sharp edges in the surface. The arguments and return value are the same as in `trisurface.TriSurface.partitionByAngle()`.

    For eltypes other than ‘tri3’, a conversion to ‘tri3’ is done before computing the partitions.

  `nodeConnections`()

    Find and store the elems connected to nodes.

  `nNodeConnected`()

    Find the number of elems connected to nodes.

  `edgeConnections`()

    Find and store the elems connected to edges.

  `nEdgeConnected`()

    Find the number of elems connected to edges.

  `nodeAdjacency`()

    Find the elems adjacent to each elem via one or more nodes.

  `nNodeAdjacent`()

    Find the number of elems which are adjacent by node to each elem.

  `edgeAdjacency`()

    Find the elems adjacent to elems via an edge.

  `nEdgeAdjacent`()

    Find the number of adjacent elems.

  `nonManifoldNodes`()

    Return the non-manifold nodes of a Mesh.

    Non-manifold nodes are nodes where subparts of a mesh of level >= 2 are connected by a node but not by an edge.

    Returns an integer array with a sorted list of non-manifold node numbers. Possibly empty (always if the dimensionality of the Mesh is lower than 2).

  `nonManifoldEdges`()

    Return the non-manifold edges of a Mesh.

    Non-manifold edges are edges where subparts of a mesh of level 3 are connected by an edge but not by an face.

    Returns an integer array with a sorted list of non-manifold edge numbers. Possibly empty (always if the dimensionality of the Mesh is lower than 3).

    As a side effect, this constructs the list of edges in the object. The definition of the nonManifold edges in terms of the nodes can thus be got from

        self.edges[self.nonManifoldEdges()]

  `nonManifoldEdgeNodes`()

    Return the non-manifold edge nodes of a Mesh.

    Non-manifold edges are edges where subparts of a mesh of level 3 are connected by an edge but not by an face.

    Returns an integer array with a sorted list of numbers of nodes on the non-manifold edges. Possibly empty (always if the dimensionality of the Mesh is lower than 3).

  `fuse`(parts=None, nodes=None, **kargs)

    Fuse the nodes of a Meshes.

    Nodes that are within the tolerance limits of each other are merged into a single node.

    Parameters:

    - parts: int array-like with length equal to number of elements. If specified, it will be used to split the Mesh into parts (see `splitProp()`) and do the fuse operation per part. Elements for which the value of nparts is negative will not be involved in the fuse operations.
    - nodes: int array-like: a list of node numbers. If specified, only these nodes will be involved in the fuse operation. This option can not be used together with the parts option.
    - Extra arguments for tuning the fuse operation are passed to the `coords.Coords:fuse()` method.
  `matchCoords`(coords, **kargs)

    Match nodes of coords with nodes of self.

    coords can be a Coords or a Mesh object This is a convenience function equivalent to

        self.coords.match(mesh.coords,**kargs)

    or

        self.coords.match(coords,**kargs)

    See also `coords.Coords.match()`

  `matchCentroids`(mesh, **kargs)

    Match elems of Mesh with elems of self.

    self and Mesh are same eltype meshes and are both without duplicates.

    Elems are matched by their centroids.

  `compact`(return_index=False)

    Remove unconnected nodes and renumber the mesh.

    Returns a mesh where all nodes that are not used in any element have been removed, and the nodes are renumbered to a compacter scheme.

    If return_index is True, also returns an index specifying the index of the new nodes in the old node scheme.

    Examples

        >>> x = Coords([[i] for i in arange(5)])
        >>> M = Mesh(x,[[0,2],[1,4],[4,2]])
        >>> M,ind = M.compact(True)
        >>> print(M.coords)
        [[ 0. 0. 0.]
         [ 1. 0. 0.]
         [ 2. 0. 0.]
         [ 4. 0. 0.]]
        >>> print(M.elems)
        [[0 2]
         [1 3]
         [3 2]]
        >>> M = Mesh(x,[[0,2],[1,3],[3,2]])
        >>> M = M.compact()
        >>> print(M.coords)
        [[ 0. 0. 0.]
         [ 1. 0. 0.]
         [ 2. 0. 0.]
         [ 3. 0. 0.]]
        >>> print(M.elems)
        [[0 2]
         [1 3]
         [3 2]]
        >>> print(ind)
        [0 1 2 4]
        >>> M = M.cselect([0,1,2])
        >>> M.coords.shape, M.elems.shape
        ((4, 3), (0, 2))
        >>> M = M.compact()
        >>> M.coords.shape, M.elems.shape
        ((0, 3), (0, 2))

  `avgNodes`(nodsel, wts=None)

    Create average nodes from the existing nodes of a mesh.

    nodsel is a local node selector as in `selectNodes()` Returns the (weighted) average coordinates of the points in the selector as (nelems*nnod,3) array of coordinates, where nnod is the length of the node selector. wts is a 1-D array of weights to be attributed to the points. Its length should be equal to that of nodsel.

  `meanNodes`(nodsel)

    Create nodes from the existing nodes of a mesh.

    nodsel is a local node selector as in `selectNodes()` Returns the mean coordinates of the points in the selector as (nelems*nnod,3) array of coordinates, where nnod is the length of the node selector.

  `addNodes`(newcoords, eltype=None)

    Add new nodes to elements.

    newcoords is an (nelems,nnod,3) or`(nelems*nnod,3)` array of coordinates. Each element gets exactly nnod extra nodes from this array. The result is a Mesh with plexitude self.nplex() + nnod.

  `addMeanNodes`(nodsel, eltype=None)

    Add new nodes to elements by averaging existing ones.

    nodsel is a local node selector as in `selectNodes()` Returns a Mesh where the mean coordinates of the points in the selector are added to each element, thus increasing the plexitude by the length of the items in the selector. The new element type should be set to correct value.

  `selectNodes`(nodsel, eltype=None)

    Return a mesh with subsets of the original nodes.

    nodsel is an object that can be converted to a 1-dim or 2-dim array. Examples are a tuple of local node numbers, or a list of such tuples all having the same length. Each row of nodsel holds a list of local node numbers that should be retained in the new connectivity table.

  `hits`(entities, level)

    Count the lower entities from a list connected to the elements.

    entities: a single number or a list/array of entities level: 0 or 1 or 2 if entities are nodes or edges or faces, respectively.

    The numbering of the entities corresponds to self.insertLevel(level). Returns an (nelems,) shaped int array with the number of the entities from the list that are contained in each of the elements. This method can be used in selector expressions like:

        self.select(self.hits(entities,level) > 0)

  `splitRandom`(n, compact=True)

    Split a Mesh in n parts, distributing the elements randomly.

    Returns a list of n Mesh objects, constituting together the same Mesh as the original. The elements are randomly distributed over the subMeshes.

    By default, the Meshes are compacted. Compaction may be switched off for efficiency reasons.

  `reverse`(sel=None)

    Return a Mesh where the elements have been reversed.

    Reversing an element has the following meaning:

    - for 1D elements: reverse the traversal direction,
    - for 2D elements: reverse the direction of the positive normal,
    - for 3D elements: reverse inside and outside directions of the element’s border surface. This also changes the sign of the elementt’s volume.

    The `reflect()` method by default calls this method to undo the element reversal caused by the reflection operation.

    Parameters:

    -sel: a selector (index or True/False array)

  `reflect`(dir=0, pos=0.0, reverse=True, **kargs)

    Reflect the coordinates in one of the coordinate directions.

    Parameters:

    - dir: int: direction of the reflection (default 0)
    - pos: float: offset of the mirror plane from origin (default 0.0)
    - reverse: boolean: if True, the `reverse()` method is called after the reflection to undo the element reversal caused by the reflection of its coordinates. This will in most cases have the desired effect. If not however, the user can set this to False to skip the element reversal.
  `convert`(totype, fuse=False, verbose=False)

    Convert a Mesh to another element type.

    Converting a Mesh from one element type to another can only be done if both element types are of the same dimensionality. Thus, 3D elements can only be converted to 3D elements.

    The conversion is done by splitting the elements in smaller parts and/or by adding new nodes to the elements.

    Not all conversions between elements of the same dimensionality are possible. The possible conversion strategies are implemented in a table. New strategies may be added however.

    The return value is a Mesh of the requested element type, representing the same geometry (possibly approximatively) as the original mesh.

    If the requested conversion is not implemented, an error is raised.

    Warning

    Conversion strategies that add new nodes may produce double nodes at the common border of elements. The `fuse()` method can be used to merge such coincident nodes. Specifying fuse=True will also enforce the fusing. This option become the default in future.

  `convertRandom`(choices)

    Convert choosing randomly between choices

    Returns a Mesh obtained by converting the current Mesh by a randomly selected method from the available conversion type for the current element type.

  `subdivide`(*ndiv, **kargs)

    Subdivide the elements of a Mesh.

    Parameters:

    - ndiv: specifies the number (and place) of divisions (seeds) along the edges of the elements. Accepted type and value depend on the element type of the Mesh. Currently implemented:
      - ‘tri3’: ndiv is a single int value specifying the number of divisions (of equal size) for each edge.
      - ‘quad4’: ndiv is a sequence of two int values nx,ny, specifying the number of divisions along the first, resp. second parametric direction of the element
      - ‘hex8’: ndiv is a sequence of three int values nx,ny,nz specifying the number of divisions along the first, resp. second and the third parametric direction of the element
    - fuse: bool, if True (default), the resulting Mesh is completely fused. If False, the Mesh is only fused over each individual element of the original Mesh.

    Returns a Mesh where each element is replaced by a number of smaller elements of the same type.

    Note

    This is currently only implemented for Meshes of type ‘tri3’ and ‘quad4’ and ‘hex8’ and for the derived class ‘TriSurface’.

  `splitDegenerate`(reduce=True, return_indices=False)

    Split a Mesh in non-degenerate and degenerate elements.

    Splits a Mesh in non-degenerate elements and degenerate elements, and tries to reduce degenerate elements to lower plexitude elements.

    Parameters: | reduce (bool or `ElementType` name) – If True, the degenerate elements will be tested against known degeneration patterns, and the matching elements will be transformed to non-degenerate elements of a lower plexitude. If a string, it is an element name and only transforms to this element type will be considered. If False, no reduction of the degenerate elements will be attempted. return_indices (bool, optional) – If True, also returns the element indices in the original Mesh for all of the elements in the derived Meshes.
    Returns: | ML (list of Mesh objects) – The list of Meshes resulting from the split operation. The first holds the non-degenerate elements of the original Mesh. The last holds the remaining degenerate elements. The intermediate Meshes, if any, hold elements of a lower plexitude than the original.

    Warning

    The Meshes that hold reduced elements may still contain degenerate elements for the new element type

    Examples

        >>> M = Mesh(np.zeros((4,3)),
        ...     [[0,0,0,0],
        ...      [0,0,0,1],
        ...      [0,0,1,2],
        ...      [0,1,2,3],
        ...      [1,2,3,3],
        ...      [2,3,3,3],
        ...     ],eltype='quad4')
        >>> M.elems.listDegenerate()
        array([0, 1, 2, 4, 5])
        >>> for Mi in M.splitDegenerate(): print(Mi)
        Mesh: nnodes: 4, nelems: 1, nplex: 4, level: 2, eltype: quad4
          BBox: [ 0.  0.  0.], [ 0.  0.  0.]    Size: [ 0.  0.  0.]
        Mesh: nnodes: 4, nelems: 5, nplex: 3, level: 2, eltype: tri3
          BBox: [ 0.  0.  0.], [ 0.  0.  0.]    Size: [ 0.  0.  0.]
        >>> conn,ind = M.splitDegenerate(return_indices=True)
        >>> print(ind[0],ind[1])
        [3] [0 1 2 5 4]
        >>> print(conn[1].elems)
        [[0 0 0]
         [0 0 1]
         [0 1 2]
         [2 3 3]
         [1 2 3]]

  `removeDegenerate`(eltype=None)

    Remove the degenerate elements from a Mesh.

    Returns a Mesh with all degenerate elements removed.

  `removeDuplicate`(permutations='all')

    Remove the duplicate elements from a Mesh.

    Duplicate elements are elements that consist of the same nodes, by default in no particular order. Setting permutations=False will only consider elements with the same nodes in the same order as duplicates.

    Returns a Mesh with all duplicate elements removed.

  `renumber`(order='elems')

    Renumber the nodes of a Mesh in the specified order.

    order is an index with length equal to the number of nodes. The index specifies the node number that should come at this position. Thus, the order values are the old node numbers on the new node number positions.

    order can also be a predefined value that will generate the node index automatically:

    - ‘elems’: the nodes are number in order of their appearance in the Mesh connectivity.
    - ‘random’: the nodes are numbered randomly.
    - ‘front’: the nodes are numbered in order of their frontwalk.
  `reorder`(order='nodes')

    Reorder the elements of a Mesh.

    Parameters:

    - order: either a 1-D integer array with a permutation of `arange(self.nelems())`, specifying the requested order, or one of the following predefined strings:
      - ‘nodes’: order the elements in increasing node number order.
      - ‘random’: number the elements in a random order.
      - ‘reverse’: number the elements in reverse order.

    Returns a Mesh equivalent with self but with the elements ordered as specified.

  `connectedElements`(startat, mask, level=0)

    Return the elements reachable from startat.

    Finds the elements which can be reached from startat by walking along a mask (a subset of elements). Walking is possible over nodes, edges or faces, as specified in level.

    - startat: int or array_like, int.
    - level: int. Specify how elements can be reached: via node (0), edge (1) or face (2).
    - mask: a boolean array or index flagging the elements which are to be considered walkable.
  `connect`(coordslist, div=1, degree=1, loop=False, eltype=None)

    Connect a sequence of toplogically congruent Meshes into a hypermesh.

    Parameters:

    - coordslist: either a list of Coords objects, or a list of Mesh objects or a single Mesh object.

      If Mesh objects are given, they should (all) have the same element type as self. Their connectivity tables will not be used though. They will only serve to construct a list of Coords objects by taking the coords attribute of each of the Meshes. If only a single Mesh was specified, self.coords will be added as the first Coords object in the list.

      All Coords objects in the coordslist (either specified or constructed from the Mesh objects), should have the exact same shape as self.coords. The number of Coords items in the list should be a multiple of degree, plus 1.

      Each of the Coords in the final coordslist is combined with the connectivity table, element type and property numbers of self to produce a list of toplogically congruent meshes. The return value is the hypermesh obtained by connecting each consecutive slice of (degree+1) of these meshes. The hypermesh has a dimensionality that is one higher than the original Mesh (i.e. points become lines, lines become surfaces, surfaces become volumes). The resulting elements will be of the given degree in the direction of the connection.

      Notice that unless a single Mesh was specified as coordslist, the coords of self are not used. In many cases however self or self.coords will be one of the items in the specified coordslist.

    - degree: degree of the connection. Currently only degree 1 and 2 are supported.

      - If degree is 1, every Coords from the coordslist is connected with hyperelements of a linear degree in the connection direction.

      - If degree is 2, quadratic hyperelements are created from one Coords item and the next two in the list. Note that all Coords items should contain the same number of nodes, even for higher order elements where the intermediate planes contain less nodes.

        Currently, degree=2 is not allowed when coordslist is specified as a single Mesh.

    - loop: if True, the connections with loop around the list and connect back to the first. This is accomplished by adding the first Coords item back at the end of the list.

    - div: This should only be used for degree==1.

      With this parameter the generated connections can be further subdivided along the connection direction. div is either a single input for the `smartSeed()` function, or a list thereof. In the latter case, the length of the list should be one less than the length of the coordslist. Each pair of consecutive items from the coordinate list will be connected using the seeds generated by the corresponding value from div, passed to `smartSeed()` with start=1 parameter. Notice that if seed values are specified directly as a list of floats, the list should not contain the first value (0.0), while the final value should be 1.0.

    - eltype: the element type of the constructed hypermesh. Normally, this is set automatically from the base element type and the connection degree. If a different element type is specified, a final conversion to the requested element type is attempted.

  `extrude`(div, dir=0, length=1.0, degree=1, eltype=None)

    Extrude a Mesh along a straight line.

    The Mesh is extruded over a given length in the given direction.

    Parameters: | div (smartseed) – Specifies how the extruded direction will be subdivided in elements. It can be anything that is acceptable as input for the `smartSeed()` function. dir (int (0,1,2) or float array-like (3,)) – The direction of the extrusion: either a global axis number or a direction vector. length (float) – The length of the extrusion, measured along the direction `dir`.
    Returns: | Mesh – A Mesh obtained by extruding the input Mesh over the given `length` in direction `dir`, subdividing this length according to the seeds generated by `smartSeed(div)`.

    Examples

        >>> M = Mesh(Formex(origin())).extrude(3,0,3)
        >>> print(M)
        Mesh: nnodes: 4, nelems: 3, nplex: 2, level: 1, eltype: line2
          BBox: [ 0.  0.  0.], [ 3.  0.  0.]    Size: [ 3.  0.  0.]

  `revolve`(n, axis=0, angle=360.0, around=None, loop=False, eltype=None)

    Revolve a Mesh around an axis.

    Returns a new Mesh obtained by revolving the given Mesh over an angle around an axis in n steps, while extruding the mesh from one step to the next. This extrudes points into lines, lines into surfaces and surfaces into volumes.

  `sweep`(path, eltype=None, **kargs)

    Sweep a mesh along a path, creating an extrusion

    Parameters:

    - path: Curve object. The path over which to sweep the Mesh.
    - eltype: string. Name of the element type on the returned Meshes.
    - **kargs: keyword arguments that are passed to `curve.Curve.sweep2()`, with the same meaning. Usually, you will need to at least set the normal parameter.

    Returns a Mesh obtained by sweeping the given Mesh over a path. The returned Mesh has double plexitude of the original. If path is a closed Curve connect back to the first.

    This operation is similar to the extrude() method, but the path can be any 3D curve.

  `smooth`(iterations=1, lamb=0.5, k=0.1, edg=True, exclnod=[], exclelem=[], weight=None)

    Return a smoothed mesh.

    Smoothing algorithm based on lowpass filters.

    If edg is True, the algorithm tries to smooth the outer border of the mesh seperately to reduce mesh shrinkage.

    Higher values of k can reduce shrinkage even more (up to a point where the mesh expands), but will result in less smoothing per iteration.

    - exclnod: It contains a list of node indices to exclude from the smoothing. If exclnod is ‘border’, all nodes on the border of the mesh will be unchanged, and the smoothing will only act inside. If exclnod is ‘inner’, only the nodes on the border of the mesh will take part to the smoothing.
    - exclelem: It contains a list of elements to exclude from the smoothing. The nodes of these elements will not take part to the smoothing. If exclnod and exclelem are used at the same time the union of them will be exluded from smoothing.
    -weight : it is a string that can assume 2 values inversedistance and
      distance. It allows to specify the weight of the adjancent points according to their distance to the point
  classmethod `concatenate`(meshes, fuse=True, **kargs)

    Concatenate a list of meshes of the same plexitude and eltype

    All Meshes in the list should have the same plexitude. Meshes with plexitude are ignored though, to allow empty Meshes to be added in.

    Merging of the nodes can be tuned by specifying extra arguments that will be passed to `coords.Coords:fuse()`.

    If any of the meshes has property numbers, the resulting mesh will inherit the properties. In that case, any meshes without properties will be assigned property 0. If all meshes are without properties, so will be the result.

    This is a class method, and should be invoked as follows:

        Mesh.concatenate([mesh0,mesh1,mesh2])

  `test`(nodes='all', dir=0, min=None, max=None, atol=0.0)

    Flag elements having nodal coordinates between min and max.

    This function is very convenient in clipping a Mesh in a specified direction. It returns a 1D integer array flagging (with a value 1 or True) the elements having nodal coordinates in the required range. Use where(result) to get a list of element numbers passing the test. Or directly use clip() or cclip() to create the clipped Mesh

    The test plane can be defined in two ways, depending on the value of dir. If dir == 0, 1 or 2, it specifies a global axis and min and max are the minimum and maximum values for the coordinates along that axis. Default is the 0 (or x) direction.

    Else, dir should be compaitble with a (3,) shaped array and specifies the direction of the normal on the planes. In this case, min and max are points and should also evaluate to (3,) shaped arrays.

    nodes specifies which nodes are taken into account in the comparisons. It should be one of the following:

    - a single (integer) point number (< the number of points in the Formex)
    - a list of point numbers
    - one of the special strings: ‘all’, ‘any’, ‘none’

    The default (‘all’) will flag all the elements that have all their nodes between the planes x=min and x=max, i.e. the elements that fall completely between these planes. One of the two clipping planes may be left unspecified.

  `clipAtPlane`(p, n, nodes='any', side='+')

    Return the Mesh clipped at plane (p,n).

    This is a convenience function returning the part of the Mesh at one side of the plane (p,n)

  `intersectionWithLines`(approximated=True, **kargs)

    Return the intersections of a level-2 Mesh with lines.

    The Mesh is intersected with lines. The arguments and return values are the same as in `trisurface.TriSurface.intersectionWithLines()`, except for the approximated.

    For a Mesh with eltype ‘tri3’, the intersections are exact. For other eltypes, if approximated is True a conversion to ‘tri3’ is done before computing the intersections. This may produce an exact result, an approximate result or no result (if the conversion fails). Of course the user can create his own approximation to a ‘tri3’ surface first, before calling this method.

  `levelVolumes`()

    Return the level volumes of all elements in a Mesh.

    The level volume of an element is defined as:

    - the length of the element if the Mesh is of level 1,
    - the area of the element if the Mesh is of level 2,
    - the (signed) volume of the element if the Mesh is of level 3.

    The level volumes can be computed directly for Meshes of eltypes ‘line2’, ‘tri3’ and ‘tet4’ and will produce accurate results. All other Mesh types are converted to one of these before computing the level volumes. Conversion may result in approximation of the results. If conversion can not be performed, None is returned.

    If succesful, returns an (nelems,) float array with the level volumes of the elements. Returns None if the Mesh level is 0, or the conversion to the level’s base element was unsuccesful.

    Note that for level-3 Meshes, negative volumes will be returned for elements having a reversed node ordering.

  `lengths`()

    Return the length of all elements in a level-1 Mesh.

    For a Mesh with eltype ‘line2’, the lengths are exact. For other eltypes, a conversion to ‘line2’ is done before computing the lengths. This may produce an exact result, an approximated result or no result (if the conversion fails).

    If succesful, returns an (nelems,) float array with the lengths. Returns None if the Mesh level is not 1, or the conversion to ‘line2’ does not succeed.

  `areas`()

    Return the area of all elements in a level-2 Mesh.

    For a Mesh with eltype ‘tri3’, the areas are exact. For other eltypes, a conversion to ‘tri3’ is done before computing the areas. This may produce an exact result, an approximate result or no result (if the conversion fails).

    If succesful, returns an (nelems,) float array with the areas. Returns None if the Mesh level is not 2, or the conversion to ‘tri3’ does not succeed.

  `volumes`()

    Return the signed volume of all the mesh elements

    For a ‘tet4’ tetraeder Mesh, the volume of the elements is calculated as 1/3 * surface of base * height.

    For other Mesh types the volumes are calculated by first splitting the elements into tetraeder elements.

    The return value is an array of float values with length equal to the number of elements. If the Mesh conversion to tetraeder does not succeed, the return value is None.

  `length`()

    Return the total length of a Mesh.

    Returns the sum of self.lengths(), or 0.0 if the self.lengths() returned None.

  `area`()

    Return the total area of a Mesh.

    Returns the sum of self.areas(), or 0.0 if the self.areas() returned None.

  `volume`()

    Return the total volume of a Mesh.

    For a Mesh of level < 3, a value 0.0 is returned. For a Mesh of level 3, the volume is computed by converting its border to a surface and taking the volume inside that surface. It is equivalent with

        self.toSurface().volume()

    This is far more efficient than self.volumes().sum().

  `fixVolumes`()

    Reverse the elements with negative volume.

    Elements with negative volume may result from incorrect local node numbering. This method will reverse all elements in a Mesh of dimensionality 3, provide the volumes of these elements can be computed.

## 7.1. Functions defined in module mesh

`mesh.``mergeNodes`(nodes, fuse=True, **kargs)

  Merge all the nodes of a list of node sets.

  Merging the nodes creates a single Coords object containing all nodes, and the indices to find the points of the original node sets in the merged set.

  Parameters:

  - nodes: a list of Coords objects, all having the same shape, except possibly for their first dimension
  - fuse: if True (default), coincident (or very close) points will be fused to a single point
  - **kargs: keyword arguments that are passed to the fuse operation

  Returns:

  - a Coords with the coordinates of all (unique) nodes,
  - a list of indices translating the old node numbers to the new. These numbers refer to the serialized Coords.

  The merging operation can be tuned by specifying extra arguments that will be passed to `coords.Coords.fuse()`.

`mesh.``mergeMeshes`(meshes, fuse=True, **kargs)

  Merge all the nodes of a list of Meshes.

  Each item in meshes is a Mesh instance. The return value is a tuple with:

  - the coordinates of all unique nodes,
  - a list of elems corresponding to the input list, but with numbers referring to the new coordinates.

  The merging operation can be tuned by specifying extra arguments that will be passed to `coords.Coords:fuse()`. Setting fuse=False will merely concatenate all the mesh.coords, but not fuse them.

`mesh.``unitAttractor`(x, e0=0.0, e1=0.0)

  Moves values in the range 0..1 closer to or away from the limits.

  - x: a list or array with values in the range 0.0 to 1.0.
  - e0, e1: attractor parameters for the start, resp. the end of the range. A value larger than zero will attract the points closer to the corresponding endpoint, while a negative value will repulse them. If two positive values are given, the middle part of the interval will become sparsely populated.

  Example:

      >>> set_printoptions(precision=4)
      >>> print(unitAttractor([0.,0.25,0.5,0.75,1.0],2.))
      [ 0.     0.0039 0.0625 0.3164 1.    ]
      >>> set_printoptions(precision=2)

`mesh.``seed`(n, e0=0.0, e1=0.0)

  Create a list of seed values.

  A seed list is a list of float values in the range 0.0 to 1.0. It can be used to subdivide a line segment or to seed nodes along lines for meshing purposes.

  This function divides the unit interval in n parts, resulting in n+1 seed values. While the intervals are by default of equal length, the e0 and e1 can be used to create unevenly spaced seed values.

  Parameters:

  - n: positive integer: the number of elements (yielding n+1 parameter values).
  - e0, e1: attractor parameters for the start, resp. the end of the range. A value larger than zero will attract the points closer to the corresponding endpoint, while a negative value will repulse them. If two positive values are given, the middle part of the interval will become sparsely populated.

  Returns a list of n+1 float values in the range 0.0 to 1.0. The values are in ascending order, starting with 0.0 and ending with 1.0.

  See also :func: seed1 for an analogue function with attractor at one end and equidistant points at the other.

  See also :func: smartSeed for an analogue function accepting a variety of input.

  Example:

      >>> set_printoptions(precision=4)
      >>> print(seed(5,2.,2.))
      [ 0.     0.0639 0.3362 0.6638 0.9361 1.    ]
      >>> set_printoptions(precision=2)

`mesh.``seed1`(n, nuni=0, e0=0.0)

  Create a list of seed values.

  A seed list is a list of float values in the range 0.0 to 1.0. It can be used to subdivide a line segment or to seed nodes along lines for meshing purposes.

  This function divides the unit interval in n parts, resulting in n+1 seed values. While the intervals are by default of equal length, the nuni and e0 can be used to create unevenly spaced seed values.

  Parameters:

  - n: positive integer: the number of elements (yielding n+1 parameter values).
  - nuni: 0..n-1: number of intervals at the end of the range that will have equal length. If n < 2, this funnction is equivalent with seed(n,e0,0.0).
  - e0 : float: attractor for the start of the range. A value larger than zero will attract the points closer to the startpoint, while a negative value will repulse them.

  Returns a list of n+1 float values in the range 0.0 to 1.0. The values are in ascending order, starting with 0.0 and ending with 1.0.

  See also :func: seed for an analogue function with attractors at both ends of the range.

  Example:

      >>> set_printoptions(precision=4)
      >>> S = seed1(5,0,1.)
      >>> print(S)
      [ 0.   0.04 0.16 0.36 0.64 1.  ]
      >>> print(S[1:]-S[:-1])
      [ 0.04 0.12 0.2  0.28 0.36]
      >>> S = seed1(5,2,1.)
      >>> print(S)
      [ 0.     0.0435 0.1739 0.3913 0.6957 1.    ]
      >>> print(S[1:]-S[:-1])
      [ 0.0435 0.1304 0.2174 0.3043 0.3043]
      >>> set_printoptions(precision=2)

`mesh.``smartSeed`(n, start=0)

  Create a list of seed values.

  Like the `seed()` function, this function creates a list of float values in the range 0.0 to 1.0. It accepts however a variety of inputs, making it the prefered choice when it is not known in advance how the user wants to control the seeds: automatically created or self specified.

  Parameters:

  - n: can be one of the following:
    - a positive integer: returns seed(n),
    - a tuple (n,), (n,e0) or (n,e0,e1): returns seed(*n),
    - a list or array of floats: returns the input parameter as is.
  - start: 0 or 1: The default (0) makes the full list created by seed() to be returned. If 1, the first value (0.0) is omitted: this can be useful when creating seeds over multiple adjacent intervals.

  Example:

      >>> set_printoptions(precision=4)
      >>> print(smartSeed(5))
      [ 0.  0.2 0.4 0.6 0.8 1. ]
      >>> print(smartSeed((5,2.,1.)))
      [ 0.     0.01   0.1092 0.3701 0.7504 1.    ]
      >>> print(smartSeed([0.0,0.2,0.3,0.4,0.8,1.0]))
      [ 0.  0.2  0.3  0.4  0.8  1. ]
      >>> set_printoptions(precision=2)

`mesh.``gridpoints`(seed0, seed1=None, seed2=None)

  Create weights for 1D, 2D or 3D element coordinates.

  Parameters:

  - ‘seed0’ : int or list of floats . It specifies divisions along the first parametric direction of the element
  - ‘seed1’ : int or list of floats . It specifies divisions along the second parametric direction of the element
  - ‘seed2’ : int or list of floats . It specifies divisions along the third parametric direction of the element

  If these parameters are integer values the divisions will be equally spaced between 0 and 1.

  Examples

`mesh.``line2_wts`(seed0)

  Create weights for line2 subdivision.

  Parameters:

  - ‘seed0’ : int or list of floats . It specifies divisions along the first parametric direction of the element

  If these parametes are integer values the divisions will be equally spaced between 0 and 1

`mesh.``quad4_wts`(seed0, seed1)

  Create weights for quad4 subdivision.

  Parameters:

  - ‘seed0’ : int or list of floats . It specifies divisions along the first parametric direction of the element
  - ‘seed1’ : int or list of floats . It specifies divisions along the second parametric direction of the element

  If these parameters are integer values the divisions will be equally spaced between 0 and 1

  This is equivalent with gridpoints(seed0, seed1).

`mesh.``quad4_els`(nx, ny)

  Quad4 element connectivity for a regular stack of nx,ny elements.

  The node numbers vary first in the x, then in the y direction.

`mesh.``quad9_wts`(seed0, seed1)

  Create weights for quad4 subdivision.

  Parameters:

  - ‘seed0’ : int or list of floats . It specifies divisions along the first parametric direction of the element
  - ‘seed1’ : int or list of floats . It specifies divisions along the second parametric direction of the element

  If these parameters are integer values the divisions will be equally spaced between 0 and 1

  This is equivalent with gridpoints(seed0, seed1).

`mesh.``quad9_els`(nx, ny)

  Quad4 element connectivity for a regular stack of nx,ny elements.

  The node numbers vary first in the x, then in the y direction.

`mesh.``quadgrid`(seed0, seed1, roll=0)

  Create a quadrilateral mesh of unit size with the specified seeds.

  Parameters:

  - seed0,`seed1`: seeds for the elements along the parametric directions 0 and 1. Each can be one of the following:
    - an integer number, specifying the number of equally sized elements along that direction,
    - a tuple (n,) or (n,e0) or (n,e0,e1), to be used as parameters in the `mesh.seed()` function,
    - a list of monotonously increasing float values in the range 0.0 to 1.0, specifying the relative positions of the nodes. Normally, the first and last values of the seeds are 0. and 1., leading to a unit square grid.

  The node and element numbers vary first in the x, then in the y direction.

`mesh.``hex8_wts`(seed0, seed1, seed2)

  Create weights for hex8 subdivision.

  Parameters:

  - ‘seed0’ : int or list of floats . It specifies divisions along the first parametric direction of the element
  - ‘seed1’ : int or list of floats . It specifies divisions along the second parametric direction of the element
  - ‘seed2’ : int or list of floats . It specifies divisions along the t parametric direction of the element

  If these parametes are integer values the divisions will be equally spaced between 0 and 1

`mesh.``hex8_els`(nx, ny, nz)

  Create connectivity table for hex8 subdivision.

`mesh.``rectangle`(L, W, nl, nw)

  Create a plane rectangular mesh of quad4 elements.

  Parameters: - L,`W`: length,width of the rectangle.

`mesh.``rectangleWithHole`(L, W, r, nr, nl, nw=None, e0=0.0, eltype='quad4')

  Create a quarter of rectangle with a central circular hole.

  Parameters:

  - L: float. Length of the (quarter) rectangle
  - W: float. Width of the (quarter) rectangle
  - r: float. Radius of the hole
  - nr: integer. Number of elements over radial direction
  - nl: integer. Number of elements over tangential direction along L
  - nw: integer. Number of elements over tangential direction along W.
      If None (default), it will be set equal to nl.
  - e0: float. Concentration factor for elements in the radial direction

  Returns a Mesh

`mesh.``quadrilateral`(x, n1, n2)

  Create a quadrilateral mesh

  Parameters:

  - x: Coords(4,3): Four corners of the mesh, in anti-clockwise order.
  - n1: number of elements along sides x0-x1 and x2-x3
  - n2: number of elements along sides x1-x2 and x3-x4

  Returns a Mesh of quads filling the quadrilateral defined by the four points x.

`mesh.``continuousCurves`(c0, c1)

  Make sure the two curves are continuous.

  Ensures that the end point of curve c0 and the start point of curve c1 are coincident. This is done by replacing these two points with their mean value.

`mesh.``triangleQuadMesh`(P0, C0, n, P0wgt=1.0)

  Create a quad Mesh over a triangular region

  The triangle can have a single non-straight edge. The domain is described by a curve and a point. The straight lines between the curve ends and the point are the other two sides.

  Parameters:

  - P0: a point
  - C: a curve
  - ndiv: a tuple of 3 int’s. The quad kernel near the point will have n0*n1 elements (n0 to the start of the curve, n1 to the end. The zone near the curve has n0+n1 elements along the curve, and n2 elements perpendicular to the curve.

`mesh.``quarterCircle`(n1, n2)

  Create a mesh of quadrilaterals filling a quarter circle.

  Parameters:

  - n1: number of elements along sides x0-x1 and x2-x3
  - n2: number of elements along sides x1-x2 and x3-x4

  Returns a Mesh representing a quarter circle with radius 1 and center at the origin.

  The quarter circle mesh has a kernel of n1*n1 cells, and two border meshes of n1*n2 cells. The resulting mesh has n1+n2 cells in radial direction and 2*n1 cells in tangential direction (in the border mesh).