# Defining subdomains for two different materials

**URL:** <https://fenicsproject.discourse.group/t/defining-subdomains-for-two-different-materials/2243>\
**Category:** mesh\
**Created:** [January 18, 2020, 6:11pm UTC](https://fenicsproject.discourse.group/t/defining-subdomains-for-two-different-materials/2243 "2020-01-18T18:11:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jaouane\_Mohammed](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/jaouane_mohammed/32/1133_2.png) [@Jaouane\_Mohammed](https://fenicsproject.discourse.group/u/Jaouane_Mohammed)\
**Post date:** [January 18, 2020, 6:11pm UTC](https://fenicsproject.discourse.group/t/defining-subdomains-for-two-different-materials/2243/1 "2020-01-18T18:11:26Z")

</div>

![2020-01-18_180456](https://global.discourse-cdn.com/free1/uploads/fenicsproject1/original/1X/a1e4b53f84e3e6bd0adb6c433284e61f34780adf.png)  
How I can defining subdomains for two different materials ?

---

<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:** [January 18, 2020, 6:32pm UTC](https://fenicsproject.discourse.group/t/defining-subdomains-for-two-different-materials/2243/2 "2020-01-18T18:32:40Z")

</div>

This can either be done with a geometrical description, as shown in this tutorial: [https://fenicsproject.org/docs/dolfin/1.4.0/python/demo/documented/subdomains-poisson/python/documentation.html](https://fenicsproject.org/docs/dolfin/1.4.0/python/demo/documented/subdomains-poisson/python/documentation.html)

You can Also use a gmesh to define the cell function, and load it as described here:

> [@Transitioning from mesh.xml to mesh.xdmf, from dolfin-convert to meshio](https://fenicsproject.discourse.group/t/transitioning-from-mesh-xml-to-mesh-xdmf-from-dolfin-convert-to-meshio/412/7):
>
> As you can see in the code snippet above, I first read the boundary data to the file mf.xdmf. this is equivalent to facet\_region.xml. For the cellfunction: meshio.write("cf.xdmf", meshio.Mesh( points=msh.points, cells={"tetra": msh.cells["tetra"]}, cell\_data={"tetra": {"name\_to\_read": msh.cell\_data["tetra"]["gmsh:physical"]}})) mvc = MeshValueCollection("size\_t", mesh, 3) with XDMFFile("cf.xdmf") as infile: infile.read(mvc, "name\_to\_read") cf = cpp.mesh.…

---

<div class="post-metadata">

**Author:** ![Jaouane\_Mohammed](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/jaouane_mohammed/32/1133_2.png) [@Jaouane\_Mohammed](https://fenicsproject.discourse.group/u/Jaouane_Mohammed)\
**Post date:** [January 18, 2020, 6:50pm UTC](https://fenicsproject.discourse.group/t/defining-subdomains-for-two-different-materials/2243/3 "2020-01-18T18:50:11Z")

</div>

Thank you very much.
