All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
timeControlFunctionObject.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2016-2021 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::functionObjects::timeControl
26 
27 Description
28 
29 Note
30  Since the timeIndex is used directly from Foam::Time, it is unaffected
31  by user-time conversions. For example, Foam::engineTime might cause \a
32  writeInterval to be degrees crank angle, but the functionObject
33  execution \a interval would still be in timestep.
34 
35 SourceFiles
36  timeControlFunctionObject.C
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef timeControlFunctionObject_H
41 #define timeControlFunctionObject_H
42 
43 #include "functionObject.H"
44 #include "dictionary.H"
45 #include "timeControl.H"
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 namespace Foam
50 {
51 namespace functionObjects
52 {
53 
54 /*---------------------------------------------------------------------------*\
55  Class timeControl Declaration
56 \*---------------------------------------------------------------------------*/
57 
58 class timeControl
59 :
60  public functionObject
61 {
62  // Private Data
63 
64  //- Reference to the time database
65  const Time& time_;
66 
67 
68  // Optional user inputs
69 
70  //- Activation time - defaults to -vGreat
71  scalar startTime_;
72 
73  //- De-activation time - defaults to vGreat
74  scalar endTime_;
75 
76  //- Number of steps before the dump-time during which deltaT
77  // may be changed (valid for adjustableRunTime)
78  label nStepsToStartTimeChange_;
79 
80 
81  //- Execute controls
82  Foam::timeControl executeControl_;
83 
84  //- Write controls
85  Foam::timeControl writeControl_;
86 
87  //- The functionObject to execute
89 
90 
91  // Private Member Functions
92 
93  //- Read relevant dictionary entries
94  void readControls(const dictionary& dict);
95 
96  //- Returns true if within time bounds
97  bool active() const;
98 
99 
100 public:
101 
102  //- Runtime type information
103  TypeName("timeControl");
104 
105 
106  // Constructors
107 
108  //- Construct from components
110  (
111  const word& name,
112  const Time&,
113  const dictionary&
114  );
115 
116  //- Disallow default bitwise copy construction
117  timeControl(const timeControl&) = delete;
118 
119 
120  // Member Functions
121 
122  // Access
123 
124  //- Return time database
125  inline const Time& time() const;
126 
127  //- Return the execute control object
128  inline const Foam::timeControl& executeControl() const;
129 
130  //- Return the write control object
131  inline const Foam::timeControl& writeControl() const;
132 
133  //- Return the functionObject filter
134  inline const functionObject& filter() const;
135 
136 
137  // Function object control
138 
139  //- Return true if the functionObject should be executed
140  // at the start
141  virtual bool executeAtStart() const;
142 
143  //- Called at each ++ or += of the time-loop.
144  // postProcess overrides the usual executeControl behaviour and
145  // forces execution (used in post-processing mode)
146  virtual bool execute();
147 
148  //- Called at each ++ or += of the time-loop.
149  // postProcess overrides the usual writeControl behaviour and
150  // forces writing (used in post-processing mode)
151  virtual bool write();
152 
153  //- Called when Time::run() determines that the time-loop exits
154  virtual bool end();
155 
156  //- Return the time to the next write
157  virtual scalar timeToNextWrite();
158 
159  //- Read and set the function object if its data have changed
160  virtual bool read(const dictionary&);
161 
162  //- Update for changes of mesh
163  virtual void updateMesh(const mapPolyMesh& mpm);
164 
165  //- Update for changes of mesh
166  virtual void movePoints(const polyMesh& mesh);
167 
168 
169  // Member Operators
170 
171  //- Disallow default bitwise assignment
172  void operator=(const timeControl&) = delete;
173 };
174 
175 
176 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
177 
178 } // End namespace functionObjects
179 } // End namespace Foam
180 
181 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
182 
184 
185 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
186 
187 #endif
188 
189 // ************************************************************************* //
dictionary dict
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
const word & name() const
Return the name of this functionObject.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
virtual bool executeAtStart() const
Return true if the functionObject should be executed.
virtual bool execute()
Called at each ++ or += of the time-loop.
void operator=(const timeControl &)=delete
Disallow default bitwise assignment.
const Foam::timeControl & executeControl() const
Return the execute control object.
Abstract base-class for Time/database functionObjects.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
virtual bool write()
Called at each ++ or += of the time-loop.
dynamicFvMesh & mesh
A class for handling words, derived from string.
Definition: word.H:59
TypeName("timeControl")
Runtime type information.
const functionObject & filter() const
Return the functionObject filter.
virtual void updateMesh(const mapPolyMesh &mpm)
Update for changes of mesh.
virtual scalar timeToNextWrite()
Return the time to the next write.
virtual void movePoints(const polyMesh &mesh)
Update for changes of mesh.
const Time & time() const
Return time database.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
General time dependent execution controller. The default to execute every time-step.
Definition: timeControl.H:49
virtual bool read(const dictionary &)
Read and set the function object if its data have changed.
virtual bool end()
Called when Time::run() determines that the time-loop exits.
Namespace for OpenFOAM.
timeControl(const word &name, const Time &, const dictionary &)
Construct from components.
const Foam::timeControl & writeControl() const
Return the write control object.