functionObjectList.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) 2011-2014 OpenFOAM Foundation
6  \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
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::functionObjectList
26 
27 Description
28  List of function objects with start(), execute() and end() functions
29  that is called for each object.
30 
31 See Also
32  Foam::functionObject and Foam::OutputFilterFunctionObject
33 
34 SourceFiles
35  functionObjectList.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef functionObjectList_H
40 #define functionObjectList_H
41 
42 #include "PtrList.H"
43 #include "functionObject.H"
44 #include "SHA1Digest.H"
45 #include "HashTable.H"
46 #include "IOdictionary.H"
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 namespace Foam
51 {
52 
53 class mapPolyMesh;
54 
55 /*---------------------------------------------------------------------------*\
56  Class functionObjectList Declaration
57 \*---------------------------------------------------------------------------*/
58 
60 :
61  private PtrList<functionObject>
62 {
63  // Private data
64 
65  //- A list of SHA1 digests for the function object dictionaries
67 
68  //- Quick lookup of the index into functions/digests
70 
71  const Time& time_;
72 
73  //- The parent dictionary containing a "functions" entry
74  // This entry can either be a list or a dictionary of
75  // functionObject specifications.
76  const dictionary& parentDict_;
77 
78  //- Function object properties - stores state information
80 
81  //- Switch for the execution of the functionObjects
82  bool execution_;
83 
84  //- Tracks if read() was called while execution is on
85  bool updated_;
86 
87 
88  // Private Member Functions
89 
90  //- Create state dictionary
91  void createStateDict() const;
92 
93  //- Remove and return the function object pointer by name,
94  // and returns the old index via the parameter.
95  // Returns a NULL pointer (and index -1) if it didn't exist.
96  functionObject* remove(const word&, label& oldIndex);
97 
98  //- Disallow default bitwise copy construct
100 
101  //- Disallow default bitwise assignment
102  void operator=(const functionObjectList&);
103 
104 
105 public:
106 
107  // Constructors
108 
109  //- Construct from Time and the execution setting
110  // The functionObject specifications are read from the controlDict
112  (
113  const Time&,
114  const bool execution=true
115  );
116 
117 
118  //- Construct from Time, a dictionary with "functions" entry
119  // and the execution setting.
120  // \param[in] parentDict - the parent dictionary containing
121  // a "functions" entry, which can either be a list or a dictionary
122  // of functionObject specifications.
124  (
125  const Time&,
126  const dictionary& parentDict,
127  const bool execution=true
128  );
129 
130 
131  //- Destructor
132  virtual ~functionObjectList();
133 
134 
135  // Member Functions
136 
137  //- Return the number of elements in the List.
139 
140  //- Return true if the List is empty (ie, size() is zero).
142 
143  //- Access to the functionObjects
145 
146  //- Return the state dictionary
148 
149  //- Return const access to the state dictionary
150  const IOdictionary& stateDict() const;
151 
152  //- Clear the list of function objects
153  virtual void clear();
154 
155  //- Find the ID of a given function object by name
156  virtual label findObjectID(const word& name) const;
157 
158  //- Switch the function objects on
159  virtual void on();
160 
161  //- Switch the function objects off
162  virtual void off();
163 
164  //- Return the execution status (on/off) of the function objects
165  virtual bool status() const;
166 
167 
168  //- Called at the start of the time-loop
169  virtual bool start();
170 
171  //- Called at each ++ or += of the time-loop. forceWrite overrides
172  // the usual outputControl behaviour and forces writing always
173  // (used in postprocessing mode)
174  virtual bool execute(const bool forceWrite = false);
175 
176  //- Called when Time::run() determines that the time-loop exits
177  virtual bool end();
178 
179  //- Called when time was set at the end of the Time::operator++
180  virtual bool timeSet();
181 
182  //- Called at the end of Time::adjustDeltaT() if adjustTime is true
183  virtual bool adjustTimeStep();
184 
185  //- Read and set the function objects if their data have changed
186  virtual bool read();
187 
188  //- Update for changes of mesh
189  virtual void updateMesh(const mapPolyMesh& mpm);
190 
191  //- Update for changes of mesh
192  virtual void movePoints(const polyMesh& mesh);
193 };
194 
195 
196 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
197 
198 } // End namespace Foam
199 
200 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
201 
202 #endif
203 
204 // ************************************************************************* //
Foam::IOdictionary
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:53
Foam::functionObjectList::movePoints
virtual void movePoints(const polyMesh &mesh)
Update for changes of mesh.
Definition: functionObjectList.C:447
Foam::functionObjectList::status
virtual bool status() const
Return the execution status (on/off) of the function objects.
Definition: functionObjectList.C:185
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
Foam::functionObjectList::adjustTimeStep
virtual bool adjustTimeStep()
Called at the end of Time::adjustDeltaT() if adjustTime is true.
Definition: functionObjectList.C:276
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
HashTable.H
Foam::functionObjectList::digests_
List< SHA1Digest > digests_
A list of SHA1 digests for the function object dictionaries.
Definition: functionObjectList.H:65
Foam::functionObjectList::createStateDict
void createStateDict() const
Create state dictionary.
Definition: functionObjectList.C:32
Foam::functionObjectList::on
virtual void on()
Switch the function objects on.
Definition: functionObjectList.C:172
Foam::functionObjectList::remove
functionObject * remove(const word &, label &oldIndex)
Remove and return the function object pointer by name,.
Definition: functionObjectList.C:55
Foam::functionObjectList::updateMesh
virtual void updateMesh(const mapPolyMesh &mpm)
Update for changes of mesh.
Definition: functionObjectList.C:435
Foam::functionObjectList::operator=
void operator=(const functionObjectList &)
Disallow default bitwise assignment.
Foam::functionObjectList::stateDict
IOdictionary & stateDict()
Return the state dictionary.
Definition: functionObjectList.C:127
Foam::functionObjectList::parentDict_
const dictionary & parentDict_
The parent dictionary containing a "functions" entry.
Definition: functionObjectList.H:75
Foam::functionObjectList
List of function objects with start(), execute() and end() functions that is called for each object.
Definition: functionObjectList.H:58
Foam::functionObjectList::start
virtual bool start()
Called at the start of the time-loop.
Definition: functionObjectList.C:191
Foam::functionObjectList::findObjectID
virtual label findObjectID(const word &name) const
Find the ID of a given function object by name.
Definition: functionObjectList.C:158
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::functionObjectList::clear
virtual void clear()
Clear the list of function objects.
Definition: functionObjectList.C:149
Foam::functionObjectList::indices_
HashTable< label > indices_
Quick lookup of the index into functions/digests.
Definition: functionObjectList.H:68
SHA1Digest.H
Foam::label
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
Foam::functionObjectList::off
virtual void off()
Switch the function objects off.
Definition: functionObjectList.C:178
Foam::PtrList
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:61
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::functionObjectList::functionObjectList
functionObjectList(const functionObjectList &)
Disallow default bitwise copy construct.
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::HashTable< label >
IOdictionary.H
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::functionObjectList::execution_
bool execution_
Switch for the execution of the functionObjects.
Definition: functionObjectList.H:81
Foam::functionObjectList::execute
virtual bool execute(const bool forceWrite=false)
Called at each ++ or += of the time-loop. forceWrite overrides.
Definition: functionObjectList.C:197
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::functionObjectList::updated_
bool updated_
Tracks if read() was called while execution is on.
Definition: functionObjectList.H:84
Foam::functionObjectList::stateDictPtr_
autoPtr< IOdictionary > stateDictPtr_
Function object properties - stores state information.
Definition: functionObjectList.H:78
Foam::functionObjectList::time_
const Time & time_
Definition: functionObjectList.H:70
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
PtrList.H
Foam::functionObjectList::~functionObjectList
virtual ~functionObjectList()
Destructor.
Definition: functionObjectList.C:121
Foam::functionObjectList::read
virtual bool read()
Read and set the function objects if their data have changed.
Definition: functionObjectList.C:297
functionObject.H
Foam::functionObjectList::end
virtual bool end()
Called when Time::run() determines that the time-loop exits.
Definition: functionObjectList.C:234
Foam::name
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
Foam::functionObjectList::timeSet
virtual bool timeSet()
Called when time was set at the end of the Time::operator++.
Definition: functionObjectList.C:255