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 | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2016 OpenFOAM Foundation
9 Copyright (C) 2017-2020 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::functionObjects::abort
29
30Group
31 grpUtilitiesFunctionObjects
32
33Description
34 Watches for presence of the named trigger file in the case directory
35 and signals a simulation stop (or other) event if found.
36
37 The presence of the trigger file is only checked on the master process.
38
39 Currently the following action types are supported:
40 - noWriteNow
41 - writeNow
42 - nextWrite
43
44 Example of function object specification:
45 \verbatim
46 abort
47 {
48 type abort;
49 libs (utilityFunctionObjects);
50
51 file "<case>/GOODBYE";
52 action writeNow
53 }
54 \endverbatim
55
56 \heading Function object usage
57 \table
58 Property | Description | Required | Default
59 type | Type name: abort | yes |
60 file | The trigger filename | no | <case>/name
61 action | The default action to trigger | no | nextWrite
62 \endtable
63
64 When the trigger file is found, it is checked for the following
65 content which corresponds to actions.
66
67 - \c action=noWriteNow
68 : triggers Foam::Time::saNoWriteNow (stop without writing data)
69 - \c action=writeNow
70 : triggers Foam::Time::saWriteNow (stop and write data)
71 - \c action=nextWrite
72 : triggers Foam::Time::saNextWrite (stop after next normal data write)
73 - \c action=endTime
74 : triggers Foam::Time::saEndTime (continue simulation to the end)
75 - Anything else (empty file, no action=, ...)
76 : use the default action
77 .
78
79Note
80 The trigger file is considered "sticky". This means that once detected
81 and processed, the trigger is duly noted and the file will not be
82 rechecked. It is not possible or desirable to 'untrigger' an action.
83
84SourceFiles
85 abort.C
86
87\*---------------------------------------------------------------------------*/
88
89#ifndef functionObjects_abort_H
90#define functionObjects_abort_H
91
92#include "timeFunctionObject.H"
93#include "Time.H"
94
95// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
96
97namespace Foam
98{
99namespace functionObjects
100{
101
102/*---------------------------------------------------------------------------*\
103 Class abort Declaration
104\*---------------------------------------------------------------------------*/
105
106class abort
107:
108 public functionObjects::timeFunctionObject
109{
110 // Private Data
111
112 //- The fully-qualified name of the trigger file
113 fileName file_;
114
115 //- The default action (defined in dictionary)
116 Time::stopAtControls defaultAction_;
117
118 //- Only trigger the action once
119 bool triggered_;
120
121
122 // Private Member Functions
123
124 //- No copy construct
125 abort(const abort&) = delete;
126
127 //- No copy assignment
128 void operator=(const abort&) = delete;
129
130
131public:
132
133 //- Runtime type information
134 TypeName("abort");
135
136
137 // Constructors
138
139 //- Construct from Time and dictionary
140 abort(const word& name, const Time& runTime, const dictionary& dict);
141
142
143 //- Destructor
144 virtual ~abort() = default;
145
146
147 // Member Functions
148
149 //- Read the dictionary settings
150 virtual bool read(const dictionary& dict);
151
152 //- Check existence of the file and take action
153 virtual bool execute();
154
155 //- No-op
156 virtual bool write();
157
158 //- Remove the trigger file after the final time-loop.
159 virtual bool end();
160};
161
162
163// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
164
165} // End namespace functionObjects
166} // End namespace Foam
167
168// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
169
170#endif
171
172// ************************************************************************* //
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:80
stopAtControls
Definition: Time.H:98
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
A class for handling file names.
Definition: fileName.H:76
const word & name() const noexcept
Return the name of this functionObject.
Watches for presence of the named trigger file in the case directory and signals a simulation stop (o...
Definition: abort.H:128
virtual ~abort()=default
Destructor.
virtual bool read(const dictionary &dict)
Read the dictionary settings.
Definition: abort.C:161
TypeName("abort")
Runtime type information.
virtual bool execute()
Check existence of the file and take action.
Definition: abort.C:201
virtual bool write()
No-op.
Definition: abort.C:242
virtual bool end()
Remove the trigger file after the final time-loop.
Definition: abort.C:248
Virtual base class for function objects with a reference to Time.
A class for handling words, derived from Foam::string.
Definition: word.H:68
engineTime & runTime
Namespace for OpenFOAM.
errorManip< error > abort(error &err)
Definition: errorManip.H:144
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73