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-2023 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  // foamPostProcess 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  // foamPostProcess 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 execute or write
155  // if time requires adjustment
156  virtual scalar timeToNextAction();
157 
158  //- Read and set the function object if its data have changed
159  virtual bool read(const dictionary&);
160 
161  //- Update topology using the given map
162  virtual void movePoints(const polyMesh& mesh);
163 
164  //- Update topology using the given map
165  virtual void topoChange(const polyTopoChangeMap& map);
166 
167  //- Update from another mesh using the given map
168  virtual void mapMesh(const polyMeshMap&);
169 
170  //- Redistribute or update using the given distribution map
171  virtual void distribute(const polyDistributionMap&);
172 
173 
174  // Member Operators
175 
176  //- Disallow default bitwise assignment
177  void operator=(const timeControl&) = delete;
178 };
179 
180 
181 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
182 
183 } // End namespace functionObjects
184 } // End namespace Foam
185 
186 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
187 
189 
190 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
191 
192 #endif
193 
194 // ************************************************************************* //
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
Abstract base-class for Time/database functionObjects.
const word & name() const
Return the name of this functionObject.
General time control for functionObjects.
const Foam::timeControl & writeControl() const
Return the write control object.
const Time & time() const
Return time database.
virtual wordList fields() const
Return the list of fields required.
timeControl(const word &name, const Time &, const dictionary &)
Construct from components.
virtual bool executeAtStart() const
Return true if the functionObject should be executed.
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
virtual void movePoints(const polyMesh &mesh)
Update topology using the given map.
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
TypeName("timeControl")
Runtime type information.
virtual scalar timeToNextAction()
Return the time to the next execute or write.
virtual bool execute()
Called at each ++ or += of the time-loop.
virtual void topoChange(const polyTopoChangeMap &map)
Update topology using the given map.
const Foam::timeControl & executeControl() const
Return the execute control object.
virtual bool write()
Called at each ++ or += of the time-loop.
virtual bool end()
Called when Time::run() determines that the time-loop exits.
void operator=(const timeControl &)=delete
Disallow default bitwise assignment.
const functionObject & filter() const
Return the functionObject filter.
virtual bool read(const dictionary &)
Read and set the function object if its data have changed.
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:51
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
General time dependent execution controller. The default to execute every time-step.
Definition: timeControl.H:50
A class for handling words, derived from string.
Definition: word.H:62
Namespace for OpenFOAM.
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
dictionary dict