Geometrical Derivatives

The geometrical differentiation capabilities are based on the following work:

Reference

"Level-set topology optimisation with unfitted finite elements and automatic shape differentiation", by Z. J. Wegert, J. Manyer, C. Mallon, S. Badia, V. J. Challis (2025)

To see examples of usage, please refer to the tests in test/LevelSetCuttersTests/GeometricalDifferentiationTests.jl.

Discretize then differentiate

GridapEmbedded.Interfaces.CutFaceBoundaryTriangulationType
struct CutFaceBoundaryTriangulation{Di,Df,Dp} <: Triangulation{Di,Dp}

Triangulation containing the interfaces between subfacets. We always have dimensions

  • Dc :: Dimension of the background mesh
  • Df = Dc-1 :: Dimension of the cut subfacets
  • Di = Dc-2 :: Dimension of the subfacet interfaces

Properties

  • face_trian :: Original SubFacetTriangulation, built on top of the background mesh.
  • face_model :: Subfacet model. Active model for face_trian.
  • face_boundary :: Triangulation of the interfaces between subfacets. It is glued to the face_model.
  • cell_boundary :: Conceptually the same as face_boundary, but it is glued to the background mesh cells. Created as a CompositeTriangulation between face_trian and face_boundary.
  • ghost_boundary :: Triangulation of the background facets that contain each interface.

The "real" triangulation is cell_boundary, but we require the other triangulations to perform complex changes of domain. Most of the Triangulation API is delegated to cell_boundary.

Constructors

Boundary(face_trian::SubFacetTriangulation)
Skeleton(face_trian::SubFacetTriangulation)
source
GridapEmbedded.Interfaces.get_ghost_maskMethod
get_ghost_mask(
  face_trian::SubFacetTriangulation{Df,Dc},
  face_model = get_active_model(face_trian)
) where {Df,Dc}

Returns a mask for ghost faces. We define ghost faces as the interfaces between two different cut facets that are located in different background cells.

The second condition is important: In 3D, some cuts subcells may not be simplices. In this case, we simplexify the subcell. This creates extra cut interfaces that are interior to a background cell. These are not considered ghost faces.

  • In 2D: Dc = 2, Df = 1 -> Ghost faces have dimension 0 (i.e interface points)
  • In 3D: Dc = 3, Df = 2 -> Ghost faces have dimension 1 (i.e interface edges)
source

Autodiff

GridapEmbedded.LevelSetCutters.DifferentiableTriangulationType
mutable struct DifferentiableTriangulation{Dc,Dp} <: Triangulation{Dc,Dp}

A DifferentiableTriangulation is a wrapper around an embedded triangulation (i.e SubCellTriangulation or SubFacetTriangulation) implementing all the necessary methods to compute derivatives w.r.t. deformations of the embedded mesh.

To do so, it propagates dual numbers into the geometric maps mapping cut subcells/subfacets to the background mesh.

Constructor:

DifferentiableTriangulation(trian::Triangulation,fe_space::FESpace)

where trian must be an embedded triangulation and fe_space is the FESpace where the level-set function lives.

source
GridapEmbedded.LevelSetCutters.precompute_cut_edge_idsMethod
precompute_cut_edge_ids(rcoords,bg_rcoords,edge_list)

Given

  • rcoords: the node ref coordinates of the cut subcell/subfacet,
  • bg_rcoords: the node ref coordinates of the background cell containing it,
  • edge_list: the list of nodes defining each edge of the background cell,

this function returns a vector that for each node of the cut subcell/subfacet contains

  • -1 if the node is also a node of the background cell,
  • the id of the edge containing the node otherwise.
source