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
41SourceFiles
42 runTimeControl.C
43
44\*---------------------------------------------------------------------------*/
45
46#ifndef functionObjects_runTimeControl_H
47#define functionObjects_runTimeControl_H
48
50#include "Map.H"
51#include "Enum.H"
52
53// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54
55namespace Foam
56{
57namespace functionObjects
58{
59namespace runTimeControls
60{
61
62// Forward declaration of classes
63class runTimeCondition;
64
65/*---------------------------------------------------------------------------*\
66 Class runTimeControl Declaration
67\*---------------------------------------------------------------------------*/
70:
72{
73public:
74
75 // Public enumerations
77 enum class satisfiedAction
78 {
79 ABORT,
80 END,
82 };
85
86
87private:
88
89 // Private data
90
91 //- List of conditions to satisfy
92 PtrList<runTimeCondition> conditions_;
93
94 //- Map to define group IDs
95 Map<label> groupMap_;
96
97 //- Number of write steps before exiting
98 label nWriteStep_;
99
100 //- Current number of steps written
101 label writeStepI_;
102
103 //- Action to take when conditions are satisfied
104 satisfiedAction satisfiedAction_;
105
106 //- Trigger index if satisfiedAction is setTrigger
107 label triggerIndex_;
108
109 //- Active flag
110 // Used in the trigger case to bypass any evaluations after the
111 // trigger has been set
112 bool active_;
113
114 //- Can be restarted flag
115 // Used in the trigger case after the trigger has been set to allow
116 // this object to be restarted/reset the active flag
117 bool canRestart_;
118
119
120 // Private Member Functions
121
122 //- No copy construct
123 runTimeControl(const runTimeControl&) = delete;
124
125 //- No copy assignment
126 void operator=(const runTimeControl&) = delete;
127
128
129public:
130
131 //- Runtime type information
132 TypeName("runTimeControl");
133
134
135 // Constructors
136
137 //- Construct for given objectRegistry and dictionary
139 (
140 const word& name,
141 const Time& runTime,
142 const dictionary& dict
143 );
144
145
146 //- Destructor
147 virtual ~runTimeControl() = default;
148
149
150 // Member Functions
151
152 //- Read the runTimeControl data
153 virtual bool read(const dictionary&);
154
155 //- Execute, currently does nothing
156 virtual bool execute();
157
158 //- Calculate the runTimeControl and write
159 virtual bool write();
160};
161
162
163// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
164
165} // End namespace runTimeControls
166} // End namespace functionObjects
167} // End namespace Foam
168
169// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
170
171#endif
172
173// ************************************************************************* //
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition: Enum.H:61
A HashTable to objects of type <T> with a label key.
Definition: Map.H:60
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: PtrList.H:73
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:80
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
const word & name() const noexcept
Return the name of this functionObject.
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
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:68
engineTime & runTime
Namespace for OpenFOAM.
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73