Volume statistics after iteration on all cells (processes)
Forum rules
Please read the forum usage recommendations before posting.
Please read the forum usage recommendations before posting.
Volume statistics after iteration on all cells (processes)
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?
-
- Posts: 4208
- Joined: Mon Feb 20, 2012 3:25 pm
Re: Volume statistics after iteration on all cells (processes)
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
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)
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.