# Define an interval with FF++

**URL:** <https://community.freefem.org/t/define-an-interval-with-ff/750>\
**Category:** General Discussion\
**Created:** [January 17, 2021, 4:08pm UTC](https://community.freefem.org/t/define-an-interval-with-ff/750 "2021-01-17T16:08:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aicha](https://avatars.discourse-cdn.com/v4/letter/a/ec9cab/32.png) [@Aicha](https://community.freefem.org/u/Aicha)\
**Post date:** [January 17, 2021, 4:08pm UTC](https://community.freefem.org/t/define-an-interval-with-ff/750/1 "2021-01-17T16:08:43Z")

</div>

Hi,  
we defin the interval [0,1] by  
//Mesh  
real a=0., b=1.;  
mesh Th=square(Nx,1,[a+x\*(b-a),y\*b/Nx]);  
fespace Vh(Th,P2);

My question is how we can define the interval [0,2]?

Regards

---

<div class="post-metadata">

**Author:** ![gero](https://avatars.discourse-cdn.com/v4/letter/g/4491bb/32.png) [@gero](https://community.freefem.org/u/gero)\
**Post date:** [January 17, 2021, 6:45pm UTC](https://community.freefem.org/t/define-an-interval-with-ff/750/2 "2021-01-17T18:45:34Z")

</div>

I think I have contributed to your confusion by giving some incorrect advice in a previous reply:

In 1d the unit interval can be created via the segment function. This segment can be scaled during creation in the standard way. There is also the function BuildMeshL that can be used in combination with the border command.

And as you seem to have fallen back to quasi 1d on a 2d rectangular mesh you can scale the x interval during square creation.

What I have learned from this topic:  
I still find it difficult to check node coordinates on the mesh object directly.  
A better way seems to be to set up an fespace and project the coordinates on it.

```
load "msh3"

int n = 10;
int b = 2;

// using segment

meshL ThSegment = segment(n, [b*x, 0, 0]);
fespace WhSegment(ThSegment,P1);
WhSegment S = x;

cout << endl << "segment" << endl;
cout << "NELEM\t" << ThSegment.nt << endl;
cout << "NBELEM\t" << ThSegment.nbe << endl;
cout << "NNODE\t" << ThSegment.nv << endl;
cout << "Length\t" << ThSegment.measure << endl;

cout << "x" << endl << S[] << endl;

// using buildmeshL

border interval(t=0., b){x=t;y=0;z=0;};
meshL ThbuildmeshL = buildmeshL(interval(n));
fespace WhbuildmeshL(ThbuildmeshL,P1);
WhSegment B = x;

cout << endl << "buildmeshL" << endl;
cout << "x" << endl << B[] << endl;

// quasiInterval

mesh Thsquare=square(n,1,[x*b,y]);
fespace Whsquare(Thsquare,P1);
Whsquare u=x, v=y;

cout << endl << "square" << endl;
cout << "NELEM\t" << Thsquare.nt << endl;
cout << "NBELEM\t" << Thsquare.nbe << endl;
cout << "NNODE\t" << Thsquare.nv << endl;
cout << "Area\t" << Thsquare.measure << endl;

cout << "x" << endl << u[] << endl;
cout << "y" << endl << v[] << endl;
```

---

<div class="post-metadata">

**Author:** ![Aicha](https://avatars.discourse-cdn.com/v4/letter/a/ec9cab/32.png) [@Aicha](https://community.freefem.org/u/Aicha)\
**Post date:** [January 17, 2021, 7:11pm UTC](https://community.freefem.org/t/define-an-interval-with-ff/750/3 "2021-01-17T19:11:37Z")

</div>

I try with

int Nx=200;  
int b=2.;  
meshL ThSegment = segment(Nx, [b\*x, 0, 0]);  
fespace WhSegment(ThSegment,P2);  
WhSegment S = x;

But i have this error: meshl does not exist.

What’s the solution? Please

---

<div class="post-metadata">

**Author:** ![gero](https://avatars.discourse-cdn.com/v4/letter/g/4491bb/32.png) [@gero](https://community.freefem.org/u/gero)\
**Post date:** [January 17, 2021, 8:02pm UTC](https://community.freefem.org/t/define-an-interval-with-ff/750/4 "2021-01-17T20:02:36Z")

</div>

Have a look at the first line:

load “mesh3”
