General concepts » Connectivity

Understanding mesh connectivity in Rodin.

Introduction

Connectivity (or incidence) information describes how the polytopes (vertices, edges, faces, cells) in a mesh relate to each other. In Rodin, this is managed by the Connectivity class, which is accessed through Mesh::getConnectivity().

Connectivity is essential for:

  • Identifying boundary entities for imposing boundary conditions
  • Traversing mesh topology during assembly
  • Finding neighbors and adjacencies

Notation

Connectivity is described as a relation between polytopes of dimension $ d_1 $ and dimension $ d_2 $ . We write this as the $ (d_1, d_2) $ -connectivity.

For a 2D triangular mesh:

  • $ d = 2 $ (cells are triangles)
  • $ d = 1 $ (edges)
  • $ d = 0 $ (vertices)

Common connectivity relations:

RelationMeaningUse case
$ (0, 2) $ Vertices → CellsWhich cells share a vertex
$ (1, 2) $ Edges → CellsBoundary detection (edges with 1 cell)
$ (2, 0) $ Cells → VerticesCell vertex lookup
$ (2, 1) $ Cells → EdgesCell edge lookup

Computing connectivity

Connectivity relations are computed on demand using the compute() method.

Mesh mesh;
mesh = mesh.UniformGrid(Polytope::Type::Triangle, {16, 16});

// Compute edge-to-cell connectivity (required for boundary detection)
mesh.getConnectivity().compute(1, 2);

Computation modes

The compute() method accepts an optional mode parameter that controls how sub-entities are handled:

ModeBehavior
Connectivity::Mode::Discover (default)Creates any missing sub-polytopes that are needed for the relation. For example, computing $ (1, 2) $ on a triangle mesh will create edge entities if they do not yet exist.
Connectivity::Mode::RestrictRestricts the relation to existing polytopes. Entity creation remains under the control of the mesh builder.
// Default mode: discovers (creates) edges if needed
mesh.getConnectivity().compute(1, 2);

// Restrict mode: only uses existing entities
mesh.getConnectivity().compute(1, 2, Connectivity::Mode::Restrict);

The default Discover mode constructs the sub-polytopes required by each requested relation.

Boundary detection

Once the $ (d-1, d) $ connectivity is computed (where $ d $ is the mesh dimension), Rodin can identify boundary entities — those that are incident to exactly one cell. This is how DirichletBC finds the boundary DOFs automatically.

  P1 vh(mesh);
  TrialFunction u(vh);
  TestFunction v(vh);
  RealFunction f = 1;

  Problem poisson(u, v);
  poisson = Integral(Grad(u), Grad(v)) - Integral(f, v) + DirichletBC(u, Zero());

Boundary attributes

Different parts of the boundary can be distinguished by attributes (integer labels). This is useful when different boundary conditions are applied to different segments.

Attribute GammaD = 2, GammaN = 3;

// Apply Dirichlet BC only on boundary with attribute GammaD
DirichletBC(u, Zero()).on(GammaD)

// Apply Neumann BC only on boundary with attribute GammaN
BoundaryIntegral(g, v).over(GammaN)

Boundary attributes are typically set when loading a mesh from a file or when building a mesh programmatically.

See also