How to set variable mesh characteristic lengths for different parts of a mesh in OCC ( Local mesh refinement)
Hi, When creating compound objects by adding together individual shapes using OCC, I would like to have different mesh characters at different parts of the mesh. For example in this case, I'm trying to fuse together a sphere and a cylinder. The global value of Maximum characteristic length is set as 4.0, however I would like to have a more refined mesh at the sphere.
In conventional gmsh '.geo' script, this can be achieved by setting the mesh length while defining each point. How can we do this using Python API / using OCC?
Also a minor thing: While doing stuff like this ( creating shapes by fusing units ), If I use the removeAllDuplicates
option before taking the fuse
, I'm ending up with internal surfaces ( boolean - fuse is not working well ). Why is this?
What exactly does this removeAllDuplicates
do ?
import gmsh
import numpy
import itertools
outfile = "Rod.msh"
lc = 4.0
side_length = 50.0
cyl_rad = 6.0
originP = [0., 0., 0.]
model = gmsh.model
factory = model.occ
pi = numpy.pi
gmsh.initialize()
gmsh.option.setNumber("Mesh.CharacteristicLengthMax", lc)
gmsh.option.setNumber("General.Terminal", 1)
model.add("ice")
def finish_and_write(filename='mesh.msh'):
factory.synchronize()
model.mesh.generate(3)
gmsh.write(filename)
gmsh.fltk.run()
gmsh.finalize()
def copy_obj(obj):
return factory.copy([(3, obj)])[0][1]
def touch_sphere(cordinates_xyz, radius_):
return factory.addSphere(cordinates_xyz[0], cordinates_xyz[1],
cordinates_xyz[2], radius=radius_)
def touch_cyllinder(p1, p2, rad):
return factory.addCylinder(p1[0], p1[1], p1[2],
p2[0] - p1[0], p2[1] - p1[1]
, p2[2] - p1[2], rad)
p0 = [0, 0, 0]
p1 = [20, 0, 0]
p2 = [3., 0., 0.]
sph = touch_sphere(p0, 4.0)
cyl = touch_cyllinder(p2, p1, 4.0)
print factory.fuse([(3, cyl)], [(3, sph)])
factory.removeAllDuplicates()
finish_and_write(outfile)
quit()