functionObjectProperties.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 | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2021-2022 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Class
27 Foam::functionObjects::properties
28
29Description
30 Storage for function object properties, derived from IOdictionary.
31 Provides functionality to read/write state information (data required for
32 smooth restart behaviour) and results to/from the state dictionary
33
34 Note: cannot be accessed until after construction of thefunction objects,
35 since the owner container functionObjectList is owned by time, and time owns
36 [this] i.e. need to wait for time to be fully constructed.
37
38See also
39 Foam::functionObject
40
41SourceFiles
42 functionObjectProperties.C
43 functionObjectPropertiesTemplates.C
44
45\*---------------------------------------------------------------------------*/
46
47#ifndef functionObjects_properties_H
48#define functionObjects_properties_H
49
50#include "IOdictionary.H"
51
52// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53
54namespace Foam
55{
56namespace functionObjects
57{
58
59/*---------------------------------------------------------------------------*\
60 Class properties Declaration
61\*---------------------------------------------------------------------------*/
63class properties
64:
65 public IOdictionary
66{
67 // Private Member Data
68
69 //- Name of the results dictionary
70 static const word resultsName_;
71
72
73protected:
74
75 // Protected Member Functions
76
77 //- No copy construct
78 properties(const properties&) = delete;
79
80 //- No copy assignment
81 void operator=(const properties&) = delete;
82
83
84public:
85
86 // Constructors
87
88 //- Construct from components
89 explicit properties(const IOobject& io);
90
91
92 //- Destructor
93 virtual ~properties() = default;
94
95
96 // Member Functions
97
98 //- Return list of object names
99 wordList objectNames() const;
100
101 //- Return true if the object with objectName exists
102 bool hasObjectDict(const word& objectName) const;
103
104 //- Return access to the property dictionary
105 dictionary& propertyDict(const word& objectName);
106
107
108 // Properties
109
110 //- Get dictionary for named object. Creates one if required
111 dictionary& getObjectDict(const word& objectName);
112
113 //- Return true if the property exists
115 (
116 const word& objectName,
117 const word& entryName
118 ) const;
119
120 //- Remove the trigger index from the properties
121 void clearTrigger();
122
123 //- Get the current trigger index
124 label getTrigger() const;
125
126 //- Set new trigger index.
127 // \return True if the index changed
128 bool setTrigger(const label triggeri);
129
130 //- Set dictionary from named object, return true if set
131 bool getObjectDict
132 (
133 const word& objectName,
134 const word& entryName,
136 ) const;
137
138 //- Retrieve generic property from named object
139 template<class Type>
141 (
142 const word& objectName,
143 const word& entryName,
144 const Type& defaultValue = Type(Zero)
145 ) const;
146
147 //- Set generic property from named object, return true if set
148 template<class Type>
150 (
151 const word& objectName,
152 const word& entryName,
153 Type& value
154 ) const;
155
156 //- Add generic property from named object
157 template<class Type>
159 (
160 const word& objectName,
161 const word& entryName,
162 const Type& value
163 );
164
165
166 // Results
167
168 //- Add result from named object
169 template<class Type>
170 void setObjectResult
171 (
172 const word& objectName,
173 const word& entryName,
174 const Type& value
175 );
176
177 //- Retrieve result from named object
178 template<class Type>
179 Type getObjectResult
180 (
181 const word& objectName,
182 const word& entryName,
183 const Type& defaultValue = Type(Zero)
184 ) const;
185
186 //- Set result from named object, return true if set
187 template<class Type>
188 bool getObjectResult
189 (
190 const word& objectName,
191 const word& entryName,
192 Type& value
193 ) const;
194
195 //- Return true if the object with objectName exists in results
196 bool hasResultObject(const word& objectName) const;
197
198 //- Return list of objects with results
200
201 //- Return true if the object with objectName exists and has
202 //- entryName in its results
204 (
205 const word& objectName,
206 const word& entryName
207 ) const;
208
209 //- Return the type of result
211 (
212 const word& objectName,
213 const word& entryName
214 ) const;
215
216 //- Return result entries for named object
217 wordList objectResultEntries(const word& objectName) const;
218
219 //- Write the results entries for all objects to stream
220 void writeResultEntries(Ostream& os) const;
221
222 //- Write the results entries for named object to stream
223 void writeResultEntries(const word& objectName, Ostream& os) const;
224
225 //- Write the results entries for all objects to stream
226 void writeAllResultEntries(Ostream& os) const;
227};
228
229
230// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
231
232} // End namespace functionObjects
233} // End namespace Foam
234
235// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
236
237#ifdef NoRepository
239#endif
240
241// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
242
243#endif
244
245// ************************************************************************* //
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:57
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Storage for function object properties, derived from IOdictionary. Provides functionality to read/wri...
void operator=(const properties &)=delete
No copy assignment.
void setObjectResult(const word &objectName, const word &entryName, const Type &value)
Add result from named object.
properties(const properties &)=delete
No copy construct.
Type getObjectProperty(const word &objectName, const word &entryName, const Type &defaultValue=Type(Zero)) const
Retrieve generic property from named object.
wordList objectNames() const
Return list of object names.
dictionary & propertyDict(const word &objectName)
Return access to the property dictionary.
dictionary & getObjectDict(const word &objectName)
Get dictionary for named object. Creates one if required.
bool setTrigger(const label triggeri)
Set new trigger index.
bool foundObjectProperty(const word &objectName, const word &entryName) const
Return true if the property exists.
bool hasResultObjectEntry(const word &objectName, const word &entryName) const
word objectResultType(const word &objectName, const word &entryName) const
Return the type of result.
void writeAllResultEntries(Ostream &os) const
Write the results entries for all objects to stream.
void setObjectProperty(const word &objectName, const word &entryName, const Type &value)
Add generic property from named object.
void writeResultEntries(Ostream &os) const
Write the results entries for all objects to stream.
bool hasResultObject(const word &objectName) const
Return true if the object with objectName exists in results.
bool hasObjectDict(const word &objectName) const
Return true if the object with objectName exists.
void clearTrigger()
Remove the trigger index from the properties.
wordList objectResultEntries(const word &objectName) const
Return result entries for named object.
virtual ~properties()=default
Destructor.
label getTrigger() const
Get the current trigger index.
wordList objectResultNames() const
Return list of objects with results.
Type getObjectResult(const word &objectName, const word &entryName, const Type &defaultValue=Type(Zero)) const
Retrieve result from named object.
A class for handling words, derived from Foam::string.
Definition: word.H:68
OBJstream os(runTime.globalPath()/outputName)
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
Namespace for OpenFOAM.
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
dictionary dict