# Problem with subdomains

**URL:** <https://fenicsproject.discourse.group/t/problem-with-subdomains/5076>\
**Category:** Uncategorized\
**Created:** [February 11, 2021, 1:09am UTC](https://fenicsproject.discourse.group/t/problem-with-subdomains/5076 "2021-02-11T01:09:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sambou-manu](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/sambou-manu/32/1080_2.png) [@sambou-manu](https://fenicsproject.discourse.group/u/sambou-manu)\
**Post date:** [February 11, 2021, 1:09am UTC](https://fenicsproject.discourse.group/t/problem-with-subdomains/5076/1 "2021-02-11T01:09:33Z")

</div>

Hi there.  
I have a problem for define a subdomain .  
The domain is a square. There are 5 subdomains :  
-One rectangle  
-and four cicles

 ![image](https://global.discourse-cdn.com/free1/uploads/fenicsproject1/original/2X/3/364d4053a4a8699043097bdcd63adf73a5547c28.jpeg)

The four small circles have a radius of 0.05 and the coordonate of their center are (±0.75 , ±0.75)

When i use the following code for the mesh, i jsut see the square and not other subdomains.  
Idon’t know what is the problem

the whole code is :

‘’’  
import matplotlib.pyplot as plt  
from fenics import \*  
from dolfin import \*  
import numpy as np  
from mshr import\*  
Rectangle = Polygon( [Point(-0.50, 0.20),Point(-0.50, -0.20),Point(0.50, -0.20),Point(0.50, 0.20)])  
p0 = Point(np.array([-0.750, 0.750]))  
p1 = Point(np.array([-0.750, -0.750]))  
p2 = Point(np.array([0.750, -0.750]))  
p3 = p0 = Point(np.array([0.750, 0.750]))  
c0 = Circle(p0,0.05)  
c1 = Circle(p1,0.05)  
c2 = Circle(p2,0.05)  
c3 = Circle(p3,0.05)  
arre = Polygon( [Point(1.0, 1.0),Point(-1.0, 1.0),Point(-1.0, -1.0),Point(1.0, -1.0)])  
carre.set\_subdomain(1, Rectangle)  
carre.set\_subdomain(2, c0)  
carre.set\_subdomain(3, c1)  
carre.set\_subdomain(4, c2)  
carre.set\_subdomain(5, c3)  
resolution =0.55  
mesh = generate\_mesh(carre,resolution)  
plt.figure(figsize=(20, 8))  
plot(mesh, title=“Mesh”)

‘’’

---

<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:** [February 11, 2021, 8:35am UTC](https://fenicsproject.discourse.group/t/problem-with-subdomains/5076/2 "2021-02-11T08:35:29Z")

</div>

Mshr is no longer maintained, and I would strongly encourage you to use another meshing software, such as [GMSH](http://gmsh.info/) (GUI or python API) or [pygmsh](https://github.com/nschloe/pygmsh) (python API).  
GMSH has their own set of tutorials at [tutorial · master · gmsh / gmsh · GitLab](https://gitlab.onelab.info/gmsh/gmsh/-/tree/master/tutorial).  
I have also made several tutorial for pygmsh and gmsh, that can be found at [Tutorials | Jørgen S. Dokken](https://jsdokken.com/tutorials.html)  
and some more advanced gmsh tutorials at [Electromagnetics example — FEniCS-X tutorial](https://jorgensd.github.io/dolfinx-tutorial/chapter3/em.html)
