scallop dome pyformex logo

Previous topic

12. elements — Definition of elements.

Next topic

14. widgets — A collection of custom widgets used in the pyFormex GUI

[FSF Associate Member]

Valid XHTML 1.0 Transitional

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

Classes defined in module mesh

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 the 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 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 object, holding the coordinates of all points in the Mesh;
  • elems: (nelems,nplex) shaped Connectivity object, defining the elements by indices into the Coords array. All values in elems should be in the range 0 <= value < ncoords.
  • prop: an array of element property numbers, default None.
  • eltype: an Element subclass or a string designing the element type, default None.

If eltype is None, the eltype of the elems Connectivity table is used, and if that is missing, a default eltype is derived from the plexitude, by a call to the elements.elementType function. In most cases the eltype can be set automatically. The user can override the default value, but an error will occur if the element type does not exist or does not match the plexitude.

A Mesh can be initialized by its attributes (coords,elems,prop,eltype) or by a single geometric object that provides a toMesh() method.

setType(eltype=None)

Set the eltype from a character string.

This function allows the user to change the element type of the Mesh. The input is a character string with the name of one of the element defined in elements.py. The function will only allow to set a type matching the plexitude of the Mesh.

This method is seldom needed, because the applications should normally set the element type at creation time.

setProp(prop=None)

Create or destroy the property array for the Mesh.

A property array is a rank-1 integer array with dimension equal to the number of elements in the Mesh. You can specify a single value or a list/array of integer values. If the number of passed values is less than the number of elements, they wil be repeated. If you give more, they will be ignored.

If a value None is given, the properties are removed from the Mesh.

getProp()

Return the properties as a numpy array (ndarray)

maxProp()

Return the highest property value used, or None

propSet()

Return a list with unique property values.

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.

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!

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.

getCoords()

Get the coords data.

Returns the full array of coordinates stored in the Mesh object. Note that this may contain points that are not used in the mesh. compact() will remove the unused points.

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

getElemEdges()

Defines the elements in function of its edges.

This returns a Connectivity table with the elements defined in function of the edges. It is equivalent to `self.elems.insertLevel(self.eltype.getEntities(1))` but it also stores the definition of the edges and the returned element to edge connectivity.

getFreeEntities(return_indices=False, level=-1)

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

The returned Connectivity can be used together with the Mesh.coords to construct a Mesh of the border geometry. See also getBorderMesh().

getFreeEntitiesMesh(compact=True, level=-1)

Return a Mesh with the border elements.

Returns a Mesh representing the border of the Mesh. The returned Mesh is of the next lower hierarchical 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.

reverse()

Return a Mesh where all 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

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

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

report()

Create a report on the Mesh shape and size.

The report contains the number of nodes, number of elements, plexitude, element type, bbox and size.

fuse(**kargs)

Fuse the nodes of a Meshes.

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

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

matchCoords(mesh, **kargs)

Match nodes of Mesh with nodes of self.

This is a convenience function equivalent to:

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

See also 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.

matchFaces(mesh)

Match faces of mesh with faces of self.

self and Mesh can be same eltype meshes or different eltype but of the same hierarchical type (i.e. hex8-quad4 or tet4 - tri3) and are both without duplicates.

Returns the indices array of the elems of self that matches the faces of mesh

compact()

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.

select(selected, compact=True)

Return a Mesh only holding the selected elements.

  • selected: an object that can be used as an index in the elems array, e.g. a list of (integer) element numbers, or a boolean array with the same length as the elems array.
  • compact: boolean. If True (default), the returned Mesh will be compacted, i.e. the unused nodes are removed and the nodes are renumbered from zero. If False, returns the node set and numbers unchanged.

Returns a Mesh (or subclass) with only the selected elements.

See cselect for the complementary operation.

cselect(selected, compact=True)

Return a mesh without the selected elements.

  • selected: an object that can be used as an index in the elems array, e.g. a list of (integer) element numbers, or a boolean array with the same length as the elems array.
  • compact: boolean. If True (default), the returned Mesh will be compacted, i.e. the unused nodes are removed and the nodes are renumbered from zero. If False, returns the node set and numbers unchanged.

Returns a Mesh with all but the selected elements.

This is the complimentary operation of select.

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.

withProp(val)

Return a Mesh which holds only the elements with property val.

val is either a single integer, or a list/array of integers. The return value is a Mesh holding all the elements that have the property val, resp. one of the values in val. The returned Mesh inherits the matching properties.

If the Mesh has no properties, a copy with all elements is returned.

withoutProp(val)

Return a Mesh without the elements with property val.

This is the complementary method of Mesh.withProp(). val is either a single integer, or a list/array of integers. The return value is a Mesh holding all the elements that do not have the property val, resp. one of the values in val. The returned Mesh inherits the matching properties.

If the Mesh has no properties, a copy with all elements is returned.

splitProp()

Partition a Mesh according to its propery values.

Returns a dict with the property values as keys and the corresponding partitions as values. Each value is a Mesh instance. It the Mesh has no props, an empty dict is returned.

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.

convert(totype, fuse=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

reduceDegenerate(eltype=None)

Reduce degenerate elements to lower plexitude elements.

This will try to reduce the degenerate elements of the mesh to elements of a lower plexitude. If a target element type is given, only the matching reduce scheme is tried. Else, all the target element types for which a reduce scheme from the Mesh eltype is available, will be tried.

The result is a list of Meshes of which the last one contains the elements that could not be reduced and may be empty. Property numbers propagate to the children.

splitDegenerate(autofix=True)

Split a Mesh in degenerate and non-degenerate elements.

If autofix is 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.

The return value is a list of Meshes. 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. These may still contain degenerate elements.

removeDegenerate(eltype=None)

Remove the degenerate elements from a Mesh.

Returns a Mesh with all degenerate elements removed.

removeDuplicate(permutations=True)

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.
renumberElems(order='nodes')

Renumber 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.
Returns:
A Mesh equivalent with self but with the elements ordered as specified.

See also: Connectivity.reorder()

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 instances, all having the same shape as self.coords, or a single Mesh instance whose coords attribute has the same shape.

    If it is a list of Coords, consider a list of Meshes obtained by combining each Coords object with the connectivity table, element type and property numbers of the current Mesh. The return value then 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 the coords of the current Mesh are not used, unless these coords are explicitely included into the specified coordslist. In many cases self.coords will be the first item in coordslist, but it could occur anywhere in the list or even not at all. The number of Coords items in the list should be a multiple of degree plus 1.

    Specifying a single Mesh instead of a list of Coords is just a convenience for the often occurring situation of connecting a Mesh (self) with another one (mesh) having the same connectivity: in this case the list of Coords will automatically be set to [ self.coords, mesh.coords ]. The degree should be 1 in this case.

  • 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.
  • 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: Either an integer, or a sequence of float numbers (usually in the range ]0.0..1.0]). With this parameter the generated elements can be further subdivided along the connection direction. If an int is given, the connected elements will be divided into this number of elements along the connection direction. If a sequence of float numbers is given, the numbers specify the relative distance along the connection direction where the elements should end. If the last value in the sequence is not equal to 1.0, there will be a gap between the consecutive connections.

  • 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(n, step=1.0, dir=0, degree=1, eltype=None)

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.

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

Returns a new Mesh obtained by sweeping the given Mesh over a path. The returned Mesh has double plexitude of the original. The operation is similar to the extrude() method, but the path can be any 3D curve.

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 produces the correct element type, but the geometry .

classmethod concatenate(clas, meshes, **kargs)

Concatenate a list of meshes of the same plexitude and eltype

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

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.

clip(t, compact=False)

Return a Mesh with all the elements where t>0.

t should be a 1-D integer array with length equal to the number of elements of the Mesh. The resulting Mesh will contain all elements where t > 0.

cclip(t, compact=False)

This is the complement of clip, returning a Mesh where t<=0.

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)

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.

volume()

Return the total volume of a Mesh.

If the Mesh can not be converted to tet4 type, 0 is returned

addNoise(*args, **kargs)

Apply ‘addNoise’ transformation to the Geometry object.

See coords.Coords.addNoise() for details.

affine(*args, **kargs)

Apply ‘affine’ transformation to the Geometry object.

See coords.Coords.affine() for details.

align(*args, **kargs)

Apply ‘align’ transformation to the Geometry object.

See coords.Coords.align() for details.

bump(*args, **kargs)

Apply ‘bump’ transformation to the Geometry object.

See coords.Coords.bump() for details.

bump1(*args, **kargs)

Apply ‘bump1’ transformation to the Geometry object.

See coords.Coords.bump1() for details.

bump2(*args, **kargs)

Apply ‘bump2’ transformation to the Geometry object.

See coords.Coords.bump2() for details.

centered(*args, **kargs)

Apply ‘centered’ transformation to the Geometry object.

See coords.Coords.centered() for details.

cylindrical(*args, **kargs)

Apply ‘cylindrical’ transformation to the Geometry object.

See coords.Coords.cylindrical() for details.

egg(*args, **kargs)

Apply ‘egg’ transformation to the Geometry object.

See coords.Coords.egg() for details.

flare(*args, **kargs)

Apply ‘flare’ transformation to the Geometry object.

See coords.Coords.flare() for details.

hyperCylindrical(*args, **kargs)

Apply ‘hyperCylindrical’ transformation to the Geometry object.

See coords.Coords.hyperCylindrical() for details.

isopar(*args, **kargs)

Apply ‘isopar’ transformation to the Geometry object.

See coords.Coords.isopar() for details.

map(*args, **kargs)

Apply ‘map’ transformation to the Geometry object.

See coords.Coords.map() for details.

map1(*args, **kargs)

Apply ‘map1’ transformation to the Geometry object.

See coords.Coords.map1() for details.

mapd(*args, **kargs)

Apply ‘mapd’ transformation to the Geometry object.

See coords.Coords.mapd() for details.

projectOnCylinder(*args, **kargs)

Apply ‘projectOnCylinder’ transformation to the Geometry object.

See coords.Coords.projectOnCylinder() for details.

projectOnPlane(*args, **kargs)

Apply ‘projectOnPlane’ transformation to the Geometry object.

See coords.Coords.projectOnPlane() for details.

projectOnSphere(*args, **kargs)

Apply ‘projectOnSphere’ transformation to the Geometry object.

See coords.Coords.projectOnSphere() for details.

replace(*args, **kargs)

Apply ‘replace’ transformation to the Geometry object.

See coords.Coords.replace() for details.

rollAxes(*args, **kargs)

Apply ‘rollAxes’ transformation to the Geometry object.

See coords.Coords.rollAxes() for details.

rot(*args, **kargs)

Apply ‘rotate’ transformation to the Geometry object.

See coords.Coords.rotate() for details.

rotate(*args, **kargs)

Apply ‘rotate’ transformation to the Geometry object.

See coords.Coords.rotate() for details.

scale(*args, **kargs)

Apply ‘scale’ transformation to the Geometry object.

See coords.Coords.scale() for details.

shear(*args, **kargs)

Apply ‘shear’ transformation to the Geometry object.

See coords.Coords.shear() for details.

spherical(*args, **kargs)

Apply ‘spherical’ transformation to the Geometry object.

See coords.Coords.spherical() for details.

superSpherical(*args, **kargs)

Apply ‘superSpherical’ transformation to the Geometry object.

See coords.Coords.superSpherical() for details.

swapAxes(*args, **kargs)

Apply ‘swapAxes’ transformation to the Geometry object.

See coords.Coords.swapAxes() for details.

toCylindrical(*args, **kargs)

Apply ‘toCylindrical’ transformation to the Geometry object.

See coords.Coords.toCylindrical() for details.

toSpherical(*args, **kargs)

Apply ‘toSpherical’ transformation to the Geometry object.

See coords.Coords.toSpherical() for details.

transformCS(*args, **kargs)

Apply ‘transformCS’ transformation to the Geometry object.

See coords.Coords.transformCS() for details.

translate(*args, **kargs)

Apply ‘translate’ transformation to the Geometry object.

See coords.Coords.translate() for details.

trl(*args, **kargs)

Apply ‘translate’ transformation to the Geometry object.

See coords.Coords.translate() for details.

resized(size=1.0, tol=1.0000000000000001e-05)

Return a scaled copy of the Formex with given size in all directions.

If a direction has zero size, it is not rescaled.

write(fil, sep=' ', mode='w')

Write a Geometry to a .pgf file.

If fil is a string, a file with that name is opened. Else fil should be an open file. The Geometry is then written to that file in a native format, using sep as separator between the coordinates. If fil is a string, the file is closed prior to returning.

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.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:fuse(). Setting fuse=False will merely concatenate all the mesh.coords, but not fuse them.