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.
Describe the bug
compute_field_offsetsinMultiFieldFESpaces.jlapplies the forward permutation when recovering per-field offsets forBlockMultiFieldStyle.During construction of a
MultiFieldFESpacewith a non-identity permutationP, block offsets are first computed following the block ordering induced by the permutation. However, the final offsets returned bycompute_field_offsetsmust correspond to the original field ordering.The current implementation uses:
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.