timeControlFunctionObject.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 | Copyright (C) 2016 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 functionObjects_timeControl_H
41 #define functionObjects_timeControl_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  //- Input dictionary
68  dictionary dict_;
69 
70 
71  // Optional user inputs
72 
73  //- Activation time - defaults to -VGREAT
74  scalar timeStart_;
75 
76  //- De-activation time - defaults to VGREAT
77  scalar timeEnd_;
78 
79  //- Number of steps before the dump-time during which deltaT
80  // may be changed (valid for adjustableRunTime)
81  label nStepsToStartTimeChange_;
82 
83 
84  //- Execute controls
85  Foam::timeControl executeControl_;
86 
87  //- Write controls
88  Foam::timeControl writeControl_;
89 
90  //- The functionObject to execute
92 
93 
94  // Private Member Functions
95 
96  //- Read relevant dictionary entries
97  void readControls();
98 
99  //- Returns true if within time bounds
100  bool active() const;
101 
102  //- Disallow default bitwise copy construct
103  timeControl(const timeControl&);
104 
105  //- Disallow default bitwise assignment
106  void operator=(const timeControl&);
107 
108 
109 public:
110 
111  //- Runtime type information
112  TypeName("timeControl");
113 
114 
115  // Constructors
116 
117  //- Construct from components
119  (
120  const word& name,
121  const Time&,
122  const dictionary&
123  );
124 
125 
126  // Member Functions
127 
128  // Access
129 
130  //- Return time database
131  inline const Time& time() const;
132 
133  //- Return the input dictionary
134  inline const dictionary& dict() const;
135 
136  //- Return the execute control object
137  inline const Foam::timeControl& executeControl() const;
138 
139  //- Return the write control object
140  inline const Foam::timeControl& writeControl() const;
141 
142  //- Return the functionObject filter
143  inline const functionObject& filter() const;
144 
145 
146  // Function object control
147 
148  //- Called at each ++ or += of the time-loop.
149  // postProcess overrides the usual executeControl behaviour and
150  // forces execution (used in post-processing mode)
151  virtual bool execute();
152 
153  //- Called at each ++ or += of the time-loop.
154  // postProcess overrides the usual writeControl behaviour and
155  // forces writing (used in post-processing mode)
156  virtual bool write();
157 
158  //- Called when Time::run() determines that the time-loop exits
159  virtual bool end();
160 
161  //- Called at the end of Time::adjustDeltaT() if adjustTime is true
162  virtual bool adjustTimeStep();
163 
164  //- Read and set the function object if its data have changed
165  virtual bool read(const dictionary&);
166 
167  //- Update for changes of mesh
168  virtual void updateMesh(const mapPolyMesh& mpm);
169 
170  //- Update for changes of mesh
171  virtual void movePoints(const polyMesh& mesh);
172 };
173 
174 
175 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
176 
177 } // End namespace functionObjects
178 } // End namespace Foam
179 
180 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
181 
183 
184 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
185 
186 #endif
187 
188 // ************************************************************************* //
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
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
virtual bool execute()
Called at each ++ or += of the time-loop.
const dictionary & dict() const
Return the input dictionary.
Abstract base-class for Time/database function objects.
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.
const Foam::timeControl & writeControl() const
Return the write control object.
const functionObject & filter() const
Return the functionObject filter.
dynamicFvMesh & mesh
const word & name() const
Return the name of this functionObject.
A class for handling words, derived from string.
Definition: word.H:59
TypeName("timeControl")
Runtime type information.
const Foam::timeControl & executeControl() const
Return the execute control object.
virtual void updateMesh(const mapPolyMesh &mpm)
Update for changes of mesh.
const Time & time() const
Return time database.
virtual void movePoints(const polyMesh &mesh)
Update for changes of mesh.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:53
virtual bool adjustTimeStep()
Called at the end of Time::adjustDeltaT() if adjustTime is true.
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.