# Need to create nonuniform mesh on four boundaries of unit square

**URL:** <https://community.freefem.org/t/need-to-create-nonuniform-mesh-on-four-boundaries-of-unit-square/3981>\
**Category:** General Discussion\
**Created:** [June 23, 2025, 9:18am UTC](https://community.freefem.org/t/need-to-create-nonuniform-mesh-on-four-boundaries-of-unit-square/3981 "2025-06-23T09:18:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Monirul25](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/monirul25/32/3287_2.png) [@Monirul25](https://community.freefem.org/u/Monirul25)\
**Post date:** [June 23, 2025, 9:18am UTC](https://community.freefem.org/t/need-to-create-nonuniform-mesh-on-four-boundaries-of-unit-square/3981/1 "2025-06-23T09:18:08Z")

</div>

Hello, i have tried . Here, is my code\>

```auto
real z = 5; // Stretching factor for exponential density

// Exponentially stretched borders: fine near ends (i.e., corners)
border bottom(t=0,1){ x=(exp(z*t)-1)/(exp(z)-1); y=0; label=1; };
border right(t=0,1){ x=1; y=(exp(z*t)-1)/(exp(z)-1); label=2; };
border top(t=1,0){ x=(exp(z*t)-1)/(exp(z)-1); y=1; label=3; };
border left(t=1,0){ x=0; y=(exp(z*t)-1)/(exp(z)-1); label=4; };

int n = 10; // Higher n = finer mesh
mesh Th = buildmesh(
    bottom(n*4)
  + right(n*10)
  + top(n*2)
  + left(n*5)
);

plot(Th, wait=1, cmm="Uniform boundary-refined mesh");
savemesh(Th, "boundary_refined.msh");

// Refine only near the boundary (optional)
real tol = 0.05;
func isBoundaryRefined = (x < tol) || (x > 1 - tol) || (y < tol) || (y > 1 - tol);
mesh Th2 = adaptmesh(Th, isBoundaryRefined, IsMetric=1, nbvx=100000, err=1e-3);
plot(Th2, wait=1, cmm="Boundary + corner-refined");
savemesh(Th2, "boundary_corner_refined.msh");

```

But exactly, i am not getting that i want. Please help.
