Mixing hex and tets in GMSH
Hi,
I am trying to make mesh in a domain that contains two boxes and cylinders using python API of GMSH (version 4.9.0
). Is it possible to make hex meshes for cylinder and tets for the rest of domain in GMSH? The cylinders should be refined and distribution of elements in cylinders should be as homogeneous as possible. That's why I thought maybe hex elements in cylinders will be more helpful. This is my script for meshing:
import gmsh
import numpy as np
gmsh.initialize()
x_min, x_max = 0, 1000
y_min, y_max = 0, 500
z_min, z_max = -500, 0
gmsh.model.occ.addRectangle(x_min, y_min, -100, x_max, y_max, 1)
bh_r = 1
ht_x, ht_y, ht_z, cl_x = 250, 250, -200, 750
gmsh.model.occ.addBox(x_min, y_min, z_max, x_max, y_max, z_min, 1)
gmsh.model.occ.addCylinder(ht_x, ht_x, -400, 0, 0, 200, bh_r, tag=2, angle=2*np.pi)
gmsh.model.occ.addCylinder(cl_x, ht_x, -400, 0, 0, 200, bh_r, tag=3, angle=2*np.pi)
gmsh.model.occ.synchronize()
lines = gmsh.model.occ.getEntities(1)
points = gmsh.model.occ.getEntities(0)
gmsh.model.occ.fragment(points + lines + [(2, 1)] + [(3, 2), (3, 3)], [(3, 1)])
gmsh.model.occ.synchronize()
gmsh.model.mesh.field.add("Distance", 1)
gmsh.model.mesh.field.setNumbers(1, "SurfacesList", [8, 9, 10, 11, 12, 13])
gmsh.model.mesh.field.setNumber(1, "Sampling", 100)
gmsh.model.mesh.field.add("Threshold", 2)
gmsh.model.mesh.field.setNumber(2, "InField", 1)
gmsh.model.mesh.field.setNumber(2, "SizeMin", bh_r)
gmsh.model.mesh.field.setNumber(2, "SizeMax", 100)
gmsh.model.mesh.field.setNumber(2, "DistMin", bh_r*1.5)
gmsh.model.mesh.field.setNumber(2, "DistMax", 150)
gmsh.model.mesh.field.add("Min", 3)
gmsh.model.mesh.field.setNumbers(3, "FieldsList", [2])
gmsh.model.mesh.field.setAsBackgroundMesh(3)
gmsh.option.setNumber("Mesh.MeshSizeMax", 100)
gmsh.option.setNumber("Mesh.MeshSizeExtendFromBoundary", 0)
gmsh.option.setNumber("Mesh.Algorithm3D", 10)
gmsh.model.mesh.generate(3)
gmsh.write("cylinder.msh")
gmsh.fltk.run()
gmsh.finalize()
At the moment the tets distribution in cylinders looks like the following (a cross-section zoomed into the model):
As you can see some irregularities does exit while I need a more homogeneous distribution of the elements in cylinder. These irregular nodes can act as deadenes for the numerical solvers and wrong values are generated there. Thanks for your help.