|
[Sponsors] |
July 10, 2009, 01:40 |
Obtain the processor id in parallel code
|
#1 |
Member
Cem Albukrek
Join Date: Mar 2009
Posts: 52
Rep Power: 17 |
Hello all,
I am trying to obtain the processor id to perform a serial file writing in a parallel simulation. Essentially, I am using ofstream as it has the append feature that OFstream does not. OFstream seams to be "parallel aware" while ofstream is not. So I would like to execute a statement like if ( processor == 0 ) { "Perform ofstream based file writing" } So how does one obtain the processor id in the OpenFOAM environment? Thanks Cem |
|
July 10, 2009, 03:23 |
|
#2 |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,715
Rep Power: 40 |
Did you check the Pstream documentation?
I think you'll find something useful there. BTW: assuming you don't care about processor == 0 per se, but if you are on the master process - that information is in the Pstream docs as well. |
|
July 10, 2009, 10:07 |
|
#3 |
Senior Member
Sandeep Menon
Join Date: Mar 2009
Location: Amherst, MA
Posts: 403
Rep Power: 25 |
Try this:
if (Pstream::master()) { // Do work here } Hope this helps. |
|
July 11, 2009, 04:18 |
|
#4 |
Member
Juho Peltola
Join Date: Mar 2009
Location: Finland
Posts: 89
Rep Power: 17 |
The Doxygen Pstream documentation will also be helpful, I'm sure:
http://foam.sourceforge.net/doc/Doxy..._1Pstream.html |
|
August 7, 2009, 14:35 |
|
#5 |
Member
Cem Albukrek
Join Date: Mar 2009
Posts: 52
Rep Power: 17 |
The tips helped.
Thanks a lot! Cem |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
IcoFoam parallel woes | msrinath80 | OpenFOAM Running, Solving & CFD | 9 | July 22, 2007 03:58 |
Problems with MFIX code and Parallel Processing. | Fernando Pio | Main CFD Forum | 4 | August 29, 2006 15:33 |
Design Integration with CFD? | John C. Chien | Main CFD Forum | 19 | May 17, 2001 16:56 |
What is the Better Way to Do CFD? | John C. Chien | Main CFD Forum | 54 | April 23, 2001 09:10 |
own Code vs. commercial code | Bernhard Mueck | Main CFD Forum | 10 | February 16, 2000 11:07 |