Sort the exported data in parallel mode

Questions and remarks about code_saturne usage
Forum rules
Please read the forum usage recommendations before posting.
Post Reply
Mohammad
Posts: 114
Joined: Thu Oct 25, 2018 12:18 pm

Sort the exported data in parallel mode

Post 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
Yvan Fournier
Posts: 4070
Joined: Mon Feb 20, 2012 3:25 pm

Re: Sort the exported data in parallel mode

Post 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
Mohammad
Posts: 114
Joined: Thu Oct 25, 2018 12:18 pm

Re: Sort the exported data in parallel mode

Post by Mohammad »

Hello,

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

Regards,
Mohammad
Post Reply