Global variable in parallel code
Greetings, dear foamers!
What is the easiest way to implement global variable in OF code, which is synchronized between the processes on request and which is written to file same as all other vector/scalar fields? I would be grateful for any ideas. |
Hi,
Little clarification, what is the type of this variable? In general "all other vector/scalar fields" can be considered as global variables. |
Hello and thank you for reply.
I mean that I need not a field, but only 1 floating point value, which is synchronized over all processes. I suppose that it could be uniformDimensionedScalarField, and synchronization can be done by means of OPstream and IPstream, but I don't know how to make reconstructPar "reconstruct" this field. |
Hi,
Curiouser and curiouser ;) How the scalar should be synchronized? Maximum of all processors, sum of all processors? Any way there is reduce that can perform binary operation on the scalar from different processors. Concerning output. Take OpenFOAM/db/functionObjects/functionObjectFile/functionObjectFile.C as an example. When I needed to calculate energy and mass balances in the simulations and write them into file, I've used this code in the constructor of the balances calculation class: Code:
if (active_) |
All times are GMT -4. The time now is 01:04. |