Skip to content

Refactor parent->submesh interpolation - #262

Merged
jorgensd merged 5 commits into
scientificcomputing:mainfrom
jorgensd:dokken/interpolate-from-surface-submesh
Sep 26, 2026
Merged

jorgensd merged 5 commits into
scientificcomputing:mainfrom
jorgensd:dokken/interpolate-from-surface-submesh

Conversation

@jorgensd

@jorgensd jorgensd commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

New features

  • New convenience function, compute_entity_closure_permutations: given a function space, an entity dimension and a subset of (cell, local entity index) pairs, compute the inverse subentity closure permutation for all these entities. This is done in groups by (local entity index, cell permutation info), so each permutation is computed only once per group, instead of once per (cell, local entity) pair.
  • compute_entity_closure_dofs: permute the dofmap of the subset of entities into each entity's own orientation. For facets, this matches the facet submesh.
  • Create the inverse, interpolation from the submesh (subentity) to the parent mesh, as SurfaceSubmeshExtension and interpolate_from_surface_submesh. It is extended with zero on all dofs that are not on the facet closures.
    • It doesn't use DOLFINX interpolate, as a vertex (or edge) of a parent cell can lie on the submesh without lying on any of that cell's own facets in the submesh, and interpolate would then set it to zero.
    • It requires a continuous volume space.
      • For Lagrange (identity interpolation matrix), the surface function is evaluated at the volume nodes on each facet.
      • For Piola-mapped spaces (e.g. RT, N1curl, in 2D and 3D), the pulled-back surface function is evaluated on the parent facets through entity_maps, and only the facet trace is set (the normal component for H(div), the tangential one for H(curl)).
    • Shared dofs are averaged over their writes, also across processes. For a compatible surface space this gives the value; for a discontinuous one, the average.
  • The inverse pullback lives in scifem.ufl_compat, which uses apply_inverse from Give each pull back an inverse FEniCS/ufl#511 when the installed UFL has it. The Piola Expressions (one per facet permutation) are compiled per process on MPI.COMM_SELF, and the facet interpolation points come from pull_back_to_reference_facet, which is now shared with interpolate_function_onto_facet_dofs

Refactor

  • Update interpolate_function_onto_facet_dofs to do fewer loops. Previously, evaluation was done once per marked facet. Now all marked facets with a specific facet permutation are evaluated at once, independent of their local facet index. Should speed things up dramatically at the cost of a slight memory increase.
  • Move interpolation to the submesh into a class, SurfaceSubmeshInterpolation, that caches the compiled expression, connectivities and cell permutation info. For DOLFINx < 0.11 it also caches the closure permutations, and uses them instead of the previous per-entity loop. interpolate_to_surface_submesh is now a wrapper around the class.

Compat

  • Add compat function for compute_integration_domains for multiple versions of DOLFINx, and use it in scifem.mesh instead of the inline version check.
  • Add compat function for create_cell_permutations for multiple versions of DOLFINx.

General utils

  • Add a general group_by_key function that computes the unique keys and how to extract the entries of each key in order afterwards. For now it is used on the facet permutations in interpolate_function_onto_facet_dofs, and on (local entity index, cell permutation info) pairs in compute_entity_closure_permutations.

Documentation

  • Document the facet-submesh functions in the API reference and README.

@jorgensd
jorgensd merged commit 159367f into scientificcomputing:main Sep 26, 2026
8 checks passed
@jorgensd
jorgensd deleted the dokken/interpolate-from-surface-submesh branch September 26, 2026 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant