Skip to content

Performance of current getindex #42

@maltezfaria

Description

@maltezfaria

Description

When profiling a 3d Zalesak example, I see loads of time being spent in the _getindexrec function. In particular, time is spent trying to decide whether an index is near the boundary or not, so that we know if a boundary condition is needed. We should probably split the main loop into:

  • loop over internal nodes, where we can just fetch the index normally
  • loop over boundary nodes, where the fancy _getindexrec is needed

For what is worth, here is a snapshot of the profile:

Screenshot 2024-11-13 at 17 27 21

and the code that can be used to generate it:

using LevelSetMethods, StaticArrays
grid = CartesianGrid((-1, -1, -1), (1, 1, 1), (50, 50, 50))
center = (-1 / 3, 0, 0)
radius = 0.5
disk = LevelSetMethods.sphere(grid; center, radius)
rec = LevelSetMethods.rectangle(
    grid;
    center = center .+ (0, radius, 0),
    width = (1 / 3, 1.0, 2),
)
ϕ = setdiff(disk, rec)
eq = LevelSetEquation(;
    levelset = ϕ,
    terms = AdvectionTerm((x, t) -> π * SVector(-x[2], x[1], 0)),
    bc = NeumannBC(),
)
@profview  integrate!(eq, 0.2) # from VScode, otherwise use @profile

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