Skip to content

Non-deterministic mesh generation #143

Closed

Description

@dbstein

First of all, thanks for the great code! I've been using Inti.jl as part of a package to simulate cytoskeletal dynamics (with fluid flows), and have found the code mostly very easy to work with. One thing that I try to do to speed up startup is to cache the precomputed singular integral operators (and their factorizations) associated with large objects to file, and in certain cases I started getting strange (i.e. clearly incorrect) results. After tracing things back, the root cause appears to be that mesh generation is not necessarily deterministic. I've attached a minimal working example. Really, it's the creation of the "Domain" that is not deterministic --- given a fixed Domain, the resultant mesh (and associated quadrature etc) are all generated deterministically, but generation of a Domain from geometric information produces non-deterministic behavior.

using Inti

function test(Domain=nothing)
    Domain = if Domain === nothing
        Inti.GeometricEntity("ellipsoid") |> Inti.Domain
    else
        Domain
    end
    Boundary = Inti.boundary(Domain)
    msh = Inti.meshgen(Boundary; meshsize=0.1)
    display(msh.nodes[1])
end

# not deterministic
for i in 1:5
    test()
end

# deterministic
Domain = Inti.GeometricEntity("ellipsoid") |> Inti.Domain
for i in 1:5
    test(Domain)
end

# what changes?
for i in 1:5
    Domain = Inti.GeometricEntity("ellipsoid") |> Inti.Domain
    display(Domain.keys.dict.slots)
    display(Domain.keys.dict.keys.ptr)
end

Activity

  1. maltezfaria commented on Jan 22, 2026

    @maltezfaria
    Member

    Thanks for the bug report and the MWE. The issue stems from the fact that Dicts and Sets in Julia are not deterministic themselves: there is no guarantee connection between the insertion order and the iteration order AFAIK. And Sets are used in Inti to store entities in a Domain right now.

    For your example, while the meshes were correct and always the same, I understand that you may want/expect the mesh structure to be invariant. I am gonna push a fix soon 👍

  2. maltezfaria commented on Jan 26, 2026

    @maltezfaria
    Member

    Hi @dbstein, I forgot to ping you earlier. I tried to address the issue you mentioned, but I’m not entirely sure it fully resolves it (the issue was auto-closed since it was linked to the PR I merged 😅). I hope that you can cache the pre-computation of the singular corrections now! Let me know if something still does not work and I can re-open this issue.

  3. maltezfaria commented on Jan 26, 2026

    @maltezfaria
    Member

    And there is a new tagged version with the fix, so you can run pkg> update to fetch it.

  4. dbstein commented on Jan 26, 2026

    @dbstein
    Author

    Yes, I saw, and thanks for the quick work! I'm deep in the midst of sorting out another (unrelated) bug --- I'll test your fix as soon as I sort that and let you know if everything is resolved.

  5. dbstein commented on Feb 12, 2026

    @dbstein
    Author

    Took a while to get back and check on this, but I can confirm that this fixes the issue I was having. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions