How to get the coordinates of specific cells?

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

How to get the coordinates of specific cells?

Post by Mohammad »

Hello,

I want to export the velocity field for specific cells in every 100 iterations.

So, I need the coordinates of the cells for processing the results.

Is there a function or something like that to get the x,y,z coordinates of each cell by giving the cell id?

Regards,
Mohammad
Luciano Garelli
Posts: 280
Joined: Fri Dec 04, 2015 1:42 pm

Re: How to get the coordinates of specific cells?

Post by Luciano Garelli »

Hello,

Yes, there is. Depending if you are working on C or Fortran. Check in the Example directory for xyzcen() (fortran) or for cell_cen() (C), you will find a lot of example of use.

Also in the Doxygen documentation https://www.code-saturne.org/cms/sites/ ... /mesh.html

Regards,

Luciano
Mohammad
Posts: 114
Joined: Thu Oct 25, 2018 12:18 pm

Re: How to get the coordinates of specific cells?

Post by Mohammad »

Hello,

Dear Luciano,
Thank you very much! I appreciate your help.

Just one more question:
I want to export the velocity magnitude of each cell + the coordinates of them in every 100 iterations to a file (each cell data in a row with 4 columns). As you know, I should use a loop over cells and if I use parallel processing there will be some ghost cells.

I want to know that will there be duplicated data (rows) in the exported file due to ghost cells?

If the answer is yes, then how can I prevent writing of ghost cells data into the file?

Regards,
Mohammad
Luciano Garelli
Posts: 280
Joined: Fri Dec 04, 2015 1:42 pm

Re: How to get the coordinates of specific cells?

Post by Luciano Garelli »

Hello,

In the Doxygen documentation that I posted previously is the data about your question. If you use ncel (cs_glob_mesh->n_cells) you will get the local number of cells in case of parallelism. If you use ncelet (cs_glob_mesh->n_cells_with_ghosts) you will get the local number of cells plus the ghost cells.

Also check the cs_user_extra_operations-parallel_operations.f90 in the Example directory.

Regards,
Luciano.
Mohammad
Posts: 114
Joined: Thu Oct 25, 2018 12:18 pm

Re: How to get the coordinates of specific cells?

Post by Mohammad »

Hello,

Thank you again Luciano!

Regards,
Mohammad
Post Reply