OpenFOAM logo
Open Source CFD Toolkit

parRun.H

Go to the documentation of this file.
00001 #ifndef parRun_H
00002 #define parRun_H
00003 
00004 #include "OPstream.H"
00005 #include "IPstream.H"
00006 #include "IOstreams.H"
00007 
00008 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00009 
00010 namespace Foam
00011 {
00012 
00013 /*---------------------------------------------------------------------------*\
00014                            Class ParRunControl Declaration
00015 \*---------------------------------------------------------------------------*/
00016 
00017 class ParRunControl
00018 {
00019     bool RunPar;
00020 
00021 public:
00022 
00023     ParRunControl()
00024     :
00025         RunPar(false)
00026     {}
00027 
00028     ~ParRunControl()
00029     {
00030         if (RunPar)
00031         {
00032             Info<< "Finalising parallel run" << endl;
00033             Pstream::exit(0);
00034         }
00035     }
00036 
00037     void runPar(int& argc, char**& argv)
00038     {
00039         RunPar = true;
00040 
00041         if (!Pstream::init(argc, argv))
00042         {
00043             Info<< "Failed to start parallel run" << endl;
00044             Pstream::exit(1);
00045         }
00046     }
00047 
00048     bool parRun() const
00049     {
00050         return RunPar;
00051     }
00052 };
00053 
00054 
00055 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00056 
00057 } // End namespace Foam
00058 
00059 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00060 
00061 #endif
00062 
00063 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
For further information go to www.openfoam.org