I am trying to use GMSH python api for creating 2d meshes of cad formats. I managed to write a script that can generate mesh successfully. However I need to know how elements are separated across surfaces and how surfaces are separated across different volumes.
As I make experiments on gmsh, I understand that I can make physical groups for different geometry entities (volumes, surfaces, curves and points). And extract mesh nodes with using those physical groups. However I couldn't find a function that extract elements from physical groups. Also I couldn't create a structure that points which surfaces are part of which volumes.
While there is no good documentation for python api except source comments I can't think of another approach. Here is my code
import gmsh import sys import os gmsh.initialize(); #Import cad model gmsh.open(sys.argv) #Get volume entities volumeEntities=gmsh.model.getEntities(3); #Trimg dim from tuples volumeEntities=[x for x in volumeEntities]; #Create physical groups for volumes physicalVolumes=; for v in range(len(volumeEntities)): physTag=gmsh.model.addPhysicalGroup(3,[volumeEntities[v]],volumeEntities[v]); gmsh.model.setPhysicalName(3,volumeEntities[v],"Volume "+str(v)) physicalVolumes.append(physTag); #Same approach surfaceEntities=gmsh.model.getEntities(2); surfaceEntities=[x for x in surfaceEntities]; physicalSurfaces=; for s in range(len(surfaceEntities)): parent=gmsh.model.getParent(2,surfaceEntities[s]); tag=gmsh.model.addPhysicalGroup(2,[surfaceEntities[s]],surfaceEntities[s]); gmsh.model.setPhysicalName(2,surfaceEntities[s],"Surface "+str(s)); physicalSurfaces.append(tag); gmsh.model.mesh.generate(2); gmsh.fltk.run(); gmsh.finalize();