hybridmesh.HybridMesh.from_meshes#

classmethod HybridMesh.from_meshes(meshes, fuse=True, **kargs)#

Create a HybridMesh from a list of Mesh objects.

Each Mesh becomes a block in the HybridMesh. The coordinates of the meshes can be fused or kept separate.

Fields are also propagated from the input meshes to the resulting HybridMesh:

  • Only fields that exist on all input meshes with the same name and type are propagated.

  • Node fields (type=’node’) are remapped according to the fused coordinate indices if fuse=True. If multiple meshes contribute to the same fused node, the resulting node field value is averaged.

  • Element (type=’elem’) and element-node (type=’elemn’) fields are concatenated block-wise in the resulting HybridMesh.

Parameters#

mesheslist of Mesh objects

The meshes to convert into a HybridMesh.

fusebool, optional

If True (default), coincident nodes across meshes are fused into a single shared coordinates array. If False, coordinates are concatenated.

**kargs :

Additional keyword arguments passed to the fuse operation.

Returns#

HybridMesh

A new HybridMesh containing the blocks from the input meshes.

Examples#

>>> from hellotriangle.mesh import Mesh
>>> coords1 = Coords([[0,0,0],[1,0,0],[1,1,0],[0,1,0]])
>>> elems1 = [[0,1,2],[0,2,3]]
>>> M1 = Mesh(coords1, elems1, eltype='tri3')
>>> coords2 = Coords([[0,0,0],[0,1,0],[0.5,0.5,1]])
>>> elems2 = [[0,1,2]]
>>> M2 = Mesh(coords2, elems2, eltype='tri3')
>>> H = HybridMesh.from_meshes([M1,M2], fuse=True)
>>> H.n_coords()
5
>>> [b.n_elems() for b in H.elems]
[2, 1]
>>> [b.eltype.name for b in H.elems]
['Tri3', 'Tri3']
>>> G = HybridMesh.from_meshes([M1, M2], fuse=False)
>>> G.n_coords()
7
>>> print(G.coords)
[[0.  0.  0. ]
 [1.  0.  0. ]
 [1.  1.  0. ]
 [0.  1.  0. ]
 [0.  0.  0. ]
 [0.  1.  0. ]
 [0.5 0.5 1. ]]