abort.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) 2011-2016 OpenFOAM Foundation
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::functionObjects::abort
26 
27 Group
28  grpUtilitiesFunctionObjects
29 
30 Description
31  Watches for presence of the named file in the $FOAM_CASE directory
32  and aborts the calculation if it is present.
33 
34  Currently the following action types are supported:
35  - noWriteNow
36  - writeNow
37  - nextWrite
38 
39 SourceFiles
40  abort.C
41 
42 \*---------------------------------------------------------------------------*/
43 
44 #ifndef functionObjects_abort_H
45 #define functionObjects_abort_H
46 
47 #include "functionObject.H"
48 #include "NamedEnum.H"
49 
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 
52 namespace Foam
53 {
54 namespace functionObjects
55 {
56 
57 /*---------------------------------------------------------------------------*\
58  Class abort Declaration
59 \*---------------------------------------------------------------------------*/
60 
61 class abort
62 :
63  public functionObject
64 {
65 public:
66 
67  // Public data
68 
69  //- Enumeration defining the type of action
70  enum actionType
71  {
74  nextWrite
75  };
76 
77 private:
78 
79  // Private data
80 
81  //- Reference to the Time
82  const Time& time_;
83 
84  //- The fully-qualified name of the abort file
85  fileName abortFile_;
86 
87  //- Action type names
88  static const NamedEnum<actionType, 3> actionTypeNames_;
89 
90  //- The type of action
91  actionType action_;
92 
93 
94  // Private Member Functions
95 
96  //- Remove abort file.
97  void removeFile() const;
98 
99  //- Disallow default bitwise copy construct
100  abort(const abort&);
101 
102  //- Disallow default bitwise assignment
103  void operator=(const abort&);
104 
105 
106 public:
107 
108  //- Runtime type information
109  TypeName("abort");
110 
111 
112  // Constructors
113 
114  //- Construct from Time and dictionary
115  abort
116  (
117  const word& name,
118  const Time& runTime,
119  const dictionary&
120  );
121 
122 
123  //- Destructor
124  virtual ~abort();
125 
126 
127  // Member Functions
128 
129  //- Read the dictionary settings
130  virtual bool read(const dictionary&);
131 
132  //- Execute, check existence of abort file and take action
133  virtual bool execute();
134 
135  //- Execute, check existence of abort file and take action
136  virtual bool write();
137 
138  //- Execute at the final time-loop, used for cleanup
139  virtual bool end();
140 };
141 
142 
143 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
144 
145 } // End namespace functionObjects
146 } // End namespace Foam
147 
148 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
149 
150 #endif
151 
152 // ************************************************************************* //
Watches for presence of the named file in the $FOAM_CASE directory and aborts the calculation if it i...
Definition: abort.H:60
A class for handling file names.
Definition: fileName.H:69
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
virtual bool end()
Execute at the final time-loop, used for cleanup.
Definition: abort.C:192
Abstract base-class for Time/database function objects.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
const word & name() const
Return the name of this functionObject.
virtual bool execute()
Execute, check existence of abort file and take action.
Definition: abort.C:135
A class for handling words, derived from string.
Definition: word.H:59
virtual bool read(const dictionary &)
Read the dictionary settings.
Definition: abort.C:115
TypeName("abort")
Runtime type information.
write data and stop immediately
Definition: abort.H:72
stop immediately without writing data
Definition: abort.H:71
virtual ~abort()
Destructor.
Definition: abort.C:109
stop the next time data are written
Definition: abort.H:73
actionType
Enumeration defining the type of action.
Definition: abort.H:69
virtual bool write()
Execute, check existence of abort file and take action.
Definition: abort.C:186
Namespace for OpenFOAM.