# Split a mesh by adding a node at the barycenter of elements

**URL:** https://community.freefem.org/t/split-a-mesh-by-adding-a-node-at-the-barycenter-of-elements/2533
**Category:** General Discussion
**Created:** [June 9, 2023, 1:38pm UTC](https://community.freefem.org/t/split-a-mesh-by-adding-a-node-at-the-barycenter-of-elements/2533 "2023-06-09T13:38:21Z")
**Posts on this page:** 5
**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: [June 9, 2023, 1:38pm UTC](https://community.freefem.org/t/split-a-mesh-by-adding-a-node-at-the-barycenter-of-elements/2533/1 "2023-06-09T13:38:21Z")

</div>

Hello all,

Given a 2D mesh Th `.msh`, what is the more efficient way to split the mesh by adding one node at the barycenter and then link the vertices of the triangles to the new nodes ?

Thank you in advance,

Best regards,

Loïc,

---

<div class="post-metadata">

### Author: ![marchywka](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@marchywka](https://community.freefem.org/u/marchywka)
#### Post date: [June 9, 2023, 3:10pm UTC](https://community.freefem.org/t/split-a-mesh-by-adding-a-node-at-the-barycenter-of-elements/2533/2 "2023-06-09T15:10:57Z")

</div>

If someone knows how to do this in FF curious if you could also comment  
the issues with doing it outside of FF. That is, I am looking at code to  
take the FF mesh file and do some manipulations. If I understand this,  
it should just be a batter of iterating through the triangls and finding  
the varycenter, adding a new vertex, and then adding two new triangles  
while just modfying the originial one with possible issues at  
region boundaries.

I guess I wanted to do a manual mesh refinement adding points  
along a set of isolines in a predictable way. Additionally, I would probably  
have to interpolate dof values by fit to an analytical solution.  
Basically I have a huge length scale problem but hope to skimp on  
nodes in the fast changing boundaries.

---

<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: [June 9, 2023, 3:16pm UTC](https://community.freefem.org/t/split-a-mesh-by-adding-a-node-at-the-barycenter-of-elements/2533/3 "2023-06-09T15:16:26Z")

</div>

Hello,

Yes it is, I want to iterate other triangles, find the barycenter and split the triangle in three smaller triangles. I think there will not be issues a region boundaries, as the mesh remains conform.

Loïc,

---

<div class="post-metadata">

### Author: ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)
#### Post date: [June 9, 2023, 3:58pm UTC](https://community.freefem.org/t/split-a-mesh-by-adding-a-node-at-the-barycenter-of-elements/2533/4 "2023-06-09T15:58:25Z")

</div>

You can perform Powell–Sabin mesh refinement using the `splitmesh*` plugins.

---

<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: [June 9, 2023, 4:43pm UTC](https://community.freefem.org/t/split-a-mesh-by-adding-a-node-at-the-barycenter-of-elements/2533/5 "2023-06-09T16:43:51Z")

</div>

Thanks !  
It works with `splitmesh3`

For the readers :

```auto
load "splitmesh3"
mesh Th = square(10,10); 
Th = splitmesh3(Th); 

```

Best regards,

Loïc
