Loading...
Searching...
No Matches
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 | postProcessing/<FO>/<time>/file
49 output field | - | -
50 \endtable
51
52Usage
53 Minimal example by using \c system/controlDict.functions:
54 \verbatim
55 fieldMinMaxFO
56 {
57 // Mandatory entries
58 type fieldMinMax;
59 libs (fieldFunctionObjects);
60 mode <word>; // magnitude;
61 fields (<wordList>); // (<field1> <field2> ... <fieldN>);
62
63 // Optional entries
64 location <bool>;
65
66 // Inherited entries
67 ...
68 }
69 \endverbatim
70
71 where the entries mean:
72 \table
73 Property | Description | Type | Reqd | Deflt
74 type | Type name: fieldMinMax | word | yes | -
75 libs | Library name: fieldFunctionObjects | word | yes | -
76 fields | List of operand fields | wordList | yes | -
77 location | Write location of the min/max value | bool | no | true
78 mode | Calculation mode: magnitude or component | word | no | magnitude
79 \endtable
80
81 The inherited entries are elaborated in:
82 - \link functionObject.H \endlink
83 - \link writeFile.H \endlink
84
85SourceFiles
86 fieldMinMax.C
87 fieldMinMaxTemplates.C
88
89\*---------------------------------------------------------------------------*/
90
91#ifndef Foam_functionObjects_fieldMinMax_H
92#define Foam_functionObjects_fieldMinMax_H
93
94#include "Switch.H"
95#include "Enum.H"
97#include "writeFile.H"
98#include "vector.H"
99#include "volFieldSelection.H"
100
101// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
102
103namespace Foam
104{
105namespace functionObjects
106{
107
108/*---------------------------------------------------------------------------*\
109 Class fieldMinMax Declaration
110\*---------------------------------------------------------------------------*/
111
112class fieldMinMax
113:
115 public writeFile
116{
117
118public:
119
120 // Public Enumerations
121
122 //- Options for the mode types
123 enum modeType
124 {
125 mdMag,
126 mdCmpt
127 };
128
129
130protected:
131
132 // Protected Data
133
134 //- Mode type names
135 static const Enum<modeType> modeTypeNames_;
136
137 //- Flag to write location of min/max values
138 bool location_;
139
140 //- Mode for min/max - only applicable for ranks > 0
142
143 //- Fields to assess min/max
144 volFieldSelection fieldSet_;
145
146
147 // Protected Member Functions
148
149 //- Helper function to write the output
150 template<class Type>
151 void output
152 (
153 const word& fieldName,
154 const word& outputName,
155 const label minCell,
156 const label maxCell,
157 const vector& minC,
158 const vector& maxC,
159 const label minProci,
160 const label maxProci,
161 const Type& minValue,
162 const Type& maxValue
163 );
164
165
166 //- Output file header information
167 virtual void writeFileHeader(Ostream& os);
168
169 //- Calculate the field min/max for a given field type
170 template<class Type>
174 const word& outputFieldName
175 );
176
177 //- Calculate the field min/max
178 template<class Type>
180 (
181 const word& fieldName,
182 const modeType& mode
183 );
184
185
186public:
187
188 //- Runtime type information
189 TypeName("fieldMinMax");
190
192 // Constructors
193
194 //- Construct from name, Time and dictionary
197 const word& name,
198 const Time& runTime,
199 const dictionary& dict
200 );
202 //- No copy construct
203 fieldMinMax(const fieldMinMax&) = delete;
204
205 //- No copy assignment
206 void operator=(const fieldMinMax&) = delete;
207
208
209 //- Destructor
210 virtual ~fieldMinMax() = default;
211
212
213 // Member Functions
214
215 //- Read the function-object dictionary
216 virtual bool read(const dictionary& dict);
217
218 //- Execute the function-object operations
219 virtual bool execute();
220
221 //- Write the function-object results
222 virtual bool write();
223};
224
225
226// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
227
228} // End namespace functionObjects
229} // End namespace Foam
230
231// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
232
233#ifdef NoRepository
234 #include "fieldMinMaxTemplates.C"
235#endif
236
237// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
238
239#endif
240
241// ************************************************************************* //
scalar maxValue
scalar minValue
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition Enum.H:57
Generic GeometricField class.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
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
Computes the values and locations of field minima and maxima. These are good indicators of calculatio...
volFieldSelection fieldSet_
Fields to assess min/max.
bool location_
Flag to write location of min/max values.
void operator=(const fieldMinMax &)=delete
No copy assignment.
modeType mode_
Mode for min/max - only applicable for ranks > 0.
fieldMinMax(const word &name, const Time &runTime, const dictionary &dict)
Construct from name, Time and dictionary.
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.
virtual bool read(const dictionary &dict)
Read the function-object dictionary.
static const Enum< modeType > modeTypeNames_
Mode type names.
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.
modeType
Options for the mode types.
TypeName("fieldMinMax")
Runtime type information.
virtual void writeFileHeader(Ostream &os)
Output file header information.
Definition fieldMinMax.C:50
virtual bool execute()
Execute the function-object operations.
virtual bool write()
Write the function-object results.
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
fvMeshFunctionObject(const fvMeshFunctionObject &)=delete
No copy construct.
Helper class to manage solver field selections.
Base class for writing single files from the function objects.
Definition writeFile.H:113
writeFile(const objectRegistry &obr, const fileName &prefix, const word &name="undefined", const bool writeToFile=true, const string &ext=".dat")
Construct from objectRegistry, prefix, fileName.
Definition writeFile.C:200
A class for handling words, derived from Foam::string.
Definition word.H:66
rDeltaTY field()
engineTime & runTime
word outputName("finiteArea-edges.obj")
OBJstream os(runTime.globalPath()/outputName)
Function objects are OpenFOAM utilities to ease workflow configurations and enhance workflows.
Namespace for OpenFOAM.
mode_t mode(const fileName &name, const bool followLink=true)
Return the file mode, normally following symbolic links.
Definition POSIX.C:775
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
Vector< scalar > vector
Definition vector.H:57
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68