Loading...
Searching...
No Matches
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
44Usage
45 Minimal example by using \c system/controlDict.functions:
46 \verbatim
47 abortFO
48 {
49 // Mandatory entries
50 type abort;
51 libs (utilityFunctionObjects);
52
53 // Optional entries
54 file <word>; // "<case>/GOODBYE";
55 action <word>;
56
57 // Inherited entries
58 ...
59 }
60 \endverbatim
61
62 where the entries mean:
63 \table
64 Property | Description | Type | Reqd | Deflt
65 type | Type name: abort | word | yes | -
66 libs | Library name: utilityFunctionObjects | word | yes | -
67 file | The trigger filename | word | no | <case>/name
68 action | The default action to trigger | word | no | nextWrite
69 \endtable
70
71 When the trigger file is found, it is checked for the following
72 content which corresponds to actions.
73
74 - \c action=noWriteNow
75 : triggers Foam::Time::saNoWriteNow (stop without writing data)
76 - \c action=writeNow
77 : triggers Foam::Time::saWriteNow (stop and write data)
78 - \c action=nextWrite
79 : triggers Foam::Time::saNextWrite (stop after next normal data write)
80 - \c action=endTime
81 : triggers Foam::Time::saEndTime (continue simulation to the end)
82 - Anything else (empty file, no action=, ...)
83 : use the default action
84 .
85
86 The inherited entries are elaborated in:
87 - \link timeFunctionObject.H \endlink
88
89Note
90 The trigger file is considered "sticky". This means that once detected
91 and processed, the trigger is duly noted and the file will not be
92 rechecked. It is not possible or desirable to 'untrigger' an action.
93
94SourceFiles
95 abort.C
96
97\*---------------------------------------------------------------------------*/
98
99#ifndef Foam_functionObjects_abort_H
100#define Foam_functionObjects_abort_H
101
102#include "timeFunctionObject.H"
103#include "Time.H"
104
105// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
106
107namespace Foam
108{
109namespace functionObjects
110{
111
112/*---------------------------------------------------------------------------*\
113 Class abort Declaration
114\*---------------------------------------------------------------------------*/
115
116class abort
117:
118 public functionObjects::timeFunctionObject
119{
120 // Private Data
121
122 //- The fully-qualified name of the trigger file
123 fileName file_;
124
125 //- The default action (defined in dictionary)
126 Time::stopAtControls defaultAction_;
127
128 //- Only trigger the action once
129 bool triggered_;
130
131
132 // Private Member Functions
133
134 //- No copy construct
135 abort(const abort&) = delete;
136
137 //- No copy assignment
138 void operator=(const abort&) = delete;
139
140
141public:
142
143 //- Runtime type information
144 TypeName("abort");
145
146
147 // Constructors
148
149 //- Construct from name, Time and dictionary
150 abort(const word& name, const Time& runTime, const dictionary& dict);
151
152
153 //- Destructor
154 virtual ~abort() = default;
155
156
157 // Member Functions
158
159 //- Read the function-object dictionary
160 virtual bool read(const dictionary& dict);
161
162 //- Execute the function-object operations
163 // Check existence of the file and take action
164 virtual bool execute();
165
166 //- Write the function-object results (no-op)
167 virtual bool write();
168
169 //- Remove the trigger file after the final time-loop.
170 virtual bool end();
171};
172
173
174// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
175
176} // End namespace functionObjects
177} // End namespace Foam
178
179// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
180
181#endif
182
183// ************************************************************************* //
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition Time.H:75
stopAtControls
Stop-run control options, which are primarily used when altering the stopAt condition.
Definition Time.H:97
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
A class for handling file names.
Definition fileName.H:75
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:144
virtual ~abort()=default
Destructor.
virtual bool read(const dictionary &dict)
Read the function-object dictionary.
Definition abort.C:154
TypeName("abort")
Runtime type information.
virtual bool execute()
Execute the function-object operations.
Definition abort.C:194
virtual bool write()
Write the function-object results (no-op).
Definition abort.C:235
virtual bool end()
Remove the trigger file after the final time-loop.
Definition abort.C:241
Virtual base class for function objects with a reference to Time.
A class for handling words, derived from Foam::string.
Definition word.H:66
engineTime & runTime
Function objects are OpenFOAM utilities to ease workflow configurations and enhance workflows.
Namespace for OpenFOAM.
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68