Skip to content

Mesh Sizing with set_mesh_size_callback #595

Description

@oliviavitale35

Hello. I am meshing a device by adding and subtracting multiple geometries using geom.boolean_difference and geom.boolean_union. I cannot attach the script as it is proprietary, but I believe you should still be able to address my questions and concerns.

  1. Working in occ.Geometry, I define my mesh_size when initializing my geometries (I've tried with geo.Geometry as well). However, once I take their boolean difference, I get this warning:
    UserWarning: Specified mesh size for <redacted> discarded in Boolean difference operation.

  2. I then attempted to use the geom.set_mesh_size_callback() function, but I keep getting errors and the documentation is very limited. In the README file, you have a few examples using the function, but they do not run. I believe there was another closed issue about the README examples, but the issue persists.

I'm opening a new issue to request improved documentation on how to use the set_mesh_size_callback function in pygmsh. I keep getting the following error, no matter how I structure it:

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

Due to this line, which I copied from the README:
geom.set_mesh_size_callback(lambda dim, tag, x, y, z: abs(np.sqrt(x**2 + y**2 + z**2) - 0.5) + 0.1)

Does this need to be structure as an anonymous function for any specific reason? What to x, y, and z mean as inputs? Are they user-specified points in the mesh? More details on how this mesh refinement function works would be very helpful.

Thanks,
Olivia

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions