Problem using the Restrict field (python API)
Hi, I have a small issue when trying to use the "Restrict" field application.
I discover that when a restrict field is applied to a surface via python api :
restrict_field = gmsh.model.mesh.field.add("Restrict")
gmsh.model.mesh.field.setNumber(restrict_field, "InField", distance_field)
gmsh.model.mesh.field.setNumber(restrict_field, "SurfacesList", my_surface1_next_2_my_line)
The field is not working.
When I open the fltk and look at the Size fields, the restricted_field exists, with the correct InField, but the SurfacesList is not assigned, thus the field doesn't work as intended
I have to reinput the surface tag in SurfacesList manually with the GUI.
When I reinput the SurfacesList tag manually, everything is working fine.
I also noticed that the "Restrict" field Options ("SurfacesList") is not working correctly because when a list() argument is given it raises a TypeError: must be real number, not list. I can only pass one by one the tag of each surface as an int. Hope this can help you to find where this error is coming from
The issue is the same for CurvesList, I didn't test volumes and points list
Here is a code very similar to the t10.py so that you can reproduce the issue that I discover :
import sys
import gmsh
gmsh.initialize(sys.argv)
gmsh.model.add("t10")
# Let's create a simple rectangular geometry:
lc = 0.15
gmsh.model.geo.addPoint(0.0, 0.0, 0, lc, 1)
gmsh.model.geo.addPoint(1, 0.0, 0, lc, 2)
gmsh.model.geo.addPoint(1, 1, 0, lc, 3)
gmsh.model.geo.addPoint(0, 1, 0, lc, 4)
gmsh.model.geo.addPoint(2, 0.0, 0, lc, 5)
gmsh.model.geo.addPoint(2, 1, 0, lc, 6)
gmsh.model.geo.addPoint(3, 0.0, 0, lc, 7)
gmsh.model.geo.addPoint(3, 1, 0, lc, 8)
gmsh.model.geo.addLine(1, 2, 1)
gmsh.model.geo.addLine(2, 3, 2)
gmsh.model.geo.addLine(3, 4, 3)
gmsh.model.geo.addLine(4, 1, 4)
gmsh.model.geo.addLine(5, 7, 5)
gmsh.model.geo.addLine(7, 8, 6)
gmsh.model.geo.addLine(8, 6, 7)
gmsh.model.geo.addLine(6, 5, 8)
gmsh.model.geo.addCurveLoop([1, 2, 3, 4], 9)
gmsh.model.geo.addCurveLoop([5, 6, 7, 8], 10)
gmsh.model.geo.addPlaneSurface([9], 11)
gmsh.model.geo.addPlaneSurface([10], 12)
gmsh.model.geo.synchronize()
gmsh.model.mesh.field.add("Distance", 1)
gmsh.model.mesh.field.setNumbers(1, "CurvesList", [1])
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", 0.005)
gmsh.model.mesh.field.setNumber(2, "SizeMax", 0.05)
gmsh.model.mesh.field.setNumber(2, "DistMin", 0.02)
gmsh.model.mesh.field.setNumber(2, "DistMax", 0.7)
gmsh.model.mesh.field.add("Restrict", 3)
gmsh.model.mesh.field.setNumber(3, "InField", 2)
gmsh.model.mesh.field.setNumber(3, "SurfacesList", 11)
gmsh.model.mesh.field.add("Distance", 4)
gmsh.model.mesh.field.setNumbers(4, "SurfacesList", [12])
gmsh.model.mesh.field.setNumber(4, "Sampling", 100)
gmsh.model.mesh.field.add("Threshold", 5)
gmsh.model.mesh.field.setNumber(5, "InField", 4)
gmsh.model.mesh.field.setNumber(5, "SizeMin", 0.5)
gmsh.model.mesh.field.add("Restrict", 6)
gmsh.model.mesh.field.setNumber(6, "InField", 5)
gmsh.model.mesh.field.setNumber(6, "SurfacesList", 12)
gmsh.model.mesh.field.add("Min", 7)
gmsh.model.mesh.field.setNumbers(7, "FieldsList", [3, 6])
gmsh.model.mesh.field.setAsBackgroundMesh(7)
gmsh.option.setNumber("Mesh.Algorithm", 6)
gmsh.model.mesh.generate(2)
# Launch the GUI to see the results:
if "-nopopup" not in sys.argv:
gmsh.fltk.run()
gmsh.finalize()
I hope this issue is easy to fix,
all the best
Tony