CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   single directional message transmit in parallel model (http://www.cfd-online.com/Forums/openfoam-programming-development/69836-single-directional-message-transmit-parallel-model.html)

su_junwei November 6, 2009 02:29

single directional message transmit in parallel model
 
Dear Foamer

I am new to parallel programming. Mybe my problem is easy for you. Would you mind giving me some suggestion?

I want to transmit some data from processor A to B, but B doesn't know there will some message coming from A. How can B received the message from A?
B may not transmit message to A. I mean the massage transmission is single directional.

I figured out a possible solution. In my question, once the message passages are established, they won't change at later time. Thus I think it better to construct the connection between A and B firstly, and transmit the message continuously at later time. To construct such a message passage beforehand, the connection of the current processor with interacting processors is broadcast, and in the destination processor the connection was constructed based on the message received.
In this method, all the processors will broadcast the connection once. How can I achieve this with OpenFOAM?

Mybe my method is a little awkward, would you mind giving me some good soultion or suggestions to this problem.

A critical problem is I don't knew how to broad a message to all the processors with current processors. Scatter? CombineScatter? combineScatterList?

Any suggestions?


Best Regards, Junwei.

herbert December 17, 2009 07:00

You have to implement both, sending and recieving. The orders you need are:

For sending a scalar named "value" to processor n:
OPstream::write(Pstream::scheduled, n, reinterpret_cast<const char*>(&value), sizeof(scalar));

and for recieving a scalar from processor n, that should be stored in "value":
IPstream::read(Pstream::scheduled, n, reinterpret_cast<char*>(&value), sizeof(scalar));

Of course, these commands are to be executed by special processors, so first check the processor number using Pstream::myProcNo().

Hope this was helpfull
Herbert


All times are GMT -4. The time now is 05:07.