Page 1 of 1

Volume statistics after iteration on all cells (processes)

Posted: Fri Nov 25, 2022 2:10 pm
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?

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

Posted: Sat Nov 26, 2022 1:55 pm
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

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

Posted: Mon Nov 28, 2022 7:45 am
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.