Problem generating anisotropic mesh with MathEvalAniso and MMG3D
I am trying to mesh a geometry that is much larger in the x and y directions than the z direction. I would like to have several layers in the mesh in the z direction.
The geometry is from topographic data, extruded to have a small thickness. An initial surface mesh can be produced and extruded outside of gmsh and imported into gmsh as an stl file (the attached topo.stl). I can also create a 3D mesh from this stl file, but it only has one layer in the z direction.
I thought that I might be able to do what I need with a combination of setting the mesh size field using MathEvalAniso and using the MMG3D algorithm, which is supposed to allow for anisotropic meshes in 3D. I tested this with a simple case of a box. The following code (using the python API) demonstrates this attempt, using the attached box.stl: box.stl
import gmsh import sys import math #%% import box geometry stl gmsh.initialize() gmsh.merge('box.stl') angle=40 forceParametrizablePatches=False includeBoundary=True curveAngle=180 gmsh.model.mesh.classifySurfaces(angle*math.pi/180.,includeBoundary,forceParametrizablePatches,curveAngle*math.pi/180.) gmsh.model.mesh.createGeometry() s = gmsh.model.getEntities(2) l = gmsh.model.geo.addSurfaceLoop([s[i] for i in range(len(s))]) gmsh.model.geo.addVolume([l]) #%% mesh the geometry gmsh.model.geo.synchronize() xsize=1 ysize=1 zsize=0.1 f=gmsh.model.mesh.field.add("MathEvalAniso") gmsh.model.mesh.field.setString(f,"M11",str(xsize)) gmsh.model.mesh.field.setString(f,"M12","0") gmsh.model.mesh.field.setString(f,"M13","0") gmsh.model.mesh.field.setString(f,"M22",str(ysize)) gmsh.model.mesh.field.setString(f,"M23","0") gmsh.model.mesh.field.setString(f,"M33",str(zsize)) gmsh.model.mesh.field.setAsBackgroundMesh(f) gmsh.option.setNumber("Mesh.Algorithm3D", 7) gmsh.model.mesh.generate(3) #%% display result if '-nopopup' not in sys.argv: gmsh.fltk.run() gmsh.finalize()
However, this mesh does not have the desired mesh size in the z direction. What I want is a mesh like this. This mesh was created using extrusion, but extrusion will not work for the more complex geometry I ultimately need to use.
I would really appreciate any help understanding what I may be doing wrong, or if what I hope to do is not possible.
Best regards, Claire