mymesh.improvement.TetContract#

mymesh.improvement.TetContract(M, h, FixedNodes={}, verbose=True, cleanup=True, maxIter=5, labels=None, FeatureAngle=25, sizing=None)[source]#

Edge contraction for tetrahedral mesh coarsening and quality improvement. Edges with edge length less than h will attempt to be contracted. Surfaces and features are preserved by prioritizing surface/feature nodes over interior nodes when deciding which node to remove in the edge collapse operation. Features (edges, corners), as determined by DetectFeatures(), are held fixed. An edge is only contracted if doing so doesn’t invert any elements or reduce the quality by creating a new element with a lower quality than was present in the local edge neighborhood before the contraction. Edges are processed in a heap sorted by edge length, with shorter edges being contracted first. New edges created in the edge contraction process are added to the heap, thus most edges are contracted in the first iteration, however some non-viable contractions may become viable after the first pass, thus multiple iterations can be performed until all possible edges are contracted.

Parameters:
  • M (mymesh.mesh) – Tetrahedral mesh to be contracted

  • h (float) – Edge length below which wil be contracted. Using 4/5 of the target edge length is often recommended.

  • FixedNodes (set or array_like, optional) – Indices of nodes to be held fixed, by default {}

  • verbose (bool, optional) – If true, will display progress, by default True

  • cleanup (bool, optional) – If true, unused nodes will be removed from the mesh and nodes will be renumbered, by default True.

  • maxIter (int, optional) – Maximum number of times to iterate through the mesh attempting to contract edges, by default 10. Most edges will be contracted in the first pass, however some contracts may not be permitted until other nearby elements have been modified.

  • labels (str or array_like, optional) – Element labels used to identify separate regions (e.g. materials) within a mesh, by default None. If provided as a string, the string must refer to an entry in M.ElemData, otherwise must be an array_like with the number of entries equal to the number of elements (M.NElem). Providing labels will preserve the interface and interface features between regions of differening labels. The labels of the new mesh will be stored in the ElemData of the returned mesh, either in ElemData[‘labels’] (if labels were provided as an array), or the entry matching the original ElemData entry (if labels were provided as a string).

  • FeatureAngle (int, optional) – Angle (in degrees) used to identify features, by default 25. See DetectFeatures() for more information.

Returns:

Mnew – Coarsened tetrahedral mesh

Return type:

mymesh.mesh