Skip to content

Slow assembly of mixed Gram matrices #212

Open

Description

@sbadrian

There seem to be an issue with the assembly of mixed Gram matrices:

Γ = meshsphere(1.0, 0.01)
X = lagrangecxd0(Γ)
Y = duallagrangec0d1(Γ)
@time Gyy = assemble(BEAST.Identity(), Y, Y)
@time Gyx = assemble(BEAST.Identity(), X, Y)

For Gyy, I took around 6 seconds, while it needed 84 seconds for Gyx. If I refine further, assembling Gyx takes forever.

The same is true in the 2D case.

Activity

  1. krcools commented on Aug 18, 2026

    @krcools
    Owner

    I got 14 seconds for Gyy, 190 seconds for Gyx. For Gyx, it the mixed mesh algorithm is used, which uses an octree for collision detection. This is probably what makes it slower. Would need to profile to see if there is type instability or allocations that can be avoided here...

  2. paresula commented on Oct 6, 2026

    @paresula
    Contributor

    I think I stumbled across the cause, it comes down to the argument order. I measure

    @time Gyy = assemble(BEAST.Identity(), Y, Y) # 11 s
    @time Gyx = assemble(BEAST.Identity(), X, Y) # 151 s
    @time Gxy = assemble(BEAST.Identity(), Y, X) # 19 s

    So it comes down to argument order: in assemble!(biop::LocalOperator,...), it is checked whether the test geometry is a refinement of the trial geometry, but not the other way around - so the Gxy case takes the refines path, while the Gyx case takes the slower mixed path.

    This could be solved by also checking the other way around and adding a function assemble_local_trialrefines! that mirrors assemble_local_refines!.
    If you want, I can write it up and create a pull request if it works as I expect.

    For unrelated meshes, this would of course not help, but here for the actual refinement on the sphere, it should solve the problem.

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions