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 -------------------------------------------------------------------------------
11 License
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 
27 Class
28  Foam::functionObjects::fieldMinMax
29 
30 Group
31  grpFieldFunctionObjects
32 
33 Description
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 
52 Usage
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 
89 See also
90  - Foam::functionObject
91  - Foam::functionObjects::fvMeshFunctionObject
92  - Foam::functionObjects::writeFile
93  - ExtendedCodeGuide::functionObjects::field::fieldMinMax
94 
95 SourceFiles
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 
113 namespace Foam
114 {
115 namespace functionObjects
116 {
117 
118 /*---------------------------------------------------------------------------*\
119  Class fieldMinMax Declaration
120 \*---------------------------------------------------------------------------*/
121 
122 class fieldMinMax
123 :
124  public fvMeshFunctionObject,
125  public writeFile
126 {
127 
128 public:
129 
130  // Public Enumerations
131 
132  enum modeType
133  {
134  mdMag,
135  mdCmpt
136  };
137 
138 
139 protected:
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
150  modeType mode_;
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  );
173 
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  );
185 
186  //- Calculate the field min/max
187  template<class Type>
188  void calcMinMaxFields
189  (
190  const word& fieldName,
191  const modeType& mode
192  );
193 
194 
195 public:
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
249 
250 // ************************************************************************* //
runTime
engineTime & runTime
Definition: createEngineTime.H:13
Foam::functionObjects::fieldMinMax::mdCmpt
component
Definition: fieldMinMax.H:186
writeFile.H
fieldMinMaxTemplates.C
Foam::Enum< modeType >
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::fieldMinMax
Computes the values and locations of field minima and maxima. These are good indicators of calculatio...
Definition: fieldMinMax.H:173
fvMeshFunctionObject.H
Foam::functionObjects::fieldMinMax::calcMinMaxFieldType
void calcMinMaxFieldType(const GeometricField< Type, fvPatchField, volMesh > &field, const word &outputFieldName)
Calculate the field min/max for a given field type.
Definition: fieldMinMaxTemplates.C:118
Foam::functionObjects::fieldMinMax::execute
virtual bool execute()
Execute, currently does nothing.
Definition: fieldMinMax.C:145
Foam::functionObjects::fieldMinMax::fieldSet_
volFieldSelection fieldSet_
Fields to assess min/max.
Definition: fieldMinMax.H:204
Foam::functionObjects::fvMeshFunctionObject
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Definition: fvMeshFunctionObject.H:64
Foam::functionObjects::fieldMinMax::write
virtual bool write()
Write the fieldMinMax.
Definition: fieldMinMax.C:151
Foam::mode
mode_t mode(const fileName &name, const bool followLink=true)
Return the file mode, normally following symbolic links.
Definition: MSwindows.C:564
outputName
word outputName("finiteArea-edges.obj")
Foam::functionObjects::fieldMinMax::modeType
modeType
Definition: fieldMinMax.H:183
Foam::functionObjects::volFieldSelection
Helper class to manage solver field selections.
Definition: volFieldSelection.H:52
Foam::functionObjects::fieldMinMax::writeFileHeader
virtual void writeFileHeader(Ostream &os)
Output file header information.
Definition: fieldMinMax.C:57
Foam::functionObjects::fieldMinMax::mode_
modeType mode_
Mode for min/max - only applicable for ranks > 0.
Definition: fieldMinMax.H:201
Foam::functionObjects::fieldMinMax::output
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.
Definition: fieldMinMaxTemplates.C:36
Switch.H
field
rDeltaTY field()
Foam::functionObjects::fieldMinMax::fieldMinMax
fieldMinMax(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: fieldMinMax.C:112
Foam::functionObjects::fieldMinMax::TypeName
TypeName("fieldMinMax")
Runtime type information.
Foam::functionObjects::fieldMinMax::operator=
void operator=(const fieldMinMax &)=delete
No copy assignment.
Foam::functionObjects::fieldMinMax::calcMinMaxFields
void calcMinMaxFields(const word &fieldName, const modeType &mode)
Calculate the field min/max.
Definition: fieldMinMaxTemplates.C:231
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::functionObjects::fieldMinMax::mdMag
magnitude
Definition: fieldMinMax.H:185
Foam::functionObjects::fieldMinMax::modeTypeNames_
static const Enum< modeType > modeTypeNames_
Mode type names.
Definition: fieldMinMax.H:195
Foam::functionObjects::fieldMinMax::location_
bool location_
Flag to write location of min/max values.
Definition: fieldMinMax.H:198
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
volFieldSelection.H
Foam::vector
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:51
Foam::functionObjects::fieldMinMax::read
virtual bool read(const dictionary &)
Read the field min/max data.
Definition: fieldMinMax.C:130
Foam::functionObject::name
const word & name() const noexcept
Return the name of this functionObject.
Definition: functionObject.C:143
Foam::Vector< scalar >
Foam::functionObjects::fieldMinMax::~fieldMinMax
virtual ~fieldMinMax()=default
Destructor.
vector.H
minValue
scalar minValue
Definition: LISASMDCalcMethod2.H:12
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::GeometricField< Type, fvPatchField, volMesh >
maxValue
scalar maxValue
Definition: LISASMDCalcMethod1.H:5
Enum.H