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-2015 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::fieldMinMax
26 
27 Group
28  grpFieldFunctionObjects
29 
30 Description
31  This function object calculates the value and location of scalar minimim
32  and maximum for a list of user-specified fields. For variables with a rank
33  greater than zero, either the min/max of a component value or the magnitude
34  is reported. When operating in parallel, the processor owning the value
35  is also given.
36 
37  Example of function object specification:
38  \verbatim
39  fieldMinMax1
40  {
41  type fieldMinMax;
42  functionObjectLibs ("libfieldFunctionObjects.so");
43  ...
44  write yes;
45  log yes;
46  location yes;
47  mode magnitude;
48  fields
49  (
50  U
51  p
52  );
53  }
54  \endverbatim
55 
56  \heading Function object usage
57  \table
58  Property | Description | Required | Default value
59  type | type name: fieldMinMax | yes |
60  write | write min/max data to file | no | yes
61  log | write min/max data to standard output | no | no
62  location | write location of the min/max value | no | yes
63  mode | calculation mode: magnitude or component | no | magnitude
64  \endtable
65 
66  Output data is written to the file <timeDir>/fieldMinMax.dat
67 
68 SeeAlso
69  Foam::functionObject
70  Foam::OutputFilterFunctionObject
71 
72 SourceFiles
73  fieldMinMax.C
74  IOfieldMinMax.H
75 
76 \*---------------------------------------------------------------------------*/
77 
78 #ifndef fieldMinMax_H
79 #define fieldMinMax_H
80 
81 #include "functionObjectFile.H"
82 #include "Switch.H"
83 #include "vector.H"
84 
85 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
86 
87 namespace Foam
88 {
89 
90 // Forward declaration of classes
91 class objectRegistry;
92 class dictionary;
93 class polyMesh;
94 class mapPolyMesh;
95 
96 /*---------------------------------------------------------------------------*\
97  Class fieldMinMax Declaration
98 \*---------------------------------------------------------------------------*/
99 
100 class fieldMinMax
101 :
102  public functionObjectFile
103 {
104 public:
105 
106  enum modeType
107  {
108  mdMag,
109  mdCmpt
110  };
111 
112 protected:
113 
114  // Protected data
115 
116  //- Mode type names
117  static const NamedEnum<modeType, 2> modeTypeNames_;
118 
119  //- Name of this set of field min/max
120  // Also used as the name of the output directory
121  word name_;
122 
123  const objectRegistry& obr_;
124 
125  //- on/off switch
126  bool active_;
127 
128  //- Switch to send output to Info as well
130 
131  //- Switch to write location of min/max values
133 
134  //- Mode for min/max - only applicable for ranks > 0
136 
137  //- Fields to assess min/max
139 
140 
141  // Private Member Functions
142 
143  //- Helper function to write the output
144  template<class Type>
145  void output
146  (
147  const word& fieldName,
148  const word& outputName,
149  const vector& minC,
150  const vector& maxC,
151  const label minProcI,
152  const label maxProcI,
153  const Type& minValue,
154  const Type& maxValue
155  );
156 
157  //- Disallow default bitwise copy construct
159 
160  //- Disallow default bitwise assignment
161  void operator=(const fieldMinMax&);
162 
163  //- Output file header information
164  virtual void writeFileHeader(const label i);
165 
166 
167 public:
168 
169  //- Runtime type information
170  TypeName("fieldMinMax");
171 
172 
173  // Constructors
174 
175  //- Construct for given objectRegistry and dictionary.
176  // Allow the possibility to load fields from files
178  (
179  const word& name,
180  const objectRegistry&,
181  const dictionary&,
182  const bool loadFromFiles = false
183  );
184 
185 
186  //- Destructor
187  virtual ~fieldMinMax();
188 
189 
190  // Member Functions
191 
192  //- Return name of the set of field min/max
193  virtual const word& name() const
194  {
195  return name_;
196  }
197 
198  //- Read the field min/max data
199  virtual void read(const dictionary&);
200 
201  //- Execute, currently does nothing
202  virtual void execute();
203 
204  //- Execute at the final time-loop, currently does nothing
205  virtual void end();
206 
207  //- Called when time was set at the end of the Time::operator++
208  virtual void timeSet();
209 
210  //- Calculate the field min/max
211  template<class Type>
212  void calcMinMaxFields
213  (
214  const word& fieldName,
215  const modeType& mode
216  );
217 
218  //- Write the fieldMinMax
219  virtual void write();
220 
221  //- Update for changes of mesh
222  virtual void updateMesh(const mapPolyMesh&)
223  {}
224 
225  //- Update for changes of mesh
226  virtual void movePoints(const polyMesh&)
227  {}
228 };
229 
230 
231 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
232 
233 } // End namespace Foam
234 
235 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
236 
237 #ifdef NoRepository
238 # include "fieldMinMaxTemplates.C"
239 #endif
240 
241 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
242 
243 #endif
244 
245 // ************************************************************************* //
virtual void write()
Write the fieldMinMax.
Definition: fieldMinMax.C:171
virtual void updateMesh(const mapPolyMesh &)
Update for changes of mesh.
Definition: fieldMinMax.H:251
mode_t mode(const fileName &)
Return the file mode.
Definition: POSIX.C:574
modeType mode_
Mode for min/max - only applicable for ranks > 0.
Definition: fieldMinMax.H:164
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
virtual void end()
Execute at the final time-loop, currently does nothing.
Definition: fieldMinMax.C:159
word name_
Name of this set of field min/max.
Definition: fieldMinMax.H:150
Switch log_
Switch to send output to Info as well.
Definition: fieldMinMax.H:158
virtual void writeFileHeader(const label i)
Output file header information.
Definition: fieldMinMax.C:113
A class for handling words, derived from string.
Definition: word.H:59
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
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, y/n, t/f, or none.
Definition: Switch.H:60
scalar maxValue
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
void operator=(const fieldMinMax &)
Disallow default bitwise assignment.
fieldMinMax(const fieldMinMax &)
Disallow default bitwise copy construct.
Namespace for OpenFOAM.
scalar minValue
virtual const word & name() const
Return name of the set of field min/max.
Definition: fieldMinMax.H:222
wordList fieldSet_
Fields to assess min/max.
Definition: fieldMinMax.H:167
Switch location_
Switch to write location of min/max values.
Definition: fieldMinMax.H:161
virtual void execute()
Execute, currently does nothing.
Definition: fieldMinMax.C:153
virtual void read(const dictionary &)
Read the field min/max data.
Definition: fieldMinMax.C:100
virtual ~fieldMinMax()
Destructor.
Definition: fieldMinMax.C:94
virtual void timeSet()
Called when time was set at the end of the Time::operator++.
Definition: fieldMinMax.C:165
static const NamedEnum< modeType, 2 > modeTypeNames_
Mode type names.
Definition: fieldMinMax.H:146
void output(const word &fieldName, const word &outputName, const vector &minC, const vector &maxC, const label minProcI, const label maxProcI, const Type &minValue, const Type &maxValue)
Helper function to write the output.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
void calcMinMaxFields(const word &fieldName, const modeType &mode)
Calculate the field min/max.
TypeName("fieldMinMax")
Runtime type information.
Registry of regIOobjects.
This function object calculates the value and location of scalar minimim and maximum for a list of us...
Definition: fieldMinMax.H:129
const objectRegistry & obr_
Definition: fieldMinMax.H:152
bool active_
on/off switch
Definition: fieldMinMax.H:155
virtual void movePoints(const polyMesh &)
Update for changes of mesh.
Definition: fieldMinMax.H:255