Loading...
Searching...
No Matches
runTimeControl.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) 2015-2016 OpenFOAM Foundation
9 Copyright (C) 2016-2022 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::runTimeControl
29
30Group
31 grpUtilitiesFunctionObjects
32
33Description
34 Controls when the calculation is terminated based on satisfying
35 user-specified conditions.
36
37 Optionally specify a number of write steps before the calculation is
38 terminated. Here, a write is performed each time that all conditions are
39 satisfied.
40
41Usage
42 Minimal example by using \c system/controlDict.functions:
43 \verbatim
44 runTimeControlFO
45 {
46 // Mandatory entries
47 type runTimeControl;
48 libs (utilityFunctionObjects);
49 conditions <dictionary>;
50
51 // Optional entries
52 nWriteStep <label>;
53 satisfiedAction <satisfiedAction>;
54
55 // Conditional entries
56
57 // when 'satisfiedAction' is 'setTrigger'
58 trigger <label>;
59
60 // Inherited entries
61 ...
62 }
63 \endverbatim
64
65 where the entries mean:
66 \table
67 Property | Description | Type | Reqd | Deflt
68 type | Type name: runTimeControl | word | yes | -
69 libs | Library name: utilityFunctionObjects | word | yes | -
70 conditions | List of conditions to satisfy | dictionary | yes | -
71 nWriteStep | Number of write steps before exiting | label | no | 0
72 satisfiedAction | Operand action | word | no | end
73 \endtable
74
75 Options for the \c satisfiedAction entry:
76 \verbatim
77 abort | Write and emit a FatalError, terminating the run abnormally
78 end | Write and exit cleanly, terminating the run normally
79 setTrigger | Trigger another condition, allowing chained control logic
80 \endverbatim
81
82 The inherited entries are elaborated in:
83 - \link functionObject.H \endlink
84
85SourceFiles
86 runTimeControl.C
87
88\*---------------------------------------------------------------------------*/
89
90#ifndef Foam_functionObjects_runTimeControl_H
91#define Foam_functionObjects_runTimeControl_H
92
94#include "Map.H"
95#include "Enum.H"
96
97// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
98
99namespace Foam
100{
101namespace functionObjects
102{
103namespace runTimeControls
104{
105
106// Forward Declarations
107class runTimeCondition;
108
109/*---------------------------------------------------------------------------*\
110 Class runTimeControl Declaration
111\*---------------------------------------------------------------------------*/
112
113class runTimeControl
114:
116{
117public:
118
119 // Public Enumerations
120
121 enum class satisfiedAction
122 {
123 ABORT,
124 END,
126 };
127
129
130
131private:
132
133 // Private data
134
135 //- List of conditions to satisfy
136 PtrList<runTimeCondition> conditions_;
137
138 //- Map to define group IDs
139 Map<label> groupMap_;
140
141 //- Number of write steps before exiting
142 label nWriteStep_;
143
144 //- Current number of steps written
145 label writeStepI_;
146
147 //- Action to take when conditions are satisfied
148 satisfiedAction satisfiedAction_;
149
150 //- Trigger index if satisfiedAction is setTrigger
151 label triggerIndex_;
153 //- Active flag
154 // Used in the trigger case to bypass any evaluations after the
155 // trigger has been set
156 bool active_;
157
158 //- Can be restarted flag
159 // Used in the trigger case after the trigger has been set to allow
160 // this object to be restarted/reset the active flag
161 bool canRestart_;
162
163
164 // Private Member Functions
165
166 //- No copy construct
167 runTimeControl(const runTimeControl&) = delete;
168
169 //- No copy assignment
170 void operator=(const runTimeControl&) = delete;
171
172
173public:
174
175 //- Runtime type information
176 TypeName("runTimeControl");
177
178
179 // Constructors
180
181 //- Construct for given objectRegistry and dictionary
182 runTimeControl
183 (
184 const word& name,
185 const Time& runTime,
186 const dictionary& dict
187 );
188
189
190 //- Destructor
191 virtual ~runTimeControl() = default;
192
193
194 // Member Functions
195
196 //- Read the runTimeControl data
197 virtual bool read(const dictionary&);
198
199 //- Execute, currently does nothing
200 virtual bool execute();
201
202 //- Calculate the runTimeControl and write
203 virtual bool write();
204};
205
206
207// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
208
209} // End namespace runTimeControls
210} // End namespace functionObjects
211} // End namespace Foam
212
213// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
214
215#endif
216
217// ************************************************************************* //
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition Enum.H:57
A HashTable to objects of type <T> with a label key.
Definition Map.H:54
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition PtrList.H:67
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition Time.H:75
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
const word & name() const noexcept
Return the name of this functionObject.
fvMeshFunctionObject(const fvMeshFunctionObject &)=delete
No copy construct.
TypeName("runTimeControl")
Runtime type information.
virtual bool execute()
Execute, currently does nothing.
virtual bool write()
Calculate the runTimeControl and write.
virtual bool read(const dictionary &)
Read the runTimeControl data.
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