# Adaptmesh and periodic boundary conditions

**URL:** <https://community.freefem.org/t/adaptmesh-and-periodic-boundary-conditions/2211>\
**Category:** General Discussion\
**Created:** [January 10, 2023, 5:00am UTC](https://community.freefem.org/t/adaptmesh-and-periodic-boundary-conditions/2211 "2023-01-10T05:00:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![glimmt](https://avatars.discourse-cdn.com/v4/letter/g/919ad9/32.png) [@glimmt](https://community.freefem.org/u/glimmt)\
**Post date:** [January 10, 2023, 5:00am UTC](https://community.freefem.org/t/adaptmesh-and-periodic-boundary-conditions/2211/1 "2023-01-10T05:00:30Z")

</div>

Hello, I am having problems with using adaptmesh with periodic boundary conditions. I found that others have experienced similar issues in the past, but I’m wondering if there is a solution in my case.  
Any help is appreciated. Thank you!

The code below generates an error message  
" current line = 22  
Exec error : Periodic: the both number of edges is not the same  
– number :1"

///////// CODE //////////////////////////////////////  
// Mesh  
border C01(t=0, 10_pi){x=t; y=0; label=1;}  
border C02(t=0, 2_pi){x=10_pi; y=t; label=2;}  
border C03(t=0, 10_pi){x=10_pi-t; y=2_pi; label=3;}  
border C04(t=0, 2_pi){x=0; y=2_pi-t; label=4;}

int n=10;  
int m=10;

mesh Th=buildmesh(C01(n)+C02(m)+C03(n)+C04(m), fixedborder=1);

func f=cos(x)\*sin(y);

// Fespace  
fespace Vh(Th,P1,periodic=[[2,y],[4,y], [1,x],[3,x]]);  
Vh fh = f;  
plot(fh);

// Adaptmesh  
for (int i = 0; i \< 2; i++){  
Th = adaptmesh(Th, fh);  
fh = f; //old mesh is deleted  
plot(Th, fh, wait=true);  
}
