Rectangular non-uniform mesh

Can we use rectangular non uniform mesh in free fem++?

If you mean to build an unstructured mesh in a rectangle you can do

int nn = 10 ; 

border b1(t=-1,1){x=t; y=-1; label=1;};
border b2(t=-1,1){x=1; y=t; label=2;};
border b3(t=0,2){x=1-t; y=1;label=3;};
border b4(t=0,2){x=-1; y=1-t; label=4;};

mesh Th = buildmesh(b1(nn) + b2(nn) + b3(nn) + b4(nn));

but maybe you mean something else.

Sir, I would like to construct a rectangular Shishkin mesh in FreeFem++. Specifically, I want to partition the domain (0,1)×(0,1) into rectangles using the tensor product of 1-dimensional Shishkin meshes. This type of mesh is commonly used in the context of singular perturbation problems.

To clarify, I have a set of given points
x_𝑖 and 𝑦_𝑗 , and I want to create a mesh by drawing straight lines through these points to form rectangles.

Is it possible to implement this mesh construction in FreeFem++?

You can build these rectangles, but FreeFem++ only handles meshes made of triangles, and finite elements on triangles. Thus you will have to cut each rectangle by a diagonal to form a mesh handable by FreeFem++.

Sir, if i can build these rectangles then can you write the code for rectangles.

You can do as

int nx=3,ny=2;// number of segments in each direction

real[int] xi(nx+1),yj(ny+1);// arrays of coordinates

// define the coordinates by their values
xi=[0.,0.5,1.6,3.];
yj=[0.,1.,1.2];

// define the coordinates by an algebraic formula
//for (int i=0;i<nx+1;i++){
// xi(i)=i*i;
//}
//for (int j=0;j<ny+1;j++){
// yj(j)=sqrt(j*1.);
//}

//define the coordinates by reading files
//{
// ifstream readxcoord("xi.dat");
// for (int i=0;i<nx+1;i++){
//  readxcoord >> xi(i) ;// read a line
// }
// ifstream readycoord("yj.dat");
// for (int j=0;j<ny+1;j++){
//  readycoord >> yj(j) ;// read a line
// }
//}


mesh Base=square(nx,ny);// reference mesh
//plot(Base,wait=1);
//savemesh(Base,"Base.msh");
fespace Vb(Base,P1);
Vb phix,phiy;
for (int j=0;j<ny+1;j++){
 for (int i=0;i<nx+1;i++){
  phix[](i+(nx+1)*j)=xi(i);
  phiy[](i+(nx+1)*j)=yj(j);
 }
}

mesh Th=movemesh(Base,[phix,phiy]);
plot(Th,wait=1);

You can choose how you define the coordinates (comment/uncomment the corresponding lines): either by their explicit values, either by an algebraic formula, either by reading files “xi.dat”, “yj.dat”.
These files are for example with nx=3,ny=2

0.
0.5
1.6
3.

and

0.
1.
1.2