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