multiFieldValue.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::fieldValues::multiFieldValue
28
29Group
30 grpFieldFunctionObjects
31
32Description
33 Computes a selected operation between multiple function objects.
34
35 The operation is applied to all results of each object.
36
37Note
38 Each object must generate the same number and type of results.
39
40Usage
41 Minimal example by using \c system/controlDict.functions:
42 \verbatim
43 multiFieldValue1
44 {
45 // Mandatory entries
46 type multiFieldValue;
47 libs (fieldFunctionObjects);
48 operation average;
49
50 // List of fieldValue function objects as dictionaries
51 functions
52 {
53 region1
54 {
55 ...
56 // Optional
57 resultFields (field1 field2);
58 }
59 region2
60 {
61 ...
62 // Optional
63 resultFields (field1 field2);
64 }
65
66 ...
67
68 regionN
69 {
70 ...
71 // Optional
72 resultFields (field1 field2);
73 }
74 }
75
76 // Inherited entries
77 ...
78 }
79 \endverbatim
80
81 where the entries mean:
82 \table
83 Property | Description | Type | Reqd | Deflt
84 type | Type name: multiFieldValue | word | yes | -
85 libs | Library name: fieldFunctionObjects | word | yes | -
86 operation | Operation type to apply to values | word | yes | -
87 functions | List of function objects | dict | yes | -
88 \endtable
89
90 Options for the \c operation entry:
91 \plaintable
92 sum | Sum of values
93 add | Add values (same as sum)
94 subtract | Subtract values from first entry
95 min | Minimum value
96 max | Maximum value
97 average | Average value
98 \endplaintable
99
100 The \c resultFields entry can be used to set the name of the function object
101 result fields to process. If omitted, all available values are employed.
102
103 The inherited entries are elaborated in:
104 - \link stateFunctionObject.H \endlink
105 - \link writeFile.H \endlink
106
107SourceFiles
108 multiFieldValue.C
109 multiFieldValueTemplates.C
110
111\*---------------------------------------------------------------------------*/
112
113#ifndef functionObjects_multiFieldValue_H
114#define functionObjects_multiFieldValue_H
115
116#include "stateFunctionObject.H"
117#include "writeFile.H"
118#include "Enum.H"
119
120// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
121
122namespace Foam
123{
124namespace functionObjects
125{
126namespace fieldValues
127{
128
129/*---------------------------------------------------------------------------*\
130 Class multiFieldValue Declaration
131\*---------------------------------------------------------------------------*/
132
133class multiFieldValue
134:
135 public functionObjects::stateFunctionObject,
136 public functionObjects::writeFile
137{
138public:
139
140 // Public Data Types
141
142 //- Operation type enumeration
143 enum operationType
144 {
145 opSum,
146 opAdd,
147 opSubtract,
148 opMin,
149 opMax,
150 opAverage
151 };
152
153 //- Operation type names
154 static const Enum<operationType> operationTypeNames_;
155
156
157private:
158
159 // Private Data
160
161 //- Operation to apply to values
162 operationType operation_;
163
164 //- List of function objects
165 PtrList<functionObject> functions_;
166
167 //- List of result fields per function object
168 List<wordList> resultFields_;
169
170
171 // Private Member Functions
172
173 //- Templated function to apply the operation.
174 // \return true if Type and resultType are correct
175 template<class Type>
176 bool applyOperation
177 (
178 const word& resultType,
179 const wordList& names,
180 const wordList& entryNames
181 );
182
183
184protected:
185
186 // Protected Member Functions
187
188 //- Output file header information
189 virtual void writeFileHeader
190 (
191 const wordList& foNames,
192 const List<wordList>& entries,
193 const List<wordList>& types,
194 Ostream& os
195 ) const;
197
198public:
200 //- Run-time type information
201 TypeName("multiFieldValue");
203
204 // Constructors
205
206 //- Construct from Time and dictionary
208 (
209 const word& name,
210 const Time& runTime,
211 const dictionary& dict
212 );
213
214 //- No copy construct
215 multiFieldValue(const multiFieldValue&) = delete;
216
217 //- No copy assignment
218 void operator=(const multiFieldValue&) = delete;
219
220
221 //- Destructor
222 virtual ~multiFieldValue() = default;
223
224
225 // Public Member Functions
226
227 //- Read from dictionary
228 virtual bool read(const dictionary& dict);
229
230 //- Do nothing
231 virtual bool execute();
232
233 //- Calculate and write
234 virtual bool write();
235};
236
237
238// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
239
240} // End namespace fieldValues
241} // End namespace functionObjects
242} // End namespace Foam
243
244// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
245
246#ifdef NoRepository
248#endif
249
250// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
251
252#endif
253
254// ************************************************************************* //
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition: Enum.H:61
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: PtrList.H:73
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:80
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
const word & name() const noexcept
Return the name of this functionObject.
Computes a selected operation between multiple function objects.
TypeName("multiFieldValue")
Run-time type information.
virtual bool read(const dictionary &dict)
Read from dictionary.
multiFieldValue(const multiFieldValue &)=delete
No copy construct.
virtual void writeFileHeader(const wordList &foNames, const List< wordList > &entries, const List< wordList > &types, Ostream &os) const
Output file header information.
void operator=(const multiFieldValue &)=delete
No copy assignment.
static const Enum< operationType > operationTypeNames_
Operation type names.
@ opSubtract
Subtract values from first entry.
Base class for function objects, adding functionality to read/write state information (data required ...
word resultType(const word &entryName) const
Retrieve the result type.
Base class for writing single files from the function objects.
Definition: writeFile.H:120
A class for handling words, derived from Foam::string.
Definition: word.H:68
engineTime & runTime
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
List< word > wordList
A List of words.
Definition: fileName.H:63
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73