I have a code that runs on parallel and at the end it writes the solution on a file. When I run it on my Mac everything is ok however, when running it on a cluster I get each time a different result, I don’t get the global solution but a value that is stored on one of the procs. How can I force it to export only the global solution?
Exporting the global solution is very expensive for large-scale problems. You can save the distributed solution as vtu format and view it by ParaView. If you exactly want to get the global solution, FreeFEM supports more than one way to deal with it. Here I just list one way: if you are using PETSc, you can add -ksp_view_solution ascii:your_solution.m:ascii_matlab to command line to put the global solution into the .m file.
WIth the other way, you can refer to FreeFem-sources/convect.edp at master · FreeFem/FreeFem-sources · GitHub
In addition to what Gang said, could you please put a small snippet of what you are currently doing and that is not working? Maybe this will help you to give you a more appropriate solution.
Yes it works by saving the solution as a vtu format, however I’m trying to save the global value of a variable. For example when I run the code on 4 procs and save the variable to a .dat file I get each time a random value stored on one of the procs. And one of these values is the global solution
I added a screenshot below. this is the code running on 4 procs, one of the values stored at each iteration is the global value of a variable, when I try to save it on a file I get at random each time values stored at proc 1 , 2, 3 or 4
Yes but the code writes values at each iteration in a parallel loop so if I add this condition before the write to file I also get a different answer each time
If your ww is a distributed solution, you need to figure out which subdomain is in charge of the point 1, 0.05, 0 and then save only to disk for the identified subdomain with if(mpirank == subdomain_in_charge_of_point) { // write to disk }.