Input Border Data from an External File in FreeFEM++

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,

You can do for example as
borderdatatomesh.edp (2.6 KB)
I have taken as example input file bdry.dat as

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.

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

1 Like

There is a much simpler way by using a multi-border
borderdatatomesh.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.

1 Like

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