# Getting markers for cells

**URL:** https://fenicsproject.discourse.group/t/getting-markers-for-cells/14304
**Category:** General
**Tags:** mesh
**Created:** [April 17, 2024, 1:18pm UTC](https://fenicsproject.discourse.group/t/getting-markers-for-cells/14304 "2024-04-17T13:18:31Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![Jesus\_Vellojin](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/jesus_vellojin/32/6485_2.png) [@Jesus\_Vellojin](https://fenicsproject.discourse.group/u/Jesus_Vellojin)
#### Post date: [April 17, 2024, 1:59pm UTC](https://fenicsproject.discourse.group/t/getting-markers-for-cells/14304/2 "2024-04-17T13:59:35Z")

</div>

Hi.

It is not clear what version of FEniCS you are using and there is no MWE.

For DOLFINx you can check, among others,

[https://fenicsproject.discourse.group/t/mesh-refinement-in-dolfinx/11733/2](https://fenicsproject.discourse.group/t/mesh-refinement-in-dolfinx/11733/2)

For DOLFINx, the marking is performed over the edges belonging to a desired cell criterion. Maybe @dokken can explain further.

For Legacy DOLFIN you can check, among others,

[https://fenicsproject.discourse.group/t/mesh-refinement-not-working/3199/3](https://fenicsproject.discourse.group/t/mesh-refinement-not-working/3199/3)  
[https://fenicsproject.discourse.group/t/mesh-refinement-adapt-vs-refine/8711/4](https://fenicsproject.discourse.group/t/mesh-refinement-adapt-vs-refine/8711/4)

Here, the markers are stored as booleans in a `MeshFunction`. Hence, you can access the markers by iterating over the cells:

```auto
"""
Taken from https://fenicsproject.discourse.group/t/mesh-refinement-adapt-vs-refine/8711/4

"""
from dolfin import *
import matplotlib.pyplot as plt

n_elem = 1
n_ref = 2
mesh = UnitSquareMesh(n_elem, n_elem, "crossed")
Praf = Point(0.20981, 0.10987652, 0.0)

fig, axs = plt.subplots(nrows=n_ref+1, ncols=1, constrained_layout=True)

plt.sca(axs[0])
plot(mesh)
plt.scatter(Praf.x(), Praf.y())

for i_ref in range(n_ref):
    print("-------------------------------------")
    print("Refinement "+str(i_ref))
    print("-------------------------------------")
    print(" ")
    markers = MeshFunction("bool", mesh, mesh.topology().dim(), False)
    for cell in cells(mesh):
        markers[cell] = cell.contains(Praf)
        if markers[cell]:
            print(cell.get_vertex_coordinates())
        print(markers[cell])

```

---

_[View the full topic](https://fenicsproject.discourse.group/t/getting-markers-for-cells/14304)._
