FEniCS / ufl

UFL - Unified Form Language
https://fenicsproject.org
GNU Lesser General Public License v3.0
97 stars 64 forks source link

`FormSum.coefficients` should be ordered deterministically the same as `Form.coefficients` #243

Closed JHopeCollins closed 9 months ago

JHopeCollins commented 10 months ago

Form.coefficients() and FormSum.coefficients() both use set to produce a unique collection of the coefficients. However, set does not have deterministic ordering. Form._analyze_form_arguments() uses sorted to make sure that the ordering is deterministic across MPI ranks and across multiple programme executions, but FormSum._analyze_form_arguments() doesn't.

This means that the ordering is sometimes different between different MPI ranks, which causes parallel hangs in MG code when a Function is sent to inject on one rank and a Cofunction is sent to restrict on another rank.

This PR just adds orders FormSum.coefficients() in the same way as Form.coefficients()