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 | Copyright (C) 2011-2017 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::functionObjects::fieldMinMax
26 
27 Group
28  grpFieldFunctionObjects
29 
30 Description
31  Calculates the value and location of scalar minimum and maximum for a list
32  of user-specified fields.
33 
34  For variables with a rank greater than zero, either the min/max of a
35  component value or the magnitude is reported. When operating in parallel,
36  the processor owning the value is also given.
37 
38  Example of function object specification:
39  \verbatim
40  fieldMinMax1
41  {
42  type fieldMinMax;
43  libs ("libfieldFunctionObjects.so");
44  ...
45  write yes;
46  log yes;
47  location yes;
48  mode magnitude;
49  fields
50  (
51  U
52  p
53  );
54  }
55  \endverbatim
56 
57 Usage
58  \table
59  Property | Description | Required | Default value
60  type | type name: fieldMinMax | yes |
61  write | write min/max data to file | no | yes
62  log | write min/max data to standard output | no | no
63  location | write location of the min/max value | no | yes
64  mode | calculation mode: magnitude or component | no | magnitude
65  \endtable
66 
67  Output data is written to the file <timeDir>/fieldMinMax.dat
68 
69 See also
70  Foam::functionObjects::fvMeshFunctionObject
71  Foam::functionObjects::logFiles
72 
73 SourceFiles
74  fieldMinMax.C
75 
76 \*---------------------------------------------------------------------------*/
77 
78 #ifndef functionObjects_fieldMinMax_H
79 #define functionObjects_fieldMinMax_H
80 
81 #include "fvMeshFunctionObject.H"
82 #include "logFiles.H"
83 #include "vector.H"
84 
85 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
86 
87 namespace Foam
88 {
89 namespace functionObjects
90 {
91 
92 /*---------------------------------------------------------------------------*\
93  Class fieldMinMax Declaration
94 \*---------------------------------------------------------------------------*/
95 
96 class fieldMinMax
97 :
98  public fvMeshFunctionObject,
99  public logFiles
100 {
101 public:
102 
103  enum modeType
104  {
105  mdMag,
106  mdCmpt
107  };
108 
109 protected:
110 
111  // Protected data
112 
113  //- Mode type names
114  static const NamedEnum<modeType, 2> modeTypeNames_;
115 
116  //- Switch to write location of min/max values
117  Switch location_;
118 
119  //- Mode for min/max - only applicable for ranks > 0
120  modeType mode_;
121 
122  //- Fields to assess min/max
124 
126  // Protected Member Functions
127 
128  //- Helper function to write the output
129  template<class Type>
130  void output
131  (
132  const word& fieldName,
133  const word& outputName,
134  const label minCell,
135  const label maxCell,
136  const vector& minC,
137  const vector& maxC,
138  const label minProci,
139  const label maxProci,
140  const Type& minValue,
141  const Type& maxValue
142  );
144  //- Disallow default bitwise copy construct
145  fieldMinMax(const fieldMinMax&);
147  //- Disallow default bitwise assignment
148  void operator=(const fieldMinMax&);
150  //- Calculate the field min/max
151  template<class Type>
153  (
154  const word& fieldName,
155  const modeType& mode
156  );
157 
158  //- Output file header information
159  virtual void writeFileHeader(const label i);
160 
161 
162 public:
163 
164  //- Runtime type information
165  TypeName("fieldMinMax");
166 
167 
168  // Constructors
169 
170  //- Construct from Time and dictionary
172  (
173  const word& name,
174  const Time& runTime,
175  const dictionary& dict
176  );
177 
178 
179  //- Destructor
180  virtual ~fieldMinMax();
181 
182 
183  // Member Functions
184 
185  //- Read the field min/max data
186  virtual bool read(const dictionary&);
187 
188  //- Execute, currently does nothing
189  virtual bool execute();
190 
191  //- Write the fieldMinMax
192  virtual bool write();
193 };
194 
195 
196 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
197 
198 } // End namespace functionObjects
199 } // End namespace Foam
200 
201 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
202 
203 #ifdef NoRepository
204  #include "fieldMinMaxTemplates.C"
205 #endif
206 
207 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
208 
209 #endif
210 
211 // ************************************************************************* //
virtual bool write()
Write the fieldMinMax.
Definition: fieldMinMax.C:144
dictionary dict
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
virtual bool execute()
Execute, currently does nothing.
Definition: fieldMinMax.C:138
const word & name() const
Return the name of this functionObject.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
fieldMinMax(const fieldMinMax &)
Disallow default bitwise copy construct.
scalar minValue
wordList fieldSet_
Fields to assess min/max.
Definition: fieldMinMax.H:152
virtual void writeFileHeader(const label i)
Output file header information.
Definition: fieldMinMax.C:57
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
void operator=(const fieldMinMax &)
Disallow default bitwise assignment.
void calcMinMaxFields(const word &fieldName, const modeType &mode)
Calculate the field min/max.
scalar maxValue
virtual bool read(const dictionary &)
Read the field min/max data.
Definition: fieldMinMax.C:125
A class for handling words, derived from string.
Definition: word.H:59
mode_t mode(const fileName &, const bool followLink=true)
Return the file mode.
Definition: POSIX.C:467
virtual ~fieldMinMax()
Destructor.
Definition: fieldMinMax.C:119
Switch location_
Switch to write location of min/max values.
Definition: fieldMinMax.H:146
static const NamedEnum< modeType, 2 > modeTypeNames_
Mode type names.
Definition: fieldMinMax.H:143
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.
List< word > wordList
A List of words.
Definition: fileName.H:54
modeType mode_
Mode for min/max - only applicable for ranks > 0.
Definition: fieldMinMax.H:149
Calculates the value and location of scalar minimum and maximum for a list of user-specified fields...
Definition: fieldMinMax.H:125
TypeName("fieldMinMax")
Runtime type information.
Namespace for OpenFOAM.