Define a marker on a subset of a boundary

Dear all,

I need to compute an inner product in a specific subset of a boundary. Please see the image below.

The red line is the part of the upper boundary where I want to calculate the desired quantity. Therefore, I need to define a measure, let us say dSubBoundary, defined just on that red line. Following Joergen Tutorial Cylinder, I guess it would be something like:

dSubBoundary = Measure("ds", domain=mesh, subdomain_data=ft, subdomain_id=redline_marker)

However, I do not know if it is possible to define a marker just in a part of a boundary.
Does anybody know if this is possible? If not, is there any other way of doing it?

Many thanks in advance!

You can easily do this as shown in: Test problem 2: Flow past a cylinder (DFG 2D-3 benchmark) — FEniCSx tutorial

When reading data into DOLFINx, it creates a MeshTags object, that does not need to include all facets of the mesh.

Thanks for the quick reply.

But, in Test problem 2: Flow past a cylinder (DFG 2D-3 benchmark) — FEniCSx tutorial, dObs is defined over the full surface of the cylinder. In my case, the red line where I want to define dSubBoundary is not the entire upper boundary. What if, for example, you want to define dObs over just the half of its surface?

Thanks again.

You can do this in GMSH (preferrable if your object is defined with it as an explicit surface). If you cannot do the marking in gmsh, you could find the facets satisfying some geometrical condition, i.e. use dolfinx.mesh.locate_entities_boundary(mesh, mesh.topology.dim-1, lambda x: some geometric requirement) and use these facets to create a meshtag object