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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011 OpenFOAM Foundation
9  Copyright (C) 2017 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::JobInfo
29 
30 Description
31  Helper class for recording information about run/finished jobs.
32 
33  Writes the following files:
34  - $FOAM_JOB_DIR/runningJobs
35  - $FOAM_JOB_DIR/finishedJobs
36 
37  If FOAM_JOB_DIR is unset, defaults to ~/.OpenFOAM/jobControl
38 
39 SourceFiles
40  JobInfo.C
41 
42 \*---------------------------------------------------------------------------*/
43 
44 #ifndef JobInfo_H
45 #define JobInfo_H
46 
47 #include "dictionary.H"
48 #include "fileName.H"
49 #include "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 
66  //- The name of the job file
67  string jobFileName_;
68  fileName runningDir_;
69  fileName finishedDir_;
70  cpuTime cpuTime_;
71 
72  // Private Member Functions
73 
74  bool write(Ostream& os) const;
75  void end(const word& terminationType);
76 
77 
78 public:
79 
80  //- Global value for constructed job info
81  static bool constructed;
82 
83  //- Global value for writeJobInfo enabled
84  static bool writeJobInfo;
85 
86 
87  // Constructors
88 
89  //- Construct null
90  JobInfo();
91 
92 
93  //- Destructor
94  // Update job info and relocate the file from running to finished.
95  ~JobInfo();
96 
97 
98  // Member Functions
99 
100  //- Write the job info to its file in the runningJobs directory
101  void write() const;
102 
103  //- End with "termination=normal"
104  void end();
105 
106  //- End with "termination=exit"
107  void exit();
108 
109  //- End with "termination=abort"
110  void abort();
111 
112  //- Update job info and relocate the file from running to finished.
113  void signalEnd() const;
114 };
115 
116 
117 extern JobInfo jobInfo;
118 
119 
120 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
121 
122 } // End namespace Foam
123 
124 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
125 
126 #endif
127 
128 // ************************************************************************* //
Foam::JobInfo::exit
void exit()
End with "termination=exit".
Definition: JobInfo.C:172
Foam::JobInfo::writeJobInfo
static bool writeJobInfo
Global value for writeJobInfo enabled.
Definition: JobInfo.H:83
Foam::JobInfo
Helper class for recording information about run/finished jobs.
Definition: JobInfo.H:59
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
Foam::JobInfo::end
void end()
End with "termination=normal".
Definition: JobInfo.C:166
Foam::JobInfo::write
void write() const
Write the job info to its file in the runningJobs directory.
Definition: JobInfo.C:151
fileName.H
Foam::cpuTimeCxx
Starts timing CPU usage and return elapsed time from start.
Definition: cpuTimeCxx.H:53
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::JobInfo::JobInfo
JobInfo()
Construct null.
Definition: JobInfo.C:96
Foam::jobInfo
JobInfo jobInfo
Definition: JobInfo.C:49
Foam::JobInfo::constructed
static bool constructed
Global value for constructed job info.
Definition: JobInfo.H:80
dictionary.H
Foam::JobInfo::~JobInfo
~JobInfo()
Destructor.
Definition: JobInfo.C:143
Foam::JobInfo::abort
void abort()
End with "termination=abort".
Definition: JobInfo.C:178
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::JobInfo::signalEnd
void signalEnd() const
Update job info and relocate the file from running to finished.
Definition: JobInfo.C:184