# Assigning different physical groups to different color in gmsh and mark them as different material in fenics

**URL:** <https://fenicsproject.discourse.group/t/assigning-different-physical-groups-to-different-color-in-gmsh-and-mark-them-as-different-material-in-fenics/11347>\
**Category:** General\
**Created:** [May 30, 2023, 6:07pm UTC](https://fenicsproject.discourse.group/t/assigning-different-physical-groups-to-different-color-in-gmsh-and-mark-them-as-different-material-in-fenics/11347 "2023-05-30T18:07:50Z")\
**Posts on this page:** 1\
**Showing post:** 25

<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:** [May 31, 2023, 7:42pm UTC](https://fenicsproject.discourse.group/t/assigning-different-physical-groups-to-different-color-in-gmsh-and-mark-them-as-different-material-in-fenics/11347/25 "2023-05-31T19:42:49Z")

</div>

See:

> [@How to define a subdomain using material data (from data file)?](https://fenicsproject.discourse.group/t/how-to-define-a-subdomain-using-material-data-from-data-file/11055/4):
>
> First of all, does your mesh consist of triangles or quadrilaterals? Secondly, is your mesh uniform and structured (i.e. is it a RectangleMesh with 100 x 100 cells?) I would suggest something like: from dolfin import \* import numpy as np mesh = UnitSquareMesh(100, 100) V = FunctionSpace(mesh, "DG", 0) u = Function(V) dx = 1/100 values = np.arange(100\*100) local\_values = np.zeros\_like(u.vector().get\_local()) for cell in cells(mesh): midpoint = cell.midpoint().array() i = int(midpoi…

Which writes the data to a function, Which you can write to xdmf

---

_[View the full topic](https://fenicsproject.discourse.group/t/assigning-different-physical-groups-to-different-color-in-gmsh-and-mark-them-as-different-material-in-fenics/11347)._
