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-2022 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  General time control for functionObjects
29 
30 SourceFiles
31  timeControlFunctionObject.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef timeControlFunctionObject_H
36 #define timeControlFunctionObject_H
37 
38 #include "functionObject.H"
39 #include "dictionary.H"
40 #include "timeControl.H"
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 namespace functionObjects
47 {
48 
49 /*---------------------------------------------------------------------------*\
50  Class timeControl Declaration
51 \*---------------------------------------------------------------------------*/
52 
53 class timeControl
54 :
55  public functionObject
56 {
57  // Private Data
58 
59  //- Reference to the time database
60  const Time& time_;
61 
62 
63  // Optional user inputs
64 
65  //- Activation time - defaults to -vGreat
66  scalar startTime_;
67 
68  //- De-activation time - defaults to vGreat
69  scalar endTime_;
70 
71  //- Number of steps before the dump-time during which deltaT
72  // may be changed (valid for adjustableRunTime)
73  label nStepsToStartTimeChange_;
74 
75 
76  //- Execute controls
77  Foam::timeControl executeControl_;
78 
79  //- Write controls
80  Foam::timeControl writeControl_;
81 
82  //- The functionObject to execute
84 
85 
86  // Private Member Functions
87 
88  //- Read relevant dictionary entries
89  void readControls(const dictionary& dict);
90 
91  //- Returns true if within time bounds
92  bool active() const;
93 
94 
95 public:
96 
97  //- Runtime type information
98  TypeName("timeControl");
99 
100 
101  // Constructors
102 
103  //- Construct from components
105  (
106  const word& name,
107  const Time&,
108  const dictionary&
109  );
110 
111  //- Disallow default bitwise copy construction
112  timeControl(const timeControl&) = delete;
113 
114 
115  // Member Functions
116 
117  // Access
118 
119  //- Return time database
120  inline const Time& time() const;
121 
122  //- Return the execute control object
123  inline const Foam::timeControl& executeControl() const;
124 
125  //- Return the write control object
126  inline const Foam::timeControl& writeControl() const;
127 
128  //- Return the functionObject filter
129  inline const functionObject& filter() const;
130 
131 
132  // Function object control
133 
134  //- Return the list of fields required
135  virtual wordList fields() const;
136 
137  //- Return true if the functionObject should be executed
138  // at the start
139  virtual bool executeAtStart() const;
140 
141  //- Called at each ++ or += of the time-loop.
142  // postProcess overrides the usual executeControl behaviour and
143  // forces execution (used in post-processing mode)
144  virtual bool execute();
145 
146  //- Called at each ++ or += of the time-loop.
147  // postProcess overrides the usual writeControl behaviour and
148  // forces writing (used in post-processing mode)
149  virtual bool write();
150 
151  //- Called when Time::run() determines that the time-loop exits
152  virtual bool end();
153 
154  //- Return the time to the next write
155  virtual scalar timeToNextWrite();
156 
157  //- Read and set the function object if its data have changed
158  virtual bool read(const dictionary&);
159 
160  //- Update topology using the given map
161  virtual void movePoints(const polyMesh& mesh);
162 
163  //- Update topology using the given map
164  virtual void topoChange(const polyTopoChangeMap& map);
165 
166  //- Update from another mesh using the given map
167  virtual void mapMesh(const polyMeshMap&);
168 
169 
170  // Member Operators
171 
172  //- Disallow default bitwise assignment
173  void operator=(const timeControl&) = delete;
174 };
175 
176 
177 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
178 
179 } // End namespace functionObjects
180 } // End namespace Foam
181 
182 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
183 
185 
186 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
187 
188 #endif
189 
190 // ************************************************************************* //
dictionary dict
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 wordList fields() const
Return the list of fields required.
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.
General time control for functionObjects.
const Foam::timeControl & executeControl() const
Return the execute control object.
Abstract base-class for Time/database functionObjects.
fvMesh & mesh
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:69
virtual bool write()
Called at each ++ or += of the time-loop.
A class for handling words, derived from string.
Definition: word.H:59
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
TypeName("timeControl")
Runtime type information.
const functionObject & filter() const
Return the functionObject filter.
virtual scalar timeToNextWrite()
Return the time to the next write.
virtual void movePoints(const polyMesh &mesh)
Update topology using the given map.
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:76
virtual void topoChange(const polyTopoChangeMap &map)
Update topology using the given map.
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:50
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.
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
Namespace for OpenFOAM.
timeControl(const word &name, const Time &, const dictionary &)
Construct from components.
const Foam::timeControl & writeControl() const
Return the write control object.