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