# Define a marker on a subset of a boundary

**URL:** <https://fenicsproject.discourse.group/t/define-a-marker-on-a-subset-of-a-boundary/9724>\
**Category:** General\
**Created:** [November 10, 2022, 12:24pm UTC](https://fenicsproject.discourse.group/t/define-a-marker-on-a-subset-of-a-boundary/9724 "2022-11-10T12:24:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JLorenteMacias](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/jlorentemacias/32/4742_2.png) [@JLorenteMacias](https://fenicsproject.discourse.group/u/JLorenteMacias)\
**Post date:** [November 10, 2022, 12:24pm UTC](https://fenicsproject.discourse.group/t/define-a-marker-on-a-subset-of-a-boundary/9724/1 "2022-11-10T12:24:12Z")

</div>

Dear all,

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

 ![Channel_Boundary](https://global.discourse-cdn.com/free1/uploads/fenicsproject1/original/2X/f/fdc40c9e8fc06c1b203426eb31445016cbf1261c.png)

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](https://jorgensd.github.io/dolfinx-tutorial/chapter2/ns_code2.html), I guess it would be something like:

```auto
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!

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [November 10, 2022, 12:50pm UTC](https://fenicsproject.discourse.group/t/define-a-marker-on-a-subset-of-a-boundary/9724/2 "2022-11-10T12:50:30Z")

</div>

You can easily do this as shown in: [Test problem 2: Flow past a cylinder (DFG 2D-3 benchmark) — FEniCSx tutorial](https://jorgensd.github.io/dolfinx-tutorial/chapter2/ns_code2.html#verification-of-the-implementation-compute-known-physical-quantities)

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

---

<div class="post-metadata">

**Author:** ![JLorenteMacias](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/jlorentemacias/32/4742_2.png) [@JLorenteMacias](https://fenicsproject.discourse.group/u/JLorenteMacias)\
**Post date:** [November 10, 2022, 1:11pm UTC](https://fenicsproject.discourse.group/t/define-a-marker-on-a-subset-of-a-boundary/9724/3 "2022-11-10T13:11:05Z")

</div>

Thanks for the quick reply.

But, in [Test problem 2: Flow past a cylinder (DFG 2D-3 benchmark) — FEniCSx tutorial](https://jorgensd.github.io/dolfinx-tutorial/chapter2/ns_code2.html#verification-of-the-implementation-compute-known-physical-quantities), `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.

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [November 10, 2022, 1:14pm UTC](https://fenicsproject.discourse.group/t/define-a-marker-on-a-subset-of-a-boundary/9724/4 "2022-11-10T13:14:09Z")

</div>

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
