occ.AddBspline() throws OSError: exception: access violation reading 0x00000000000254
Hi All,
I'm trying to mesh a 2d surface and soe of the edges are BSplines. I want to input the weights and knot vectors of the BSpline so i am using the occ class instead of geo. I am getting an OSError for the occ.AddBspline function. I don't know how to fix it. Can you advise on what to do?
Here's the code:
import gmsh
import sys
#initialize mesh
gmsh.initialize()
#add new model
gmsh.model.add("cell_mesh_tb0.4_lb0.4_rc0.4")
#add perimeter points
gmsh.model.geo.addPoint(-1.72, 0, 0, 1)
gmsh.model.geo.addPoint(-1.72, 0.8, 0, 2)
gmsh.model.geo.addPoint(0.4, 0.8, 0, 3)
gmsh.model.geo.addPoint(0, 0, 0, 4)
gmsh.model.geo.addPoint(0.4, 7.25288143364131E-17, 0, 5)
gmsh.model.geo.addPoint(0.4, 0.4, 0, 6)
gmsh.model.geo.addPoint(5.68, 0.8, 0, 7)
gmsh.model.geo.addPoint(5.68, 0.4, 0, 8)
gmsh.model.geo.addPoint(5.68, 1.6, 0, 9)
gmsh.model.geo.addPoint(6.08, 1.6, 0, 10)
gmsh.model.geo.addPoint(6.08, 1.2, 0, 11)
gmsh.model.geo.addPoint(6.08, 0.8, 0, 12)
gmsh.model.geo.addPoint(5.68, 2, 0, 13)
gmsh.model.geo.addPoint(6.48, 2, 0, 14)
gmsh.model.geo.addPoint(6.48, 1.2, 0, 15)
gmsh.model.geo.addPoint(6.48, 0.4, 0, 16)
gmsh.model.geo.addPoint(3.04, 1.6, 0, 17)
gmsh.model.geo.addPoint(3.04, 2, 0, 18)
gmsh.model.geo.addPoint(7.8, 3.6, 0, 19)
gmsh.model.geo.addPoint(7.8, 2.8, 0, 20)
gmsh.model.geo.addPoint(5.68, 2.8, 0, 21)
gmsh.model.geo.addPoint(6.08, 3.6, 0, 22)
gmsh.model.geo.addPoint(5.68, 3.6, 0, 23)
gmsh.model.geo.addPoint(5.68, 3.2, 0, 24)
gmsh.model.geo.addPoint(0.399999999999999, 2.8, 0, 25)
gmsh.model.geo.addPoint(0.399999999999999, 3.2, 0, 26)
gmsh.model.geo.addPoint(0.4, 2, 0, 27)
gmsh.model.geo.addPoint(0, 2, 0, 28)
gmsh.model.geo.addPoint(-4.9960036108132E-16, 2.4, 0, 29)
gmsh.model.geo.addPoint(0, 2.8, 0, 30)
gmsh.model.geo.addPoint(0.4, 1.6, 0, 31)
gmsh.model.geo.addPoint(-0.400000000000001, 1.6, 0, 32)
gmsh.model.geo.addPoint(-0.4, 2.4, 0, 33)
gmsh.model.geo.addPoint(-0.400000000000001, 3.2, 0, 34)
#add perimeter lines and arc
gmsh.model.geo.addLine(1, 2, 1)
gmsh.model.geo.addLine(2, 3, 2)
gmsh.model.geo.addLine(4, 1, 3)
gmsh.model.geo.addCircleArc(4, 5, 6, 4)
gmsh.model.geo.addLine(3, 7, 5)
gmsh.model.geo.addLine(6, 8, 6)
gmsh.model.occ.addBSpline([9,10,11,12,7], 7, 2, [1,0.707106781186547,1,0.707106781186547,1], [0,0,0.628318530717959,0.628318530717959,1.25663706143592,1.25663706143592], [2,2,2,2,2,2])
gmsh.model.occ.addBSpline([13,14,15,16,8], 8, 2, [1,0.707106781186547,1,0.707106781186547,1], [0,0,1.25663706143592,1.25663706143592,2.51327412287183,2.51327412287183], [2,2,2,2,2,2])
gmsh.model.geo.addLine(9, 17, 9)
gmsh.model.geo.addLine(13, 18, 10)
gmsh.model.geo.addLine(19, 20, 11)
gmsh.model.geo.addLine(20, 21, 12)
gmsh.model.geo.addLine(22, 19, 13)
gmsh.model.geo.addCircleArc(22, 23, 24, 14)
gmsh.model.geo.addLine(21, 25, 15)
gmsh.model.geo.addLine(24, 26, 16)
gmsh.model.occ.addBSpline([27,28,29,30,25], 17, 2, [1,0.707106781186547,1,0.707106781186547,1], [0,0,0.628318530717959,0.628318530717959,1.25663706143592,1.25663706143592], [2,2,2,2,2,2])
gmsh.model.occ.addBSpline([31,32,33,34,26], 18, 2, [1,0.707106781186547,1,0.707106781186547,1], [0,0,1.25663706143592,1.25663706143592,2.51327412287183,2.51327412287183], [2,2,2,2,2,2])
gmsh.model.geo.addLine(27, 18, 19)
gmsh.model.geo.addLine(31, 17, 20)
#create curved loop for perimeter
gmsh.model.geo.addCurveLoop([1,2,5,-7,9,-20,18,-16,-14,13,11,12,15,-17,19,-10,8,-6,-4,3], 1)
#create surface
gmsh.model.geo.addPlaneSurface([1], 1)
#synchronized CAD entities
gmsh.model.geo.synchronize()
#mesh constraints
lc=0.0333333333333333
gmsh.model.mesh.field.add("Distance", 1)
#edge constraint
gmsh.model.mesh.field.setNumbers(1, "CurvesList",[0])
gmsh.model.mesh.field.setNumber(1, "NumPointsPerCurve", 500)
gmsh.model.mesh.field.add("Threshold", 2)
gmsh.model.mesh.field.setNumber(2, "InField", 1)
gmsh.model.mesh.field.setNumber(2, "SizeMin", lc)
gmsh.model.mesh.field.setNumber(2, "SizeMax", 3 * lc)
gmsh.model.mesh.field.setNumber(2, "DistMin", 0.4)
gmsh.model.mesh.field.setNumber(2, "DistMax", 2)
gmsh.model.mesh.field.setAsBackgroundMesh(2)
#
gmsh.option.setNumber("Mesh.MeshSizeExtendFromBoundary", 0)
gmsh.option.setNumber("Mesh.MeshSizeFromPoints", 0)
gmsh.option.setNumber("Mesh.MeshSizeFromCurvature", 0)
#Make quads
gmsh.model.mesh.setRecombine(2, 1)
#Mesh color
gmsh.model.setColor(gmsh.model.getEntities(2), 255, 0, 0)
#generate and save mesh
gmsh.model.mesh.generate(2)
gmsh.write("quarter_tile.msh")
#Launch the GUI to see the results:
if '-nopopup' not in sys.argv:
gmsh.fltk.run()
#finalize mesh
gmsh.finalize()
Here's the error i am getting:
Traceback (most recent call last): File "gen.py", line 59, in gmsh.model.occ.addBSpline([9,10,11,12,7], 7, 2, [1,0.707106781186547,1,0.707106781186547,1], [0,0,0.628318530717959,0.628318530717959,1.25663706143592,1.25663706143592], [2,2,2,2,2,2]) File "C:\python\lib\site-packages\gmsh-4.8.4-Windows64-sdk\lib\gmsh.py", line 4904, in addBSpline api_result_ = lib.gmshModelOccAddBSpline( OSError: exception: access violation reading 0x0000000000000254
thanks a bunch, Victor