BasicTools.Containers.UnstructuredMeshModificationTools module

BasicTools.Containers.UnstructuredMeshModificationTools.AddTagPerBody(inmesh: UnstructuredMesh) ndarray[source]
Generate nodal tag (in the form of “Body_”+int) per body

a body is defined by all the nodes connected by the elements (connectivity filter in vtk )


inmesh (UnstructuredMesh) – the input mesh


pointsPerBody : a vector with the number of point in every body. len(pointsPerBody) is the number of unconnected bodies in the mesh

Return type:



Exception – in the case of an internal error

BasicTools.Containers.UnstructuredMeshModificationTools.CleanDoubleElements(mesh: UnstructuredMesh)[source]

Remove double elements on the mesh, even if a permutation exist


mesh (UnstructuredMesh) – the input mesh

BasicTools.Containers.UnstructuredMeshModificationTools.CleanDoubleNodes(mesh: UnstructuredMesh, tol: Optional[float64] = None, nodesToTestMask: Optional[Union[_SupportsArray[dtype], _NestedSequence[_SupportsArray[dtype]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]] = None)[source]

Remove double nodes for the input mesh

  • mesh (UnstructuredMesh) – the in put mesh

  • tol (Optional[PBasicFloatType], optional) – the tolerance, by default value is = np.linalg.norm(mesh.boundingMax - mesh.boundingMin)*1e-7 if tol is zero a faster algorithm is used

  • nodesToTestMask (ArrayLike, optional) – _description_, by default None

BasicTools.Containers.UnstructuredMeshModificationTools.CleanLonelyNodes(mesh: UnstructuredMesh, inPlace: bool = True) Tuple[ndarray, UnstructuredMesh][source]

Remove nodes not used by the elements

  • mesh (UnstructuredMesh) – the input mesh

  • inPlace (bool, optional) – if true the nodes are removed in place , by default True


usedNodes: a mask of type ndarray (size the number of nodes in mesh) with the nodes present on the cleanMesh cleanMesh: UnstructuredMesh the mesh without lonely nodes

Return type:

(usedNodes, cleanMesh)

BasicTools.Containers.UnstructuredMeshModificationTools.ComputeFeatures(inputMesh: UnstructuredMesh, featureAngle: float64 = 90.0, skin: Optional[UnstructuredMesh] = None) Tuple[UnstructuredMesh, UnstructuredMesh][source]

Compute features, element of dimensionality dim-2 (edges) for a given angle

  • inputMesh (UnstructuredMesh) – the input mesh

  • featureAngle (PBasicFloatType, optional) – the detection angle: edges with faces with an angle grater than featureAngle will be consider as ridges , by default 90.

  • skin (Optional[UnstructuredMesh], optional) – if the user can provide the skin (to save time), by default None


edgeMesh: a mesh containing the edges skinMesh: a mesh containing the skin

Return type:


BasicTools.Containers.UnstructuredMeshModificationTools.ComputeRigidBodyTransformationBetweenTwoSetOfPoints(setPoints1: ndarray, setPoints2: ndarray) Tuple[ndarray, ndarray][source]

Compute the rotation and the translation operator from two sets of points setPoints1 and setPoints2 have the same dimension (nbeOfPoints,dimension)

  • setPoints1 (np.ndarray) – First set of points

  • setPoints2 (np.ndarray) – Second set of points


A, b such that setPoints1.T approx A*setPoints2.T + b

Return type:

Tuple[np.ndarray, np.ndarray]

BasicTools.Containers.UnstructuredMeshModificationTools.ComputeSkin(mesh: UnstructuredMesh, md: Optional[int] = None, inPlace: bool = False) UnstructuredMesh[source]

Compute the skin of a mesh (mesh), if md (mesh dimensionality) is None the mesh.GetDimensionality() is used to filter the element to compute the skin.

Warning if some elements are duplicated the behavior of computeSkin with the option inPlace=True is not defined (Use CleanDoubleElements before ComputeSkin)

  • mesh (UnstructuredMesh) – the input mesh

  • md (Optional[int], optional) – _description_, by default None

  • inPlace (bool, optional) –

    if True the skin is added to the original mesh, a tag “Skin” is created. if False a new mesh is returned with the elements of the skin (even if

    some element of the skin are already present on the original mesh). If the user merged the two meshes, you must call CleanDoubleElements to clean the mesh

    , by default False


The mesh containing the skin, (the mesh if inPlace == True, or only the skin if inPlace ==False)

Return type:


BasicTools.Containers.UnstructuredMeshModificationTools.ConvertNTagsToETags(mesh: UnstructuredMesh, prefix='NTag', targetDim: Optional[int] = None)[source]

Create eTags from nTags on the mesh. Skin (surface element) and edges are created to hold the eTag information. The name of the created element tags is constructed using :


Where d is the dimensionality of the target elements (1 for edges, 2 for surfaces) I.e.: “NTag1D_ForceEdgeNodes”

  • mesh (UnstructuredMesh) – The input mesh

  • prefix (str, optional) – The prefix used for the creation of eTags, by default “NTag”

  • targetDim (int | None, optional) – if None, surface and edge element with be created, by default None if 1 only edges with be created if 2 only surface elements are created

BasicTools.Containers.UnstructuredMeshModificationTools.CopyElementTags(sourceMesh: UnstructuredMesh, targetMesh: UnstructuredMesh, extendTags: bool = False)[source]

Copy tags from sourceMesh to the targetMesh We use the connectivity to identify the elements

  • sourceMesh (UnstructuredMesh) – The source

  • targetMesh (UnstructuredMesh) – _description_

  • extendTags (bool, optional) – if False will overwrite the tags on targetMesh if True will extend the tags on targetMesh by default False

BasicTools.Containers.UnstructuredMeshModificationTools.DeleteElements(mesh: UnstructuredMesh, mask: Union[_SupportsArray[dtype], _NestedSequence[_SupportsArray[dtype]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]])[source]

Delete elements on the input mesh

  • mesh (UnstructuredMesh) – the input mesh

  • mask (ArrayLike) – the mash of elements to delete

BasicTools.Containers.UnstructuredMeshModificationTools.DeleteInternalFaces(mesh: UnstructuredMesh)[source]

Delete faces not present on the skin (internal faces)


mesh (UnstructuredMesh) – the mesh

BasicTools.Containers.UnstructuredMeshModificationTools.LowerNodesDimension(mesh: UnstructuredMesh) UnstructuredMesh[source]

Remove the last columns of the mesh nodes coordinate. This is done in place


mesh (UnstructuredMesh) – the input mesh


the mesh

Return type:


BasicTools.Containers.UnstructuredMeshModificationTools.Morphing(mesh: UnstructuredMesh, targetDisplacement, targetDisplacementMask, radius: Optional[float64] = None, forceOneStep=False) ndarray[source]

method for computing the deform mesh knowing displacement of some nodes. the user can push the morphed point back to the mesh by doing : mesh.node = morphedPoints


  • mesh (UnstructuredMesh) – the input mesh, the use only the point position information

  • targetDisplacement (_type_) – is the known displacement in a numpy array (shape [number_of_of_known_nodes,3])

  • targetDisplacementMask (_type_) – array containing the ids of known nodes (list of ids or boolean array) in the same order as targetDisplacement

  • rayon (Optional[PBasicFloatType], optional) – you can choose a radius by setting rayon to a value, by default np.linalg.norm(mesh.boundingMax-mesh.boundingMin)/2

  • forceOneStep (bool, optional) – if True do the morphing in one step, by default False


morphedPoints: the morphed points

Return type:


BasicTools.Containers.UnstructuredMeshModificationTools.NodesPermutation(mesh: UnstructuredMesh, per: Union[_SupportsArray[dtype], _NestedSequence[_SupportsArray[dtype]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]])[source]

Function to do a permutation of the nodes in a mesh (in place)

  • mesh (UnstructuredMesh) – mesh to be modified

  • per (ArrayLike) – the permutation vector ([1,0,2,3] to permute first an second node)

BasicTools.Containers.UnstructuredMeshModificationTools.RigidBodyTransformation(mesh: UnstructuredMesh, rotationMatrix: ndarray, translationVector: ndarray)[source]

In place rigid body transformation. new pos = Q.pos + translation

the rotation matrix Q should verify: QtQ = I = QQt et det Q = 1

  • mesh (UnstructuredMesh) – The input mesh

  • rotationMatrix (np.ndArray) – a 3x3 rotation matrix

  • translationVector (np.ndArray) – a vector of size 3 with the translation