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-2024 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 
72  //- Execute controls
73  Foam::timeControl executeControl_;
74 
75  //- Write controls
76  Foam::timeControl writeControl_;
77 
78  //- The functionObject to execute
80 
81 
82  // Private Member Functions
83 
84  //- Read relevant dictionary entries
85  void readControls(const dictionary& dict);
86 
87  //- Returns true if within time bounds
88  bool active() const;
89 
90 
91 public:
92 
93  //- Runtime type information
94  TypeName("timeControl");
95 
96 
97  // Constructors
98 
99  //- Construct from components
101  (
102  const word& name,
103  const Time&,
104  const dictionary&
105  );
106 
107  //- Disallow default bitwise copy construction
108  timeControl(const timeControl&) = delete;
109 
110 
111  // Member Functions
112 
113  // Access
114 
115  //- Return time database
116  inline const Time& time() const;
117 
118  //- Return the execute control object
119  inline const Foam::timeControl& executeControl() const;
120 
121  //- Return the write control object
122  inline const Foam::timeControl& writeControl() const;
123 
124  //- Return the functionObject filter
125  inline const functionObject& filter() const;
126 
127 
128  // Function object control
129 
130  //- Return the list of fields required
131  virtual wordList fields() const;
132 
133  //- Return true if the functionObject should be executed
134  // at the start
135  virtual bool executeAtStart() const;
136 
137  //- Called at each ++ or += of the time-loop.
138  // foamPostProcess overrides the usual executeControl behaviour and
139  // forces execution (used in post-processing mode)
140  virtual bool execute();
141 
142  //- Called at each ++ or += of the time-loop.
143  // foamPostProcess overrides the usual writeControl behaviour and
144  // forces writing (used in post-processing mode)
145  virtual bool write();
146 
147  //- Called when Time::run() determines that the time-loop exits
148  virtual bool end();
149 
150  //- Return the time to the next execute or write
151  // if time requires adjustment
152  virtual scalar timeToNextAction();
153 
154  //- Read and set the function object if its data have changed
155  virtual bool read(const dictionary&);
156 
157  //- Update topology using the given map
158  virtual void movePoints(const polyMesh& mesh);
159 
160  //- Update topology using the given map
161  virtual void topoChange(const polyTopoChangeMap& map);
162 
163  //- Update from another mesh using the given map
164  virtual void mapMesh(const polyMeshMap&);
165 
166  //- Redistribute or update using the given distribution map
167  virtual void distribute(const polyDistributionMap&);
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 // ************************************************************************* //
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:162
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:51
A class for handling words, derived from string.
Definition: word.H:62
Namespace for OpenFOAM.
dictionary dict