Skip to content

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FEniCSx Submesh & Interface Tutorial

This small tutorial demonstrates how to work with global meshes, submeshes, tags, and interface integrals in DOLFINx (FEniCSx). The goal is to provide a minimal and transparent setup that helps debug multi-domain problems such as fluid–structure interaction (FSI).

The script intentionally focuses on understanding the mesh infrastructure before adding physics.


What the tutorial demonstrates

The example walks through the following steps.

1. Create a global mesh

A rectangular domain is generated and divided into two regions (left and right).

(0,1) ------------------------
      |           |          |
      |           |          |
(0,0) ------------------------
              x = 0.5

The mesh specifically generated in submesh_tutorial.py using

Nx, Ny, Lx, Ly  = 4, 2, 2.0, 1.0

domain = mesh.create_rectangle(comm,
                               [[0.0, 0.0], [Lx, Ly]],
                               [Nx, Ny],
                               cell_type=mesh.CellType.triangle)

looks as follows:

Numbered mesh (if not visible, just click the text.)

Mesh, submeshes with numbering

2. Tag cells and facets

  • Cell tags define the two subdomains.
  • Facet tags identify the internal interface.

3. Define measures

Custom measures are created for

  • left domain
  • right domain
  • interface

This allows integration over specific regions of the mesh.

5. Create submeshes

Two submeshes are extracted from the global mesh:

  • left_mesh
  • right_mesh

Each submesh has its own numbering of cells, facets, and vertices, independent of the parent mesh.

6. Verify consistency via integration

Simple linear functions are interpolated on the meshes and integrated over

  • global subdomains
  • submeshes
  • the interface

The results should match, confirming that tags, measures, submesh mappings are correctly defined.

Why this tutorial exists

When working with multi-domain problems in FEniCSx it is common to run into confusion about

  • mesh entity numbering
  • mesh tags
  • submesh mappings
  • interface measures

This example provides a minimal debugging reference.

Typical issues it helps diagnose include

  • integrals returning zero
  • incorrect interface detection
  • mismatched submesh numbering
  • wrong tag propagation.

Key concepts illustrated

Mesh entities

FEniCSx assigns internal indices for

  • vertices
  • facets
  • cells

These indices are local to each mesh.

MeshTags

Tags are stored in a separate object:

MeshTags
 ├─ indices
 └─ values

Meaning

 entity_index → tag_value

Important: Tags belong to the mesh that created them.

Parent mesh indices and submesh indices are therefore different.

Submeshes

Submeshes provide

submesh cell → parent cell
submesh vertex → parent vertex

These mappings are essential when reconstructing tags or coupling fields across meshes.

Interface detection

Interior interfaces are detected using

  • facet tags
  • facet–cell connectivity
  • geometric checks (facet midpoints).

This is crucial for FSI and multi-physics coupling. Topology based interface detection is preferred, since it is not affected by round-off errors or geometric changes due to deformation.

Diagnostic utility

The tutorial includes a helper function that prints

  • number of mesh entities
  • connectivity relations
  • parent–submesh mappings
  • facet midpoints
  • boundary vs interior facets.

This significantly simplifies debugging.

Additional utilities

There are two additional helper functions for

  • Submesh facet mappings
  • Visualizing a mesh or submesh using PyVista together with node, cell and facet numberings

with own README files. These functions can be independent of this tutorial.

Typical applications

This template is useful for

  • fluid–structure interaction
  • multi-material elasticity
  • coupled PDE systems
  • Nitsche or mortar coupling
  • domain decomposition methods.

Requirements

  • Python 3
  • NumPy
  • MPI
  • DOLFINx / FEniCSx
  • UFL

Run the example

python submesh_tutorial.py

About

Demonstrates use of meshes and submeshes, useful for instance for FSI

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages