CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   constructor argList and parallel run (https://www.cfd-online.com/Forums/openfoam-programming-development/126938-constructor-arglist-parallel-run.html)

maybee November 29, 2013 07:59

constructor argList and parallel run
 
hi,
I have questions about the subject mentioned in the title:

1. The first part of the argList constructor is:

Code:

Foam::argList::argList
  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];
  389
  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

Code:

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;
    Pstream::exit(1);
  }
}

and herein method init(...) out of class reference Pstream:
Code:

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);
  41
  42    return false;
  43 }

Questions:
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
http://www.openfoam.org/docs/user/ru...s-parallel.php
and
http://www.cfd-online.com/Forums/ope...g-2-2-0-a.html

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 :D ?

dkxls November 29, 2013 09:50

If you want to figure which process is 'master', this should help
Code:

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:
https://github.com/OpenFOAM/OpenFOAM...startSummary.H

'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.


All times are GMT -4. The time now is 03:47.