# Definition of the subdomain error

**URL:** <https://community.freefem.org/t/definition-of-the-subdomain-error/1572>\
**Category:** General Discussion\
**Created:** [March 4, 2022, 10:58am UTC](https://community.freefem.org/t/definition-of-the-subdomain-error/1572 "2022-03-04T10:58:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rayhanai](https://avatars.discourse-cdn.com/v4/letter/r/ed8c4c/32.png) [@rayhanai](https://community.freefem.org/u/rayhanai)\
**Post date:** [March 4, 2022, 10:58am UTC](https://community.freefem.org/t/definition-of-the-subdomain-error/1572/1 "2022-03-04T10:58:44Z")

</div>

Hello fellow users,

I’m looking to create a mesh using a boundary from the alphabet R. I have successfully created the border geometry using respective parametric equations as shown in the picture and plot it.

My problem is when I used the function

> mesh Th = buildmesh(…);

using the same equations, it gives me this error:

`FreeFem++ v4.1 (Sat, Nov 13, 2021 7:40:01 PM - git v4.10)  
file : D:\Documents\Docs\Semester 8\Fenomena Transpor di Biomedika\Kuliah 6\r.edp  
Load: lg\_fem lg\_mesh lg\_mesh3 eigenvalue  
1 : // outer border  
2 : border v1(t=0,5.5){ x=0; y=t; label=1;};  
3 : border h1(t=0,4){ x=t; y=5.5; label=2;};  
4 : border c1(t=pi/2,-pi/2){ x=1.75_cos(t)+4; y=1.75_sin(t)+3.75; label=3;};  
5 : border d2(t=4,5){ x=t; y=-2_t+10; label=4;};  
6 : border h4(t=5,3.5){ x=t; y=0; label=5;};  
7 : border d1(t=3.5,2.5){ x=t; y=-2_t+7; label=6;};  
8 : border h3(t=2.5,1.5){ x=t; y=2; label=7;};  
9 : border v2(t=2,0){ x=1.5; y=t; label=8;};  
10 : border h2(t=1.5,0){ x=t; y=0; label=9;};  
11 : // inner border  
12 : border v3(t=3,4.5){ x=1.5; y=t; label=10;};  
13 : border h6(t=1.5,3.5){ x=t; y=4.5; label=11;};  
14 : border c2(t=pi/2,-pi/2){ x=0.75_cos(t)+3.5; y=0.75_sin(t)+3.75; label=12;};  
15 : border h5(t=3.5,1.5){ x=t; y=3; label=13;};  
16 :  
17 : int n=20;  
18 : mesh Th =buildmesh(v1(n)+h1(n)+c1(n)+d2(n)+h4(n)+d1(n)+h3(n)+v2(n)+h2(n)+v3(-n)+h6(-n)+c2(-n)+h5(-n));  
19 : plot(Th,wait=1);  
20 : sizestack + 1024 =1472 ( 448 )

Error in the definition of subdomain 4 boundary border 9/13: wrong direction 80 1  
Error in the definition of subdomain 5 boundary border 8/13: wrong direction 100 1  
Error in the definition of subdomain 6 boundary border 7/13: wrong direction 120 1  
Error in the definition of subdomain 7 boundary border 6/13: wrong direction 140 1  
Error in the definition of subdomain 8 boundary border 5/13: wrong direction 160 1  
Error in the definition of subdomain 9 boundary border 4/13: wrong direction 180 1  
Error in the definition of subdomain 10 boundary border 3/13: wrong direction 200 1  
Error in the definition of subdomain 11 boundary border 2/13: wrong direction 220 1  
Error in the definition of subdomain 12 boundary border 1/13: wrong direction 240 1  
Fatal error in the mesh generator 777  
current line = 2  
Meshing error: Bamg  
number : 777,  
catch Err bamg  
Meshing error: Bamg  
number : 777`

Where did I went wrong? The borders seems to have no problem for me, thanks in advance!

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/8/8093ead8acc93120108a7f9d7162cf47813c9765.png)

---

<div class="post-metadata">

**Author:** ![frederichecht](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/frederichecht/32/15_2.png) [@frederichecht](https://community.freefem.org/u/frederichecht)\
**Post date:** [March 4, 2022, 8:24pm UTC](https://community.freefem.org/t/definition-of-the-subdomain-error/1572/2 "2022-03-04T20:24:10Z")

</div>

Remenber in 2d the border see as in direct sens by default ( the domain must be a left of the orient  
border) or put a negative number of segment to reverse this rule.

THE CORRECTION

```auto
 border v1(t=0,5.5){ x=0; y=t; label=1;};
 border h1(t=0,4){ x=t; y=5.5; label=2;};
 border c1(t=pi/2,-pi/2){ x=1.75*cos(t)+4; y=1.75*sin(t)+3.75; label=3;};
 border d2(t=4,5){ x=t; y=-2*t+10; label=4;};
 border h4(t=5,3.5){ x=t; y=0; label=5;};
 border d1(t=3.5,2.5){ x=t; y=-2*t+7; label=6;};
 border h3(t=2.5,1.5){ x=t; y=2; label=7;};
 border v2(t=2,0){ x=1.5; y=t; label=8;};
 border h2(t=1.5,0){ x=t; y=0; label=9;};
 // inner border
 border v3(t=3,4.5){ x=1.5; y=t; label=10;};
 border h6(t=1.5,3.5){ x=t; y=4.5; label=11;};
 border c2(t=pi/2,-pi/2){ x=0.75*cos(t)+3.5; y=0.75*sin(t)+3.75; label=12;};
 border h5(t=3.5,1.5){ x=t; y=3; label=13;};

 int n=20;
 plot(v1(n)+h1(n)+c1(n)+d2(-n)+h4(n)+d1(n)+h3(n)+v2(n)+h2(n)+v3(-n)+h6(-n)+c2(-n)+h5(-n),wait=1);
 mesh Th =buildmesh(v1(-n)+h1(-n)+c1(-n)+d2(-n)+h4(-n)+d1(-n)+h3(-n)+v2(-n)+h2(-n)+v3(n)+h6(n)+c2(n)+h5(n));
 plot(Th,wait=1);

```
