Access violation - gmsh.model.mesh.compute_cross_field()
I'm trying to use the Packing of Parallelograms algorithm to get a nice rectilinear mesh for a simple rectangle (using python gmsh v4.10.5), but when I run gmsh.model.mesh.compute_cross_field() I get an access violation. Code below (I'm new to using gmsh so I may be missing something).
import gmsh
import numpy as np
def main():
gmsh.initialize()
gmsh.model.add('Model-1')
global_mesh_size = 0.25
dx = 4.2
dy = 6.2
# create surface
p1 = np.array([0, 0, 0], dtype=float)
p2 = np.array([dx, 0, 0], dtype=float)
p3 = np.array([dx, dy, 0], dtype=float)
p4 = np.array([0, dy, 0], dtype=float)
poly = np.ndarray(shape=(4, 3), dtype=float)
poly[0] = p1
poly[1] = p2
poly[2] = p3
poly[3] = p4
poly_tags = [gmsh.model.geo.add_point(*p, global_mesh_size) for p in poly]
l1 = gmsh.model.geo.add_line(poly_tags[0], poly_tags[1])
l2 = gmsh.model.geo.add_line(poly_tags[1], poly_tags[2])
l3 = gmsh.model.geo.add_line(poly_tags[2], poly_tags[3])
l4 = gmsh.model.geo.add_line(poly_tags[3], poly_tags[0])
poly_curve_tag = gmsh.model.geo.add_curve_loop([l1, l2, l3, l4])
surface_tag = gmsh.model.geo.add_plane_surface([poly_curve_tag])
gmsh.model.geo.synchronize()
gmsh.model.mesh.compute_cross_field() # !!
gmsh.model.mesh.set_algorithm(2, surface_tag, 9) # 9 == Packing of Parallelograms
gmsh.model.mesh.set_recombine(2, surface_tag)
gmsh.model.mesh.generate(2)
gmsh.finalize()
if __name__ == "__main__":
main()
Edited by Christophe Geuzaine