# Input Border Data from an External File in FreeFEM++

**URL:** https://community.freefem.org/t/input-border-data-from-an-external-file-in-freefem/3713
**Category:** General Discussion
**Created:** [January 27, 2025, 11:55am UTC](https://community.freefem.org/t/input-border-data-from-an-external-file-in-freefem/3713 "2025-01-27T11:55:56Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Amina1727](https://avatars.discourse-cdn.com/v4/letter/a/f08c70/32.png) [@Amina1727](https://community.freefem.org/u/Amina1727)
#### Post date: [January 27, 2025, 11:55am UTC](https://community.freefem.org/t/input-border-data-from-an-external-file-in-freefem/3713/1 "2025-01-27T11:55:56Z")

</div>

Hello everyone,  
I am currently working on a project in FreeFEM++ and would like to know how to read boundary coordinates from an external file. I have a file named Data.dat that contains  
r and z values in a table format, for example:

r1 z1  
r2 z2  
r3 z3

My goal is to read this data and use it to define a boundary or contour in my computational domain. I’ve tried using an `ifstream` to read the file, but I encountered errors (e.g., “No operator .is for type ”).

Could anyone provide a working example or recommend an approach for:

1. Reading such an external file in FreeFEM++.
2. Using the data to define a boundary or mesh?

Thank you in advance for your help! Any suggestions or sample scripts would be greatly appreciated.

Best regards,

---

<div class="post-metadata">

### Author: ![fb77](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/fb77/32/3796_2.png) [@fb77](https://community.freefem.org/u/fb77)
#### Post date: [January 30, 2025, 4:23pm UTC](https://community.freefem.org/t/input-border-data-from-an-external-file-in-freefem/3713/2 "2025-01-30T16:23:10Z")

</div>

You can do for example as  
[borderdatatomesh.edp](https://community.freefem.org/uploads/short-url/tw2AUFfKFU7R6IQdHLksszTmn0r.edp) (2.6 KB)  
I have taken as example input file `bdry.dat` as

```auto
6
0. 0.
1. 0.
2. 1.
1. 3.
0.5 5.
0. 1.

```

The first line contains the number of points on the boundary (6 in the example),  
and next the x and y coordinates of the points.  
They are supposed to represent the boundary oriented in the trigonometric sense.

I assume the data will represent a star-shaped domain, and I therefore add a point in the middle (coordinate 0.5, 0.5 in the file .edp) so that the mesh is made of triangles joining a boundary segment to the center.

 ![meshpoints](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/0/0615458424f3f2579bd24aa7529b7c198aba3212.png)

After that you can refine the mesh (see file).

---

<div class="post-metadata">

### Author: ![fb77](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/fb77/32/3796_2.png) [@fb77](https://community.freefem.org/u/fb77)
#### Post date: [January 31, 2025, 9:55am UTC](https://community.freefem.org/t/input-border-data-from-an-external-file-in-freefem/3713/3 "2025-01-31T09:55:34Z")

</div>

There is a much simpler way by using a multi-border  
[borderdatatomesh.edp](https://community.freefem.org/uploads/short-url/1OdIGkDQ0hrwnZILTNozCpI25h.edp) (1.0 KB)  
The domain needs not be star-shaped.  
You have simply to set `nbsegborder` in order to define the level of discretization.

---

<div class="post-metadata">

### Author: ![Amina1727](https://avatars.discourse-cdn.com/v4/letter/a/f08c70/32.png) [@Amina1727](https://community.freefem.org/u/Amina1727)
#### Post date: [February 11, 2025, 8:43pm UTC](https://community.freefem.org/t/input-border-data-from-an-external-file-in-freefem/3713/4 "2025-02-11T20:43:36Z")

</div>

Thank you, Professor , for your invaluable help and support. I truly appreciate your guidance.
