# Unconnected meshes of finite elements

**URL:** https://discourse.vtk.org/t/unconnected-meshes-of-finite-elements/12522
**Category:** Development
**Tags:** python, code
**Created:** [October 23, 2023, 7:26pm UTC](https://discourse.vtk.org/t/unconnected-meshes-of-finite-elements/12522 "2023-10-23T19:26:57Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![lucasteixeirag](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lucasteixeirag/32/7796_2.png) [@lucasteixeirag](https://discourse.vtk.org/u/lucasteixeirag)
#### Post date: [October 23, 2023, 7:26pm UTC](https://discourse.vtk.org/t/unconnected-meshes-of-finite-elements/12522/1 "2023-10-23T19:26:57Z")

</div>

Hello everyone. I’m working on a finite elements software. It basically works like this for now: I have a 3D model of a structure (a cube in a .step file), and I want to mesh it. I have a vtkUnstructuredGrid that represents the structure, and I want to mesh it with quadrilateral and triangular elements. I’m using gmsh to do the meshing, and I’m using the following code to do it:  
gmsh.initialize()  
gmsh.merge(“grid.stl”)  
gmsh.model.mesh.createTopology()  
gmsh.model.mesh.createGeometry()  
gmsh.model.mesh.createFaces()  
gmsh.model.mesh.createEdges()  
gmsh.model.occ.synchronize()  
gmsh.model.geo.synchronize()  
if meshType == 6:

```
    gmsh.option.setNumber('Mesh.Algorithm', meshType) 
    gmsh.option.setNumber('Mesh.MeshSizeMin', meshSize) 
    gmsh.option.setNumber('Mesh.MeshSizeMax', meshSize) 
elif meshType == 8:
    # Caso o tipo de malha seja quadrangular
    gmsh.option.setNumber('Mesh.Algorithm', meshType) 
    gmsh.option.setNumber('Mesh.MeshSizeMin', meshSize)
    gmsh.option.setNumber('Mesh.MeshSizeMax', meshSize) 
    gmsh.option.setNumber('Mesh.RecombineAll', 1) 
    gmsh.option.setNumber('Mesh.RecombinationAlgorithm', 3)
    gmsh.option.setNumber("Mesh.SubdivisionAlgorithm", 1)
gmsh.model.geo.synchronize() 
gmsh.model.occ.synchronize() 
gmsh.model.mesh.generate(2) 
gmsh.write("mesh.vtk")
gmsh.finalize()

```

after that, I read the mesh with the vtkDataSetReader and create a new vtk structure (mapper, actor, etc) with the mesh. The problem is that the mesh is not being created correctly, like in the images that I’m uploaded.  
I appreciate any help or suggestions! Thank you.

 ![dePerto](https://discourse.vtk.org/uploads/default/original/2X/4/485e9a2b98d670d6d3db9158169b44d269ba54c3.png)  
 ![malhaTriangularDupla](https://discourse.vtk.org/uploads/default/original/2X/6/601c7bcaaeb61346153c3f188099dbb8a86f15c7.png)  
 ![quadrada](https://discourse.vtk.org/uploads/default/original/2X/d/d382321aa2fe583a5f73e28b9c8e381821801a86.png)  
 ![triangularQuadrada](https://discourse.vtk.org/uploads/default/original/2X/7/7598d7d3ddf564b8f33b5f25bdb87c5ca2c29b95.png)
