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-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::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 "IOdictionary.H"
44 #include "PtrList.H"
45 #include "functionObject.H"
46 #include "SHA1Digest.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  public IOdictionary,
66  private PtrList<functionObject>
67 {
68  // Private Data
69 
70  //- A list of SHA1 digests for the function object dictionaries
71  List<SHA1Digest> digests_;
72 
73  //- Quick lookup of the index into functions/digests
74  HashTable<label> indices_;
75 
76  const Time& time_;
77 
78  //- Switch for the execution of the functionObjects
79  bool execution_;
80 
81  //- Tracks if read() was called while execution is on
82  bool updated_;
83 
84 
85  // Private Member Functions
86 
87  //- Read the function dictionary if present
88  // otherwise read the optional functions entry in controlDict
89  typeIOobject<IOdictionary> readFunctionsDict
90  (
91  const Time& t,
92  const bool execution
93  );
94 
95  //- Read the functions dictionary and set construct the functionObjects
96  virtual bool readDict();
97 
98  //- Remove and return the function object pointer by name,
99  // and returns the old index via the parameter.
100  // Returns a nullptr (and index -1) if it didn't exist
101  functionObject* remove(const word&, label& oldIndex);
102 
103 
104 public:
105 
106  // Constructors
107 
108  //- Construct from Time and the execution setting.
109  // The functionObject specifications are read from the controlDict
111  (
112  const Time& runTime,
113  const bool execution=true
114  );
115 
116  //- Disallow default bitwise copy construction
117  functionObjectList(const functionObjectList&) = delete;
118 
119  //- Construct and return a functionObjectList for an application.
120  // If the "dict" argument is specified the functionObjectList is
121  // constructed from that dictionary which is returned as
122  // controlDict otherwise the functionObjectList is constructed
123  // from the "functions" sub-dictionary of "system/controlDict"
125  (
126  const argList& args,
127  const Time& runTime
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  //- Allow addition of functionObjects to list
148 
149  //- Clear the list of function objects
150  void clear();
151 
152  //- Find the ID of a given function object by name
153  label findObjectID(const word& name) const;
154 
155  //- Read and set the function objects if their data have changed
156  virtual bool read();
157 
158  //- Called at the start of the time-loop
159  bool start();
160 
161  //- Called at each ++ or += of the time-loop.
162  // foamPostProcess overrides the usual executeControl behaviour and
163  // forces execution (used in post-processing mode)
164  bool execute();
165 
166  //- Called when Time::run() determines that the time-loop exits
167  bool end();
168 
169  //- Return the time to the next write
170  scalar timeToNextAction();
171 
172  //- Return the maximum time-step for stable operation
173  virtual scalar maxDeltaT() const;
174 
175  //- Update topology using the given map
176  virtual void movePoints(const polyMesh& mesh);
177 
178  //- Update topology using the given map
179  virtual void topoChange(const polyTopoChangeMap& map);
180 
181  //- Update from another mesh using the given map
182  virtual void mapMesh(const polyMeshMap&);
183 
184  //- Redistribute or update using the given distribution map
185  virtual void distribute(const polyDistributionMap&);
186 
187 
188  // Member Operators
189 
190  //- Disallow default bitwise assignment
191  void operator=(const functionObjectList&) = delete;
192 };
193 
194 
195 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196 
197 } // End namespace Foam
198 
199 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
200 
201 #endif
202 
203 // ************************************************************************* //
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:57
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
const fileName & name() const
Return the dictionary name.
Definition: dictionary.H:111
List of function objects with start(), execute() and end() functions that is called for each object.
virtual ~functionObjectList()
Destructor.
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
virtual scalar maxDeltaT() const
Return the maximum time-step for stable operation.
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.
static autoPtr< functionObjectList > New(const argList &args, const Time &runTime)
Construct and return a functionObjectList for an application.
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.
virtual 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.
Templated form of IOobject providing type information for file reading and header type checking.
Definition: IOobject.H:531
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
Foam::argList args(argc, argv)