Page 1 of 1

Sort the exported data in parallel mode

Posted: Sun Dec 08, 2019 12:44 pm
by Mohammad
Hello,

I want to export the u component of velocity field every 100 iterations to a file. I also write the coordinates of the cells in 3 columns.
So, I wrote the following codes in cs_extra_operations.cs file.

Code: Select all

const cs_lnum_t n_cells = cs_glob_mesh-> n_cells;
cs_real_3_t *cvar_vel = (cs_real_3_t *)CS_F_(u)->val;
cs_real_3_t *cell_cen = mesh_quantities->cell_cen;

      if(fmod(ntcabs,5) == 0)                                             
        {
          for (cs_lnum_t i = 0; i < n_cells; i++) {
            FILE *f2 = NULL;
              f2 = fopen("VELOCITY_COMPONENTS","a");
              fprintf(f2, "%i\t%f\t%f\t%f\t%f\n", ntcabs, cvar_vel[i][0],cell_cen[i][0],cell_cen[i][1],cell_cen[i][2]);
              fclose (f2);
          }
        }
It does the job very well, but the problem is that the exported data is not sorted well when using parallel cpus.
The exported data are sorted randomly in parallel mode, while in single processor mode they are sorted very well by cell id.

Is there a way to sort the exported data in parallel mode like the ones in single processor mode?

Regards,
Mohammad

Re: Sort the exported data in parallel mode

Posted: Sun Dec 08, 2019 5:42 pm
by Yvan Fournier
Hello,

Did you look at the probes and profiles documentation ? It seems it would be adapted to what you are doing.
Otherwise, export to EnSight format, and extract the data to CSV using ParaView.

Regards,

Yvan

Re: Sort the exported data in parallel mode

Posted: Sun Dec 08, 2019 8:10 pm
by Mohammad
Hello,

Thanks a lot.
I did it using cs_glob_mesh->global_cell_num and Linux's terminal sort command!

Regards,
Mohammad