CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Programming & Development

Obtain the processor id in parallel code

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By deepsterblue

Reply
 
LinkBack Thread Tools Display Modes
Old   July 10, 2009, 00:40
Default Obtain the processor id in parallel code
  #1
Member
 
Cem Albukrek
Join Date: Mar 2009
Posts: 50
Rep Power: 8
albcem is on a distinguished road
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
albcem is offline   Reply With Quote

Old   July 10, 2009, 02:23
Default
  #2
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: http://olesenm.github.io/
Posts: 777
Rep Power: 18
olesen will become famous soon enough
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.
olesen is offline   Reply With Quote

Old   July 10, 2009, 09:07
Default
  #3
Senior Member
 
Sandeep Menon
Join Date: Mar 2009
Location: Amherst, MA
Posts: 386
Rep Power: 15
deepsterblue will become famous soon enough
Try this:

if (Pstream::master())
{
// Do work here
}

Hope this helps.
fportela likes this.
__________________
Sandeep Menon
University of Massachusetts Amherst
https://github.com/smenon
deepsterblue is offline   Reply With Quote

Old   July 11, 2009, 03:18
Default
  #4
Member
 
Juho Peltola
Join Date: Mar 2009
Location: Finland
Posts: 80
Rep Power: 8
juho is on a distinguished road
The Doxygen Pstream documentation will also be helpful, I'm sure:
http://foam.sourceforge.net/doc/Doxy..._1Pstream.html
juho is offline   Reply With Quote

Old   August 7, 2009, 13:35
Default
  #5
Member
 
Cem Albukrek
Join Date: Mar 2009
Posts: 50
Rep Power: 8
albcem is on a distinguished road
The tips helped.

Thanks a lot!


Cem
albcem is offline   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
IcoFoam parallel woes msrinath80 OpenFOAM Running, Solving & CFD 9 July 22, 2007 02:58
Problems with MFIX code and Parallel Processing. Fernando Pio Main CFD Forum 4 August 29, 2006 14:33
Design Integration with CFD? John C. Chien Main CFD Forum 19 May 17, 2001 15:56
What is the Better Way to Do CFD? John C. Chien Main CFD Forum 54 April 23, 2001 08:10
own Code vs. commercial code Bernhard Mueck Main CFD Forum 10 February 16, 2000 11:07


All times are GMT -4. The time now is 04:14.