Saving and loading files

Hello guys!

I need to save a solution and then read ir in another freefem file. I’m not sure how to do this. I am able to save the mesh and load it, but I can’t do dat with the solution.

Just to clarify:

problem Psiext(psiext,v)=
int2d(Sh)(-dx(psiext)*dx(v)-dy(psiext)*dy(v)-v*dx(psiext)/x)
-int2d(Sh)(-x*Jtor*v)
+on(izq,psiext=0)+on(circ,psiext=0); // condicion de Dirichlet de Soloviev

Psiext;

My solution would be psiext.

Thanks!

Maybe you can try ifstream

using ofstream to save solutions and ifstream to load solutions.

Hello! First of all, thank you for your anwser. I understand that ifstream and ofstream are the solution to my problem, but I have no idea which is the information I have to write down in the file. I am not sure if the solution is an 2D array of how the information is storaged.

Hello,

You can try

/*
fespace Vh(Th, P1);
Vh Psiext;
*/
ofstream fileSol ("file.txt");
for (int i = 0; i<Vh.ndof; i++){
	fileSol <<psiext[][i]<<endl;
}

And do the same thing with ifstream to load your solution
Alexandre