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