Save cells data in TXT file

Hello everybody,
I tried to save cells data of a mesh, in a text file, with the code:

ofstream file(“file.txt”);
//file<<“CELLS”<<Th.nt<<" “<<4*Th.nt<<endl;
for (int i=0; i<Th.nt; i++){
for (int j=0; j<3; j++){
file<<Vh(i,j)<<” ";

But saved data are different from saved data with savemesh(Th,“Th.txt”) code.
What is wrong???
Thank you all!!!

@fffm_84 The savemesh function saves the coordinates of the mesh, and Vh(i,j) is showing the connectivities of the mesh. So they are different things. If you want to save the data (fespace), use the ffmatlib.idp. I added below my edited version with the load data function added.

ffmatlib-Edited.idp (4.7 KB)

Thank you!!!
There is something I don’t understand:

  • when I check the TRIANGLES lists (one made with savemesh command, and the other with the code above) they are different in the first/last two rows!