functionObjectList.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) 2011-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::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
33  Foam::functionObjects::timeControl
34 
35 SourceFiles
36  functionObjectList.C
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef functionObjectList_H
41 #define functionObjectList_H
42 
43 #include "PtrList.H"
44 #include "functionObject.H"
45 #include "SHA1Digest.H"
46 #include "HashSet.H"
47 #include "includeFuncEntry.H"
48 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 namespace Foam
52 {
53 
54 class polyTopoChangeMap;
55 class polyMeshMap;
56 class polyDistributionMap;
57 class argList;
58 
59 /*---------------------------------------------------------------------------*\
60  Class functionObjectList Declaration
61 \*---------------------------------------------------------------------------*/
62 
64 :
65  private PtrList<functionObject>
66 {
67  // Private Data
68 
69  //- A list of SHA1 digests for the function object dictionaries
70  List<SHA1Digest> digests_;
71 
72  //- Quick lookup of the index into functions/digests
73  HashTable<label> indices_;
74 
75  const Time& time_;
76 
77  //- The parent dictionary containing a "functions" entry
78  // This entry can either be a list or a dictionary of
79  // functionObject specifications
80  const dictionary& parentDict_;
81 
82  //- Switch for the execution of the functionObjects
83  bool execution_;
84 
85  //- Tracks if read() was called while execution is on
86  bool updated_;
87 
88 
89  // Private Member Functions
90 
91  //- Remove and return the function object pointer by name,
92  // and returns the old index via the parameter.
93  // Returns a nullptr (and index -1) if it didn't exist
94  functionObject* remove(const word&, label& oldIndex);
95 
96 
97 public:
98 
99  // Constructors
100 
101  //- Construct from Time and the execution setting.
102  // The functionObject specifications are read from the controlDict
104  (
105  const Time& runTime,
106  const bool execution=true
107  );
108 
109  //- Construct from Time, a dictionary with "functions" entry
110  // and the execution setting.
111  // \param[in] t - the other Time instance to construct from
112  // \param[in] parentDict - the parent dictionary containing
113  // a "functions" entry, which can either be a list or a dictionary
114  // of functionObject specifications.
115  // \param[in] execution - whether the function objects should execute
116  // or not. Default: true.
118  (
119  const Time& runTime,
120  const dictionary& parentDict,
121  const bool execution=true
122  );
123 
124  //- Disallow default bitwise copy construction
125  functionObjectList(const functionObjectList&) = delete;
126 
127  //- Construct and return a functionObjectList for an application.
128  // If the "dict" argument is specified the functionObjectList is
129  // constructed from that dictionary which is returned as
130  // controlDict otherwise the functionObjectList is constructed
131  // from the "functions" sub-dictionary of "system/controlDict"
133  (
134  const argList& args,
135  const Time& runTime,
137  );
138 
139 
140  //- Destructor
141  virtual ~functionObjectList();
142 
143 
144  // Member Functions
145 
146  //- Return the number of elements in the List.
148 
149  //- Return true if the List is empty (ie, size() is zero).
151 
152  //- Access to the functionObjects
154 
155  //- Allow addition of functionObjects to list
157 
158  //- Clear the list of function objects
159  void clear();
160 
161  //- Find the ID of a given function object by name
162  label findObjectID(const word& name) const;
163 
164  //- Read and set the function objects if their data have changed
165  bool read();
166 
167  //- Called at the start of the time-loop
168  bool start();
169 
170  //- Called at each ++ or += of the time-loop.
171  // foamPostProcess overrides the usual executeControl behaviour and
172  // forces execution (used in post-processing mode)
173  bool execute();
174 
175  //- Called when Time::run() determines that the time-loop exits
176  bool end();
177 
178  //- Return the time to the next write
179  scalar timeToNextAction();
180 
181  //- Update topology using the given map
182  virtual void movePoints(const polyMesh& mesh);
183 
184  //- Update topology using the given map
185  virtual void topoChange(const polyTopoChangeMap& map);
186 
187  //- Update from another mesh using the given map
188  virtual void mapMesh(const polyMeshMap&);
189 
190  //- Redistribute or update using the given distribution map
191  virtual void distribute(const polyDistributionMap&);
192 
193 
194  // Member Operators
195 
196  //- Disallow default bitwise assignment
197  void operator=(const functionObjectList&) = delete;
198 };
199 
200 
201 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
202 
203 } // End namespace Foam
204 
205 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
206 
207 #endif
208 
209 // ************************************************************************* //
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:91
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: PtrList.H:75
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
Extract command arguments and options from the supplied argc and argv parameters.
Definition: argList.H:103
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
List of function objects with start(), execute() and end() functions that is called for each object.
static autoPtr< functionObjectList > New(const argList &args, const Time &runTime, dictionary &controlDict)
Construct and return a functionObjectList for an application.
virtual ~functionObjectList()
Destructor.
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.
label findObjectID(const word &name) const
Find the ID of a given function object by name.
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
bool start()
Called at the start of the time-loop.
functionObjectList(const Time &runTime, const bool execution=true)
Construct from Time and the execution setting.
void clear()
Clear the list of function objects.
void operator=(const functionObjectList &)=delete
Disallow default bitwise assignment.
scalar timeToNextAction()
Return the time to the next write.
bool execute()
Called at each ++ or += of the time-loop.
virtual void topoChange(const polyTopoChangeMap &map)
Update topology using the given map.
bool end()
Called when Time::run() determines that the time-loop exits.
bool read()
Read and set the function objects if their data have changed.
Abstract base-class for Time/database functionObjects.
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.
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
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
runTime controlDict().lookup("adjustTimeStep") >> adjustTimeStep
Foam::argList args(argc, argv)