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 -------------------------------------------------------------------------------
11 License
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 
27 Class
28  Foam::functionObjects::runTimeControl
29 
30 Group
31  grpUtilitiesFunctionObjects
32 
33 Description
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 
41 SourceFiles
42  runTimeControl.C
43 
44 \*---------------------------------------------------------------------------*/
45 
46 #ifndef functionObjects_runTimeControl_H
47 #define functionObjects_runTimeControl_H
48 
49 #include "fvMeshFunctionObject.H"
50 #include "Map.H"
51 #include "Enum.H"
52 
53 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54 
55 namespace Foam
56 {
57 namespace functionObjects
58 {
59 namespace runTimeControls
60 {
61 
62 // Forward declaration of classes
63 class runTimeCondition;
64 
65 /*---------------------------------------------------------------------------*\
66  Class runTimeControl Declaration
67 \*---------------------------------------------------------------------------*/
68 
69 class runTimeControl
70 :
72 {
73 public:
74 
75  // Public enumerations
76 
77  enum class satisfiedAction
78  {
80  END,
82  };
83 
85 
86 
87 private:
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 
129 public:
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 // ************************************************************************* //
dictionary dict
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
engineTime & runTime
virtual bool write()
Calculate the runTimeControl and write.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:69
virtual bool read(const dictionary &)
Read the runTimeControl data.
const word & name() const noexcept
Return the name of this functionObject.
TypeName("runTimeControl")
Runtime type information.
A class for handling words, derived from Foam::string.
Definition: word.H:63
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
Definition: List.H:55
virtual bool execute()
Execute, currently does nothing.
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Namespace for OpenFOAM.