FreeFOAM The Cross-Platform CFD Toolkit
JobInfo.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::JobInfo
26 
27 Description
28  Helper class for recording information about run/finished jobs.
29 
30  Writes the following files:
31  - FOAM_JOB_DIR/runningJobs
32  - FOAM_JOB_DIR/finishedJobs
33  where FOAM_JOB_DIR is the first of the following options that applies:
34  - $FREEFOAM_JOB_DIR if the environment variable is defined
35  - $FOAM_JOB_DIR if the environment variable is defined (for backward compatibility)
36  - The value of the entry "foamJobDir" in the global controlDict if the entry is present
37  - $HOME/.FreeFOAM/jobControl
38 
39 SourceFiles
40  JobInfo.C
41 
42 \*---------------------------------------------------------------------------*/
43 
44 #ifndef JobInfo_H
45 #define JobInfo_H
46 
47 #include <OpenFOAM/dictionary.H>
48 #include <OpenFOAM/fileName.H>
49 #include <OSspecific/cpuTime.H>
50 
51 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 
53 namespace Foam
54 {
55 
56 /*---------------------------------------------------------------------------*\
57  Class JobInfo Declaration
58 \*---------------------------------------------------------------------------*/
59 
60 class JobInfo
61 :
62  public dictionary
63 {
64  // Private data
65  fileName runningJobPath_;
66  fileName finishedJobPath_;
67  cpuTime cpuTime_;
68 
69  // Private member functions
70 
71  bool write(Ostream&) const;
72  void end(const word& terminationType);
73 
74 
75 public:
76 
77  static bool constructed;
78  static bool writeJobInfo;
79 
80  // Constructors
81 
82  //- Construct null
83  JobInfo();
84 
85 
86  // Destructor
87 
88  ~JobInfo();
89 
90 
91  // Member Functions
92 
93  // Write
94 
95  void write() const;
96 
97  void end();
98 
99  void exit();
100 
101  void abort();
102 
103  void signalEnd() const;
104 };
105 
106 
107 extern JobInfo jobInfo;
108 
109 
110 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
111 
112 } // End namespace Foam
113 
114 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
115 
116 #endif
117 
118 // ************************ vim: set sw=4 sts=4 et: ************************ //