setTimeStepFunctionObject.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) 2013-2014 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::setTimeStepFunctionObject
26 
27 Group
28  grpUtilitiesFunctionObjects
29 
30 Description
31  This function object overrides the calculation time step. Can only be used
32  with solvers with adjustTimeStep control (e.g. pimpleFoam). It makes no
33  attempt to co-operate with other time step 'controllers', e.g. maxCo, other
34  functionObjects. Supports 'enabled' flag but none of the other options
35  'timeStart', 'timeEnd', 'outputControl' etc.
36 
37 
38  Example of function object specification to manipulate the time step:
39  \verbatim
40  setTimeStep1
41  {
42  type setTimeStep;
43  functionObjectLibs ("libutilityFunctionObjects.so");
44  ...
45  }
46  \endverbatim
47 
48  \heading Function object usage
49  \table
50  Property | Description | Required | Default value
51  type | Type name: setTimeStep | yes |
52  enabled | On/off switch | no | yes
53  \endtable
54 
55 SourceFiles
56  setTimeStepFunctionObject.C
57 
58 \*---------------------------------------------------------------------------*/
59 
60 #ifndef setTimeStepFunctionObject_H
61 #define setTimeStepFunctionObject_H
62 
63 #include "functionObject.H"
64 #include "dictionary.H"
65 #include "DataEntry.H"
66 #include "Switch.H"
67 
68 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
69 
70 namespace Foam
71 {
72 
73 /*---------------------------------------------------------------------------*\
74  Class setTimeStepFunctionObject Declaration
75 \*---------------------------------------------------------------------------*/
76 
77 class setTimeStepFunctionObject
78 :
79  public functionObject
80 {
81  // Private data
82 
83  //- Reference to the time database
84  const Time& time_;
85 
86 
87  // Optional user inputs
88 
89  //- Switch for the execution - defaults to 'yes/on'
90  Switch enabled_;
91 
92  //- Time step
94 
95 
96  //- Disallow default bitwise copy construct
98 
99  //- Disallow default bitwise assignment
101 
102 
103 public:
104 
105  //- Runtime type information
106  TypeName("setTimeStep");
107 
108  // Constructors
109 
110  //- Construct from components
112  (
113  const word& name,
114  const Time& runTime,
115  const dictionary& dict
116  );
117 
118 
119  // Member Functions
120 
121  // Access
122 
123  //- Return time database
124  virtual const Time& time() const
125  {
126  return time_;
127  }
128 
129  //- Return the enabled flag
130  virtual bool enabled() const
131  {
132  return enabled_;
133  }
134 
135 
136  // Function object control
137 
138  //- Switch the function object on
139  virtual void on();
140 
141  //- Switch the function object off
142  virtual void off();
143 
144  //- Called at the start of the time-loop
145  virtual bool start();
146 
147  //- Called at each ++ or += of the time-loop
148  virtual bool execute(const bool forceWrite);
149 
150  //- Called when Time::run() determines that the time-loop exits
151  virtual bool end();
152 
153  //- Called when time was set at the end of the Time::operator++
154  virtual bool timeSet();
155 
156  //- Called at the end of Time::adjustDeltaT() if adjustTime is true
157  virtual bool adjustTimeStep();
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
170 
171 } // End namespace Foam
172 
173 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
174 
175 #endif
176 
177 // ************************************************************************* //
Foam::setTimeStepFunctionObject::enabled
virtual bool enabled() const
Return the enabled flag.
Definition: setTimeStepFunctionObject.H:144
Foam::Switch
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:60
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
Foam::setTimeStepFunctionObject::time
virtual const Time & time() const
Return time database.
Definition: setTimeStepFunctionObject.H:138
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::setTimeStepFunctionObject::end
virtual bool end()
Called when Time::run() determines that the time-loop exits.
Definition: setTimeStepFunctionObject.C:87
Foam::setTimeStepFunctionObject::execute
virtual bool execute(const bool forceWrite)
Called at each ++ or += of the time-loop.
Definition: setTimeStepFunctionObject.C:81
Foam::setTimeStepFunctionObject::timeStepPtr_
autoPtr< DataEntry< scalar > > timeStepPtr_
Time step.
Definition: setTimeStepFunctionObject.H:107
Foam::setTimeStepFunctionObject::start
virtual bool start()
Called at the start of the time-loop.
Definition: setTimeStepFunctionObject.C:75
Foam::setTimeStepFunctionObject::time_
const Time & time_
Reference to the time database.
Definition: setTimeStepFunctionObject.H:98
Foam::setTimeStepFunctionObject::setTimeStepFunctionObject
setTimeStepFunctionObject(const setTimeStepFunctionObject &)
Disallow default bitwise copy construct.
Foam::setTimeStepFunctionObject::enabled_
Switch enabled_
Switch for the execution - defaults to 'yes/on'.
Definition: setTimeStepFunctionObject.H:104
Foam::setTimeStepFunctionObject::TypeName
TypeName("setTimeStep")
Runtime type information.
Foam::setTimeStepFunctionObject::on
virtual void on()
Switch the function object on.
Definition: setTimeStepFunctionObject.C:63
Foam::setTimeStepFunctionObject::read
virtual bool read(const dictionary &)
Read and set the function object if its data have changed.
Definition: setTimeStepFunctionObject.C:117
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Foam::functionObject
Abstract base-class for Time/database function objects.
Definition: functionObject.H:58
Foam::setTimeStepFunctionObject::adjustTimeStep
virtual bool adjustTimeStep()
Called at the end of Time::adjustDeltaT() if adjustTime is true.
Definition: setTimeStepFunctionObject.C:99
DataEntry.H
Foam::setTimeStepFunctionObject
This function object overrides the calculation time step. Can only be used with solvers with adjustTi...
Definition: setTimeStepFunctionObject.H:91
Switch.H
Foam::setTimeStepFunctionObject::updateMesh
virtual void updateMesh(const mapPolyMesh &mpm)
Update for changes of mesh.
Definition: setTimeStepFunctionObject.C:144
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::setTimeStepFunctionObject::movePoints
virtual void movePoints(const polyMesh &mesh)
Update for changes of mesh.
Definition: setTimeStepFunctionObject.C:148
Foam::autoPtr
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
Foam::setTimeStepFunctionObject::operator=
void operator=(const setTimeStepFunctionObject &)
Disallow default bitwise assignment.
Foam::functionObject::name
virtual const word & name() const
Name.
Definition: functionObject.C:105
Foam::setTimeStepFunctionObject::off
virtual void off()
Switch the function object off.
Definition: setTimeStepFunctionObject.C:69
dictionary.H
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
functionObject.H
Foam::setTimeStepFunctionObject::timeSet
virtual bool timeSet()
Called when time was set at the end of the Time::operator++.
Definition: setTimeStepFunctionObject.C:93