CFD Online Logo CFD Online URL
Home > Forums > OpenFOAM Programming & Development

constructor argList and parallel run

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

LinkBack Thread Tools Display Modes
Old   November 29, 2013, 08:59
Default constructor argList and parallel run
Senior Member
Join Date: Jan 2012
Posts: 159
Rep Power: 7
maybee is on a distinguished road
I have questions about the subject mentioned in the title:

1. The first part of the argList constructor is:

  372 (
  373     int& argc,
  374     char**& argv,
  375     bool checkArgs,
  376     bool checkOpts
  377 )
  378 :
  379     args_(argc),
  380     options_(argc)
  381 {
  382     // Check if this run is a parallel run by searching for any parallel option
  383     // If found call runPar which might filter argv
  384     for (int argI = 0; argI < argc; ++argI)
  385     {
  386         if (argv[argI][0] == '-')
  387         {
  388             const char *optionName = &argv[argI][1];
  390             if (validParOptions.found(optionName))
  391             {
  392                 parRunControl_.runPar(argc, argv);
  393                 break;
  394             }
  395         }
  396     }
If the first argument of argv starts with a dash (line386) and the the following string is found in the valid paralell options (line 390) method runPar() is called on parRunControl_.
Now runPar is defined as

void runPar(int& argc, char**& argv)
RunPar = true;  //bool RunPar;  //subobject of parRunControl
if (!Pstream::init(argc, argv))           
    Info<< "Failed to start parallel run" << endl;
and herein method init(...) out of class reference Pstream:
bool Foam::UPstream::init(int& argc, char**& argv)    //Spawns slave processes and 
                                                                             //initialises inter-communication
   36 {
   37     FatalErrorIn("UPstream::init(int& argc, char**& argv)")
   38         << "Trying to use the dummy Pstream library." << nl
   39         << "This dummy library cannot be used in parallel mode"
   40         << Foam::exit(FatalError);
   42     return false;
   43 }
1. Method init(...) should spawn slave processes. Where is this happening in init()?
Furthermore when looking up the .C files of class UpStream on my PC I get three different files with three different init() methods. Is the method out of the online OpenFoam library the right one? How am I suppossed to know which one will be used in the code I am analysing?

2. When talking about parallel run what is meant with master process?
I have read already

If I devide the mesh into different sections and assign each section to another processor
which section or processor will be the master and more important what is the meaning of being master ?
maybee is offline   Reply With Quote

Old   November 29, 2013, 10:50
Senior Member
dkxls's Avatar
Join Date: Feb 2011
Location: Helsinki, Finland
Posts: 156
Rep Power: 12
dkxls will become famous soon enough
If you want to figure which process is 'master', this should help
if (Pstream::master())
    // Do something only on master
Otherwise, I would also be very happy if somebody who has some insight to this could point out what the master process does and what not.
To my understanding this comes largely into play when talking about input/output.

For example, it would be quite interesting to know which process is writing to a 'summary file', as e.g. the one in the sprayEngineFoam solver:

'OFstream logSummaryFile' is (and has to be) initialized in all processes, but in the end there will only be one file on the HDD. I haven't had time to dig through the source code, but it would be interesting to know, how OpenFOAM handles such kind of I/O operations in parallel runs.
dkxls is offline   Reply With Quote


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
parallel run is slower than serial run (pimpleFoam) !!! mechy OpenFOAM 18 August 17, 2016 17:19
simpleFoam parallel AndrewMortimer OpenFOAM Running, Solving & CFD 12 August 7, 2015 18:45
Can not run OpenFOAM in parallel in clusters, help! ripperjack OpenFOAM Running, Solving & CFD 5 May 6, 2014 15:25
simpleFoam in parallel issue plucas OpenFOAM Running, Solving & CFD 3 July 17, 2013 11:30
Working directory via command line Luiz CFX 4 March 6, 2011 21:02

All times are GMT -4. The time now is 17:56.