# Non-uniform border vertex spacing (before movemesh23) and incompatibility when combining with square3-generated meshS

**URL:** <https://community.freefem.org/t/non-uniform-border-vertex-spacing-before-movemesh23-and-incompatibility-when-combining-with-square3-generated-meshs/430>\
**Category:** General Discussion\
**Created:** [May 25, 2020, 7:50am UTC](https://community.freefem.org/t/non-uniform-border-vertex-spacing-before-movemesh23-and-incompatibility-when-combining-with-square3-generated-meshs/430 "2020-05-25T07:50:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aaron1d](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/aaron1d/32/168_2.png) [@aaron1d](https://community.freefem.org/u/aaron1d)\
**Post date:** [May 25, 2020, 7:50am UTC](https://community.freefem.org/t/non-uniform-border-vertex-spacing-before-movemesh23-and-incompatibility-when-combining-with-square3-generated-meshs/430/1 "2020-05-25T07:50:51Z")

</div>

I have a somewhat complex 3d geometry, the boundary of most of which I can construct with **meshS** pieces from calling **square3**. However, Due to the different numbers of vertices required on opposing sides in one plane of my design, I want to use **buildmesh** followed by **movemesh23**. I can sum all the **meshS** elements together just fine, but when I try to use **tetgen** to generate the internal mesh, even after ensuring that the number of joining vertices is the same for each respective pair of **meshS** elements , I get an error, which is coming from the edges where a **square3**  **meshS** is joined with a **movemesh23** ( **buildmesh** ( )) **meshS**. For example:

> PLC Error: A vertex lies in a segment.  
> Vertex: [5825] (0.0005,-0.000431538,-2e-006).  
> Segment: [3658, 3660] #-1 (20)  
> Strange catch exception ???

After experimenting with a simple example:

load “msh3”

int nx = 5;  
int ny = 4;  
int nz = 2;

func y0=0;  
func x1=2;

border a1(t=0,1){x=2_t; y=0;};  
border a2(t=0,1){x=2; y=t;};  
border a3(t=0,1){x=2_(1-t); y=1;};  
border a4(t=0,1){x=0; y=1-t;};  
mesh aa = buildmesh(a1(nx)+a2(ny)+a3(nx)+a4(ny));  
meshS Th3aa = movemesh23(aa,transfo=[x,y,0]);  
meshS Th3b1 = square3(nx,nz,[x_2, y0, y_1],orientation=-1);

meshS Th3 = Th3aa + Th3b1;  
plot(Th3, wait=1);

I can see the vertex misalignment where the planes are joined:

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/1X/1533ac4f5a3ffa90ecf3dcb8c0de2412e3aeb6f5.png)

Also, printing out the vertex locations for the **mesh, aa,** , I can see that the vertices along the y-axis are not evenly spaced at 0, 0.25, 0.5, 0.75, 1; they are spaced at 0, 0.264423, 0.5, 0.735577, 1. Similarly, they are not spaced evenly along the x-axis, as they are with the **square3**  **meshS**.

Does anyone know how to make the **buildmesh** command space the vertices uniformly along each section of the perimeter? Or how I can otherwise get the vertices to line up on my composite **meshS** before I run tetgen?

Much thanks!

**UPDATE:**  
I have constructed the planar surface I wanted to using 5 square3’s (with unnecessary increased “border” vertices) instead of 1 movemesh23(buildmesh(…)).

However, I’m still curious about why the buildmesh(border(…)+…) vertices aren’t uniformly spaced.

---

<div class="post-metadata">

**Author:** ![denis.crete](https://avatars.discourse-cdn.com/v4/letter/d/9d8465/32.png) [@denis.crete](https://community.freefem.org/u/denis.crete)\
**Post date:** [August 10, 2025, 4:01pm UTC](https://community.freefem.org/t/non-uniform-border-vertex-spacing-before-movemesh23-and-incompatibility-when-combining-with-square3-generated-meshs/430/2 "2025-08-10T16:01:55Z")

</div>

Hello,

I have the same problem and tried to fix it by adding the following line :

```auto
mesh aa = buildmesh(a1(nx)+a2(ny)+a3(nx)+a4(ny));
aa = movemesh(aa,[round(x*nx)/nx,round(y*ny)/ny]);

and it seems to solve the problem. It does not look really nice, but if it works... 
HTH
Denis

```

---

<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:** [August 25, 2025, 9:48am UTC](https://community.freefem.org/t/non-uniform-border-vertex-spacing-before-movemesh23-and-incompatibility-when-combining-with-square3-generated-meshs/430/3 "2025-08-25T09:48:10Z")

</div>

Long time ago, I add fixeborder = 1 in ‘buildmesh’ function to solve the problem.

see:

> **[Functions](https://doc.freefem.org/references/functions.html#buildmesh)**
