Dear all, I am trying to mesh a composite material made of paste and grains. Since I have to do some Boolean operation on a 3D volume of composite I tried to use the occ factory. At the end of the day I need a continuous mesh where paste elements of the mesh belong to a paste physical group and grains elements belong to an other physical group.
In the attached script I first create a cylinder and two grains. Using a cut I was able to obtain a mesh with all the elements belonging to the paste. Using a fuse I was able to obtain a mesh with all the elements belonging to the grains. Unfortunately, it seems that the two meshes are separated. I tried to fuse them to obtain a continuous mesh but I am not sure it works fine and that it is the proper method. Any advice ? Regards -- Frédéric Dubois, PhD, Eng. --- Directeur adjoint du LMGC. Laboratoire de Mécanique et Génie Civil - CNRS/UM cc 048, 163 rue Auguste Broussonnet, 34090 Montpellier http://www.lmgc.univ-montp2.fr/~dubois Tel: 33/0 467144984 Mobile: 33/0 635490843
import math import sys import gmsh gmsh.initialize(sys.argv) # 1: MeshAdapt, 2: Automatic, 5: Delaunay, 6: Frontal-Delaunay, 7: BAMG, # 8: Frontal-Delaunay for Quads, 9: Packing of Parallelograms gmsh.option.setNumber("Mesh.Algorithm", 5) # 1: Delaunay, 4: Frontal, 7: MMG3D, 9: R-tree, 10: HXT gmsh.option.setNumber("Mesh.Algorithm3D", 1) # dreaming of an homogeneous mesh size lc_=0.5 gmsh.option.setNumber("Mesh.CharacteristicLengthMin", lc_); gmsh.option.setNumber("Mesh.CharacteristicLengthMax", lc_); # gmsh.option.setNumber("Mesh.MshFileVersion",2.2) gmsh.model.add("cheese"); # cylinder cyl=gmsh.model.occ.addCylinder(0,0,0,0,0,5,2); # grains sphere1=gmsh.model.occ.addSphere(-1,0.,1,0.5) sphere2=gmsh.model.occ.addSphere(1.,0.,4,0.5) grains = gmsh.model.occ.fuse([(3,sphere1)],[(3,sphere2)])[0] gmsh.model.occ.synchronize() print(grains) lg=[] for g in grains: lg.append(g[1]) ggrains = gmsh.model.addPhysicalGroup(3,lg) gmsh.model.setPhysicalName(3, ggrains, 'grains') # paste = cyl - grains paste= gmsh.model.occ.cut([(3,cyl)],grains,removeObject=True,removeTool=False)[0][0] gmsh.model.occ.synchronize() print(paste) gpaste = gmsh.model.addPhysicalGroup(3,[paste[1]]) gmsh.model.setPhysicalName(3, gpaste, 'paste') # # merging grains and paste all = gmsh.model.occ.fuse(grains,[paste],removeObject=False,removeTool=False)[0][0] gmsh.model.occ.synchronize() print(all) gall = gmsh.model.addPhysicalGroup(3,[all[1]]) gmsh.model.setPhysicalName(3, gall, 'all') gmsh.model.mesh.generate(3) gmsh.write("composite.msh") gmsh.write("composite.vtk") gmsh.finalize()
_______________________________________________ gmsh mailing list gmsh@onelab.info http://onelab.info/mailman/listinfo/gmsh