Volume statistics after iteration on all cells (processes)

Questions and remarks about code_saturne usage
Forum rules
Please read the forum usage recommendations before posting.
Post Reply
Antech
Posts: 197
Joined: Wed Jun 10, 2015 10:02 am

Volume statistics after iteration on all cells (processes)

Post by Antech »

Hello. I have a question that is simple for you but tricky for me. In user-functions, I usually work on current process, so every process launches it's copy of the same user function. But now I need to calculate some statistics and print it to log (for simple hand-made CH4 combustion model). I checked examples but didn't find anything enumerating all cells on all cores/threads. I saw something similar years ago but cannot remember where... Maybe you will point to particular example or provide simple code on the forum?
Yvan Fournier
Posts: 4070
Joined: Mon Feb 20, 2012 3:25 pm

Re: Volume statistics after iteration on all cells (processes)

Post by Yvan Fournier »

Hello,

If all you need are simple statistics (mean, min, max), the cs_array_reduce series of functions (used in cs_log_iteration) will do.
If your dat is represented as a field, you can also simply activate logging for it.

Otherwise, there are also functions for histograms, one of which can be used as a simple postprocessing output writer.

Otherwise, if you do things in your own code, you usually need at least some parallel reductios (cs_parall_sum or MPI_Allteduce) in addition to the local loops.

Best regards,

Yvan
Antech
Posts: 197
Joined: Wed Jun 10, 2015 10:02 am

Re: Volume statistics after iteration on all cells (processes)

Post by Antech »

Thanks! I found required functions in cs_parall.h. Actually, I needed summary heat of reaction so cs_parall_sum made the trick. There are also other helpful functions in that header. Kind of magic is that functions take only current thread variable and collect data from all other threads automatically, very useful. I guess cs_parall_allgather_r builds specified array from all processes but I didn't need it so didn't try.
Post Reply