Skip to content

Use multiple threads in generalized winding numbers #1197

@juliohm

Description

@juliohm

The algorithm is embarrassingly parallel, and should be trivial to run in parallel with multiple threads:

Meshes.jl/src/winding.jl

Lines 44 to 65 in 4965450

function winding(points, mesh::Mesh)
assertion(paramdim(mesh) == 2, "winding number only defined for surface meshes")
(eltype(mesh) <: Triangle) || return winding(points, simplexify(mesh))
function w(p)
= sum(1:nelements(mesh)) do i
v = vertices(mesh[i])
a⃗ = v[1] - p
b⃗ = v[2] - p
c⃗ = v[3] - p
a = norm(a⃗)
b = norm(b⃗)
c = norm(c⃗)
n = det([a⃗ b⃗ c⃗])
d = a * b * c + (a⃗ b⃗) * c + (b⃗ c⃗) * a + (c⃗ a⃗) * b
2atan(n, d)
end
/ oftype(∑, 4π)
end
[w(p) for p in points]
end

I am opening the issue in case someone wants to give it a try.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions