The example "ball with mesh refinement" prints errors: TypeError: <lambda>() takes 5 positional arguments but 6 were given
yurivict opened this issue · 1 comments
yurivict commented
Exception ignored on calling ctypes callback function: <function model.mesh.setSizeCallback.<locals>.<lambda> at 0x8452fc1f0>
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/gmsh.py", line 3940, in <lambda>
api_callback_ = api_callback_type_(lambda dim, tag, x, y, z, lc, _ : callback(dim, tag, x, y, z, lc))
TypeError: <lambda>() takes 5 positional arguments but 6 were given
Exception ignored on calling ctypes callback function: <function model.mesh.setSizeCallback.<locals>.<lambda> at 0x8452fc1f0>
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/gmsh.py", line 3940, in <lambda>
api_callback_ = api_callback_type_(lambda dim, tag, x, y, z, lc, _ : callback(dim, tag, x, y, z, lc))
TypeError: <lambda>() takes 5 positional arguments but 6 were given
Version: 7.1.17
gmsh-4.11.0
Python-3.9
FreeBSD 13.1
mbarbie1 commented
Adding an extra argument "lc" in the lambda definition of the example removed the issue in my case.
# ball with mesh refinement
from math import sqrt
import pygmsh
with pygmsh.occ.Geometry() as geom:
geom.add_ball([0.0, 0.0, 0.0], 1.0)
geom.set_mesh_size_callback(
lambda dim, tag, x, y, z, lc: abs(sqrt(x ** 2 + y ** 2 + z ** 2) - 0.5) + 0.1
)
mesh = geom.generate_mesh()
Version: 7.1.17
gmsh-4.13.1
python-3.12
Windows 10