# Create common label edges between two object

**URL:** <https://community.freefem.org/t/create-common-label-edges-between-two-object/1499>\
**Category:** General Discussion\
**Created:** [February 15, 2022, 1:53pm UTC](https://community.freefem.org/t/create-common-label-edges-between-two-object/1499 "2022-02-15T13:53:25Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Loic](https://avatars.discourse-cdn.com/v4/letter/l/e9c0ed/32.png) [@Loic](https://community.freefem.org/u/Loic)\
**Post date:** [February 15, 2022, 1:53pm UTC](https://community.freefem.org/t/create-common-label-edges-between-two-object/1499/1 "2022-02-15T13:53:25Z")

</div>

Hello all,

I have a coarse element (Object 1 in the attached picture) whose labels are 1, 2 and 3.

 ![explanation](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/1X/8475e35b53e4cc15716a49f471e2bc49ffc33680.png)

I have the same element with perforations (Object 2). In the Object 2, all edges have the Label 0.

I want that the common edges between Object 1 and Object 2 have the same label.

Could someone have an idea about the way to do this ?

Thank you in advance,

Best regards,

Loïc,

---

<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:** [February 17, 2022, 1:25pm UTC](https://community.freefem.org/t/create-common-label-edges-between-two-object/1499/2 "2022-02-17T13:25:09Z")

</div>

This is no so difficult  
let us call `Thc` the coarse mesh and `Thp` the mesh with perforation.

```auto
load "msh3"
meshL ThLc= extract(Thc); // border mesh 
fespace Ehc(Thc,P0Edge); // Constant fonction of edge 
Ehc ul = label+0.5; // get the label on the each boundary edge

Thp = change(Thp, flabel= dist(ThLc) < 1e-6 ? ul : 4) ; 

```

Now the label of Thp mesh are 1,2,3 of Coarse mesh border and 4 if not on border of ThLc (dist \> 1e-6)

---

<div class="post-metadata">

**Author:** ![Loic](https://avatars.discourse-cdn.com/v4/letter/l/e9c0ed/32.png) [@Loic](https://community.freefem.org/u/Loic)\
**Post date:** [February 17, 2022, 2:59pm UTC](https://community.freefem.org/t/create-common-label-edges-between-two-object/1499/3 "2022-02-17T14:59:17Z")

</div>

Hello @frederichecht ,

Thank you for your reply,

But it seems that this method does not work. I have this code :

```auto
  meshL THL= extract(THK); // border mesh
  meshL ThL=extract(ThK);
  fespace Ehc(THL,P0edge); // Constant fonction of edge
  Ehc ul = label+0.5; // get the label on the each boundary edge
  ThK = change(ThK, flabel= dist(THL) < 1e-6 ? ul : 4 ) ;

```

And I get this error:

```auto
 44 : meshL THL= extract(THK); // border mesh
   45 : meshL ThL=extract(ThK);
   46 : fespace Ehc(THL,P0edge); // Constant fonction of edge
   47 : Ehc ul = label+0.5; // get the label on the each boundary edge
   48 : ThK = change(ThK, flabel= dist(THL) error operator ( <PPKN5Fem2D5MeshLE> 
 List of choices 
	 ( <d> : <d>, <d> )
	 ( <d> : <d>, <d>, <d> )

 Error line number 48, in file ReadMeshMED.edp, before token )

```

Best regards,

Loïc,

---

<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:** [February 17, 2022, 5:37pm UTC](https://community.freefem.org/t/create-common-label-edges-between-two-object/1499/4 "2022-02-17T17:37:21Z")

</div>

I am sorry the dist function is really new (version 4.9)

So new how to say simply we are not on THL .

fespace WHK(THK,P1b); // p1 bubble

Wh ong ;  
varf von(u,v) = on(1,2,3,u=1); // 1 on border  
ong[]= von(0,WHK,tgv=1); // 1 ON BORDER …  
ThK = change(ThK, flabel= ong\>0.999999 ? ul : 4 ) ;

```auto

```

---

<div class="post-metadata">

**Author:** ![Loic](https://avatars.discourse-cdn.com/v4/letter/l/e9c0ed/32.png) [@Loic](https://community.freefem.org/u/Loic)\
**Post date:** [February 17, 2022, 5:41pm UTC](https://community.freefem.org/t/create-common-label-edges-between-two-object/1499/5 "2022-02-17T17:41:01Z")

</div>

My FreeFEM is on version 4.9. So the dist function has to work, isn’t it ?

Loïc

---

<div class="post-metadata">

**Author:** ![Loic](https://avatars.discourse-cdn.com/v4/letter/l/e9c0ed/32.png) [@Loic](https://community.freefem.org/u/Loic)\
**Post date:** [February 17, 2022, 5:57pm UTC](https://community.freefem.org/t/create-common-label-edges-between-two-object/1499/6 "2022-02-17T17:57:17Z")

</div>

However I have another error.

Here my code:

```auto
 meshL THL= extract(THK); // border mesh
  meshL ThL=extract(ThK);
  fespace Ehc(THL,P0edge); // Constant fonction of edge
  Ehc ul = label+0.5; // get the label on the each boundary edge
  //ThK = change(ThK, flabel= dist(THL) < 1e-6 ? ul : 4 ) ;

  fespace WHK(THK,P1b); // p1 bubble

  WHK ong ;
  varf von(u,v) = on(1,2,3,u=1); // 1 on border
  ong[]= von(0,WHK,tgv=1); // 1 ON BORDER …
  ThK = change(ThK, flabel= ong>0.999999 ? ul : 4 ) ;

```

and the error:

```auto
sorry no cast to this curve finite element 
  current line = 47
Exec error : sorry no cast to this curve finite element 
   -- number :1
Exec error : sorry no cast to this curve finite element 
   -- number :1
 err code 8 , mpirank 0

```

Loïc,

---

<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:** [February 19, 2022, 5:08pm UTC](https://community.freefem.org/t/create-common-label-edges-between-two-object/1499/7 "2022-02-19T17:08:13Z")

</div>

Without line number it is impossible to give answer!!!

---

<div class="post-metadata">

**Author:** ![Loic](https://avatars.discourse-cdn.com/v4/letter/l/e9c0ed/32.png) [@Loic](https://community.freefem.org/u/Loic)\
**Post date:** [February 20, 2022, 7:10am UTC](https://community.freefem.org/t/create-common-label-edges-between-two-object/1499/8 "2022-02-20T07:10:44Z")

</div>

Hello @frederichecht ,

Sorry for that,

```auto

47 meshL THL= extract(THK); // border mesh
48 fespace Ehc(THL,P0edge); // Constant fonction of edge
49 Ehc ul = label+0.5; // get the label on the each boundary edge
50 fespace WHK(THK,P1b); // p1 bubble
51 WHK ong ;
52 varf von(u,v) = on(1,2,3,u=1); // 1 on border
53 ong[]= von(0,WHK,tgv=1); // 1 ON BORDER …
54 ThK = change(ThK, flabel= ong>0.999999 ? ul : 4 ) ;

```

```auto
 sorry no cast to this curve finite element 
  current line = 48
Exec error : sorry no cast to this curve finite element 
   -- number :1
Exec error : sorry no cast to this curve finite element 
   -- number :1
 err code 8 , mpirank 0

```

The error comes from the line `fespace Ehc(THL,P0edge); `

Besides, I would like to understand why I have not access to the function `dist`. I think this function will be very useful for me.

Thank you in advance,

Best regards,

Loïc,

---

<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:** [February 20, 2022, 4:21pm UTC](https://community.freefem.org/t/create-common-label-edges-between-two-object/1499/9 "2022-02-20T16:21:22Z")

</div>

remark on 1d element P0edge is P0 so replace P0edge pas P0

---

<div class="post-metadata">

**Author:** ![Loic](https://avatars.discourse-cdn.com/v4/letter/l/e9c0ed/32.png) [@Loic](https://community.freefem.org/u/Loic)\
**Post date:** [February 20, 2022, 4:47pm UTC](https://community.freefem.org/t/create-common-label-edges-between-two-object/1499/10 "2022-02-20T16:47:49Z")

</div>

I have no error now, but the labels are only 0 et 1.

It seems that `ul` does not take the value of THK labels. When I display the value of `ul`, it gives me ` -0.5	-0.5	-0.5	`.

Best regards,

Loïc,

---

<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:** [February 21, 2022, 8:16am UTC](https://community.freefem.org/t/create-common-label-edges-between-two-object/1499/11 "2022-02-21T08:16:36Z")

</div>

Sorry) But the label on border become region on MeshL

For the list function , you have to install the develop version or a wait the version 4.11

---

<div class="post-metadata">

**Author:** ![Loic](https://avatars.discourse-cdn.com/v4/letter/l/e9c0ed/32.png) [@Loic](https://community.freefem.org/u/Loic)\
**Post date:** [February 21, 2022, 8:28am UTC](https://community.freefem.org/t/create-common-label-edges-between-two-object/1499/12 "2022-02-21T08:28:25Z")

</div>

Hello @frederichecht,

Thank you for your message,  
Now it works with region (instead of label).

Best regards,

Loïc,

---

<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:** [February 21, 2022, 4:44pm UTC](https://community.freefem.org/t/create-common-label-edges-between-two-object/1499/13 "2022-02-21T16:44:19Z")

</div>


