fieldMinMax.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) 2011-2017 OpenFOAM Foundation
9 Copyright (C) 2015-2020 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::functionObjects::fieldMinMax
29
30Group
31 grpFieldFunctionObjects
32
33Description
34 Computes the values and locations of field minima and maxima.
35 These are good indicators of calculation performance, e.g. to confirm that
36 predicted results are within expected bounds, or how well a case is
37 converging.
38
39 Multiple fields can be processed, where for rank > 0 primitives, e.g.
40 vectors and tensors, the extrema can be calculated per component, or by
41 magnitude. In addition, spatial location and local processor index are
42 included in the output.
43
44 Operands:
45 \table
46 Operand | Type | Location
47 input | - | -
48 output file | dat | $FOAM_CASE/postProcessing/<FO>/<time>/<file>
49 output field | - | -
50 \endtable
51
52Usage
53 Minimal example by using \c system/controlDict.functions:
54 \verbatim
55 fieldMinMax1
56 {
57 // Mandatory entries (unmodifiable)
58 type fieldMinMax;
59 libs (fieldFunctionObjects);
60
61 // Mandatory entries (runtime modifiable)
62 mode magnitude;
63 fields (<field1> <field2> ... <fieldN>);
64
65 // Optional entries (runtime modifiable)
66 location true;
67
68 // Optional (inherited) entries
69 ...
70 }
71 \endverbatim
72
73 where the entries mean:
74 \table
75 Property | Description | Type | Req'd | Dflt
76 type | Type name: fieldMinMax | word | yes | -
77 libs | Library name: fieldFunctionObjects | word | yes | -
78 fields | List of operand fields | wordList | yes | -
79 location | Write location of the min/max value | bool | no | true
80 mode | Calculation mode: magnitude or component | word | no | magnitude
81 \endtable
82
83 The inherited entries are elaborated in:
84 - \link functionObject.H \endlink
85 - \link writeFile.H \endlink
86
87 Usage by the \c postProcess utility is not available.
88
89See also
90 - Foam::functionObject
91 - Foam::functionObjects::fvMeshFunctionObject
92 - Foam::functionObjects::writeFile
93 - ExtendedCodeGuide::functionObjects::field::fieldMinMax
94
95SourceFiles
96 fieldMinMax.C
97 fieldMinMaxTemplates.C
98
99\*---------------------------------------------------------------------------*/
100
101#ifndef functionObjects_fieldMinMax_H
102#define functionObjects_fieldMinMax_H
103
104#include "Switch.H"
105#include "Enum.H"
106#include "fvMeshFunctionObject.H"
107#include "writeFile.H"
108#include "vector.H"
109#include "volFieldSelection.H"
110
111// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
112
113namespace Foam
114{
115namespace functionObjects
116{
117
118/*---------------------------------------------------------------------------*\
119 Class fieldMinMax Declaration
120\*---------------------------------------------------------------------------*/
121
122class fieldMinMax
123:
124 public fvMeshFunctionObject,
125 public writeFile
126{
127
128public:
129
130 // Public Enumerations
131
132 enum modeType
133 {
134 mdMag,
135 mdCmpt
136 };
137
138
139protected:
140
141 // Protected Data
142
143 //- Mode type names
144 static const Enum<modeType> modeTypeNames_;
145
146 //- Flag to write location of min/max values
147 bool location_;
148
149 //- Mode for min/max - only applicable for ranks > 0
151
152 //- Fields to assess min/max
153 volFieldSelection fieldSet_;
154
155
156 // Protected Member Functions
157
158 //- Helper function to write the output
159 template<class Type>
160 void output
161 (
162 const word& fieldName,
163 const word& outputName,
164 const label minCell,
165 const label maxCell,
166 const vector& minC,
167 const vector& maxC,
168 const label minProci,
169 const label maxProci,
170 const Type& minValue,
171 const Type& maxValue
172 );
174
175 //- Output file header information
176 virtual void writeFileHeader(Ostream& os);
177
178 //- Calculate the field min/max for a given field type
179 template<class Type>
181 (
183 const word& outputFieldName
184 );
186 //- Calculate the field min/max
187 template<class Type>
189 (
190 const word& fieldName,
191 const modeType& mode
192 );
193
194
195public:
196
197 //- Runtime type information
198 TypeName("fieldMinMax");
199
200
201 // Constructors
202
203 //- Construct from Time and dictionary
205 (
206 const word& name,
207 const Time& runTime,
208 const dictionary& dict
209 );
210
211 //- No copy construct
212 fieldMinMax(const fieldMinMax&) = delete;
213
214 //- No copy assignment
215 void operator=(const fieldMinMax&) = delete;
216
217
218 //- Destructor
219 virtual ~fieldMinMax() = default;
220
221
222 // Member Functions
223
224 //- Read the field min/max data
225 virtual bool read(const dictionary&);
226
227 //- Execute, currently does nothing
228 virtual bool execute();
229
230 //- Write the fieldMinMax
231 virtual bool write();
232};
233
234
235// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
236
237} // End namespace functionObjects
238} // End namespace Foam
239
240// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
241
242#ifdef NoRepository
243 #include "fieldMinMaxTemplates.C"
244#endif
245
246// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
247
248#endif
250// ************************************************************************* //
scalar maxValue
scalar minValue
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition: Enum.H:61
Generic GeometricField class.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
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 the values and locations of field minima and maxima. These are good indicators of calculatio...
Definition: fieldMinMax.H:177
volFieldSelection fieldSet_
Fields to assess min/max.
Definition: fieldMinMax.H:204
bool location_
Flag to write location of min/max values.
Definition: fieldMinMax.H:198
void operator=(const fieldMinMax &)=delete
No copy assignment.
modeType mode_
Mode for min/max - only applicable for ranks > 0.
Definition: fieldMinMax.H:201
fieldMinMax(const fieldMinMax &)=delete
No copy construct.
void calcMinMaxFields(const word &fieldName, const modeType &mode)
Calculate the field min/max.
virtual ~fieldMinMax()=default
Destructor.
void calcMinMaxFieldType(const GeometricField< Type, fvPatchField, volMesh > &field, const word &outputFieldName)
Calculate the field min/max for a given field type.
static const Enum< modeType > modeTypeNames_
Mode type names.
Definition: fieldMinMax.H:195
void output(const word &fieldName, const word &outputName, const label minCell, const label maxCell, const vector &minC, const vector &maxC, const label minProci, const label maxProci, const Type &minValue, const Type &maxValue)
Helper function to write the output.
TypeName("fieldMinMax")
Runtime type information.
virtual void writeFileHeader(Ostream &os)
Output file header information.
Definition: fieldMinMax.C:57
virtual bool execute()
Execute, currently does nothing.
Definition: fieldMinMax.C:145
virtual bool write()
Write the fieldMinMax.
Definition: fieldMinMax.C:151
virtual bool read(const dictionary &)
Read the field min/max data.
Definition: fieldMinMax.C:130
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Helper class to manage solver field selections.
Base class for writing single files from the function objects.
Definition: writeFile.H:120
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
A class for handling words, derived from Foam::string.
Definition: word.H:68
rDeltaTY field()
engineTime & runTime
word outputName("finiteArea-edges.obj")
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
mode_t mode(const fileName &name, const bool followLink=true)
Return the file mode, normally following symbolic links.
Definition: MSwindows.C:572
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73