Page 1 of 1

How to get the coordinates of specific cells?

Posted: Wed Dec 04, 2019 5:15 pm
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

Re: How to get the coordinates of specific cells?

Posted: Thu Dec 05, 2019 12:35 pm
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

Re: How to get the coordinates of specific cells?

Posted: Thu Dec 05, 2019 10:22 pm
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

Re: How to get the coordinates of specific cells?

Posted: Fri Dec 06, 2019 4:47 pm
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.

Re: How to get the coordinates of specific cells?

Posted: Fri Dec 06, 2019 7:59 pm
by Mohammad
Hello,

Thank you again Luciano!

Regards,
Mohammad