Skip to content

compute_field_offsets applies forward permutation instead of inverse in BlockMultiFieldStyle #1231

@anusha19murthy

Description

@anusha19murthy

Describe the bug

compute_field_offsets in MultiFieldFESpaces.jl applies the forward permutation when recovering per-field offsets for BlockMultiFieldStyle.

During construction of a MultiFieldFESpace with a non-identity permutation P, block offsets are first computed following the block ordering induced by the permutation. However, the final offsets returned by compute_field_offsets must correspond to the original field ordering.

The current implementation uses:

offsets = map(p -> block_offsets[p], P)

which applies the forward permutation to block_offsets.

Since block_offsets already follows the permuted block ordering, recovering offsets per field requires applying the inverse permutation. Using the forward permutation incorrectly reorders offsets between fields.

As a consequence, offsets associated with one field may be assigned to another field.

Impact

Field offsets are later used by _restrict_to_field to extract each field’s DOF slice from the global block vector.

When offsets are incorrect:

fields may read DOF ranges belonging to other fields

DOF slices can overlap or become swapped

assembly and linear/nonlinear solves complete without errors

resulting solutions silently contain swapped or corrupted field values

This produces incorrect numerical results in multifield simulations using BlockMultiFieldStyle with explicit permutations.

The failure is silent and particularly difficult to detect since solver convergence is unaffected.

Affected file
src/MultiField/MultiFieldFESpaces.jl

Possible fix

Recover offsets using the inverse permutation instead of the forward permutation.

Replace:

offsets = map(p -> block_offsets[p], P)

with:

Pinv = invperm(P)
offsets = map(p -> block_offsets[p], Pinv)

This ensures offsets correspond to the correct field ordering and prevents incorrect DOF extraction across fields.

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