# How to assign data only on the edges of a 3D mesh

**URL:** <https://community.freefem.org/t/how-to-assign-data-only-on-the-edges-of-a-3d-mesh/1906>\
**Category:** General Discussion\
**Created:** [July 22, 2022, 8:16pm UTC](https://community.freefem.org/t/how-to-assign-data-only-on-the-edges-of-a-3d-mesh/1906 "2022-07-22T20:16:29Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![zcwang6](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/zcwang6/32/371_2.png) [@zcwang6](https://community.freefem.org/u/zcwang6)\
**Post date:** [July 22, 2022, 8:16pm UTC](https://community.freefem.org/t/how-to-assign-data-only-on-the-edges-of-a-3d-mesh/1906/1 "2022-07-22T20:16:29Z")

</div>

Dear Freefem team, I hope all of you doing great. I was wondering if there is any way I can only give a number to the points on the edges of a 3D mesh. I noticed that ,in Freefem, we can use ThS= Th.gamma to get the surface of 3D mesh. Then the edges ThL can be get from ThS by ThS.gamma as well. Initially, I attempted interpolate the data from MeshL to 3D mesh. However, it seems doesn’t work. I am attaching the code here, which shows the steps I mentioned above. Thank you so much for you time.  
[FREE\_FEM\_01.zip](https://community.freefem.org/uploads/short-url/1uo9kGAtr6pyy5doZ8vhGmwt2Sw.zip) (3.0 MB)

---

<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:** [July 23, 2022, 10:27am UTC](https://community.freefem.org/t/how-to-assign-data-only-on-the-edges-of-a-3d-mesh/1906/2 "2022-07-23T10:27:57Z")

</div>

I Sorry a try your exemple, I see not problem,  
And I do not understand what you want to do.

---

<div class="post-metadata">

**Author:** ![zcwang6](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/zcwang6/32/371_2.png) [@zcwang6](https://community.freefem.org/u/zcwang6)\
**Post date:** [July 23, 2022, 12:24pm UTC](https://community.freefem.org/t/how-to-assign-data-only-on-the-edges-of-a-3d-mesh/1906/3 "2022-07-23T12:24:57Z")

</div>

Dear frederic, thank you for your time. In the demo, we did not put the interpolation over there. Basically, what am trying to do is:" fespace Vh(Th,P0); Vh ThreeD; fespace VhL(ThL,P0) oneDedge;  
oneDedge = 1; **ThreeD = oneDedege;**" I thought ThreeD will only have 1 on the edges, and any other place will give 0; However, ThreeD has 1 everywhere. Thank you.

---

<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:** [July 23, 2022, 8:32pm UTC](https://community.freefem.org/t/how-to-assign-data-only-on-the-edges-of-a-3d-mesh/1906/4 "2022-07-23T20:32:49Z")

</div>

OK, the big problem in you all is: the dof of Vh is the barycenter of tet so no way by this way.

You can use P0edge finite element with dof are the barycenter of edge.

---

<div class="post-metadata">

**Author:** ![zcwang6](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/zcwang6/32/371_2.png) [@zcwang6](https://community.freefem.org/u/zcwang6)\
**Post date:** [July 24, 2022, 2:04pm UTC](https://community.freefem.org/t/how-to-assign-data-only-on-the-edges-of-a-3d-mesh/1906/5 "2022-07-24T14:04:29Z")

</div>

Thank you, If there is any example I can find from online?

---

<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:** [July 26, 2022, 1:12pm UTC](https://community.freefem.org/t/how-to-assign-data-only-on-the-edges-of-a-3d-mesh/1906/6 "2022-07-26T13:12:06Z")

</div>

I will try to fluid a simple example, but a find bug buildBdMesh function  
[zcwang6.edp](https://community.freefem.org/uploads/short-url/zEcsxk81Tfl7ugjs56c8KgXnWu.edp) (562 Bytes)

I try to correct rapidly

---

<div class="post-metadata">

**Author:** ![zcwang6](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/zcwang6/32/371_2.png) [@zcwang6](https://community.freefem.org/u/zcwang6)\
**Post date:** [July 26, 2022, 2:55pm UTC](https://community.freefem.org/t/how-to-assign-data-only-on-the-edges-of-a-3d-mesh/1906/7 "2022-07-26T14:55:50Z")

</div>

Thank you Frederic !!

---

<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:** [July 27, 2022, 2:12pm UTC](https://community.freefem.org/t/how-to-assign-data-only-on-the-edges-of-a-3d-mesh/1906/8 "2022-07-27T14:12:56Z")

</div>

I fact, They no error except in my graphic interpretation.

This code build a finite element function on edge U3

value = 1 on edge on edge of the cube  
value = 0 on all other edge of the mesh.

[zcwang6-v2.edp](https://community.freefem.org/uploads/short-url/lbZfmiEcmy5FyZlUmdeWCHQMadz.edp) (740 Bytes)

---

<div class="post-metadata">

**Author:** ![zcwang6](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/zcwang6/32/371_2.png) [@zcwang6](https://community.freefem.org/u/zcwang6)\
**Post date:** [July 27, 2022, 3:43pm UTC](https://community.freefem.org/t/how-to-assign-data-only-on-the-edges-of-a-3d-mesh/1906/9 "2022-07-27T15:43:07Z")

</div>

Thank you so much, sir.
