fieldMinMax.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2019 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 Description
28  Calculates the value and location of scalar minimum and maximum for a list
29  of user-specified fields.
30 
31  For variables with a rank greater than zero, either the min/max of a
32  component value or the magnitude is reported. When operating in parallel,
33  the processor owning the value is also given.
34 
35  Example of function object specification:
36  \verbatim
37  fieldMinMax1
38  {
39  type fieldMinMax;
40  libs ("libfieldFunctionObjects.so");
41  ...
42  log yes;
43  location yes;
44  mode magnitude;
45  fields
46  (
47  U
48  p
49  );
50  }
51  \endverbatim
52 
53 Usage
54  \table
55  Property | Description | Required | Default value
56  type | type name: fieldMinMax | yes |
57  log | write min/max data to standard output | no | no
58  location | write location of the min/max value | no | yes
59  mode | calculation mode: magnitude or component | no | magnitude
60  \endtable
61 
62  Output data is written to the file <timeDir>/fieldMinMax.dat
63 
64 See also
65  Foam::functionObjects::fvMeshFunctionObject
66  Foam::functionObjects::logFiles
67 
68 SourceFiles
69  fieldMinMax.C
70 
71 \*---------------------------------------------------------------------------*/
72 
73 #ifndef functionObjects_fieldMinMax_H
74 #define functionObjects_fieldMinMax_H
75 
76 #include "fvMeshFunctionObject.H"
77 #include "logFiles.H"
78 #include "vector.H"
79 
80 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
81 
82 namespace Foam
83 {
84 namespace functionObjects
85 {
86 
87 /*---------------------------------------------------------------------------*\
88  Class fieldMinMax Declaration
89 \*---------------------------------------------------------------------------*/
90 
91 class fieldMinMax
92 :
93  public fvMeshFunctionObject,
94  public logFiles
95 {
96 public:
97 
98  enum class modeType
99  {
100  mag,
101  cmpt
102  };
103 
104 protected:
105 
106  // Protected data
107 
108  //- Mode type names
109  static const NamedEnum<modeType, 2> modeTypeNames_;
110 
111  //- Switch to write location of min/max values
112  Switch location_;
113 
114  //- Mode for min/max - only applicable for ranks > 0
116 
117  //- Fields to assess min/max
119 
120 
121  // Protected Member Functions
123  //- Helper function to write the output
124  template<class Type>
125  void output
126  (
127  const word& fieldName,
128  const word& outputName,
129  const label minCell,
130  const label maxCell,
131  const vector& minC,
132  const vector& maxC,
133  const label minProci,
134  const label maxProci,
135  const Type& minValue,
136  const Type& maxValue
137  );
138 
139  //- Calculate the field min/max
140  template<class Type>
141  void calcMinMaxFields
142  (
143  const word& fieldName,
144  const modeType& mode
145  );
146 
147  //- Output file header information
148  virtual void writeFileHeader(const label i);
149 
150 
151 public:
152 
153  //- Runtime type information
154  TypeName("fieldMinMax");
155 
156 
157  // Constructors
158 
159  //- Construct from Time and dictionary
161  (
162  const word& name,
163  const Time& runTime,
164  const dictionary& dict
165  );
166 
167  //- Disallow default bitwise copy construction
168  fieldMinMax(const fieldMinMax&) = delete;
169 
170 
171  //- Destructor
172  virtual ~fieldMinMax();
173 
174 
175  // Member Functions
176 
177  //- Read the field min/max data
178  virtual bool read(const dictionary&);
179 
180  //- Execute, currently does nothing
181  virtual bool execute();
182 
183  //- Write the fieldMinMax
184  virtual bool write();
185 
186 
187  // Member Operators
188 
189  //- Disallow default bitwise assignment
190  void operator=(const fieldMinMax&) = delete;
191 };
192 
193 
194 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
195 
196 } // End namespace functionObjects
197 } // End namespace Foam
198 
199 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
200 
201 #ifdef NoRepository
202  #include "fieldMinMaxTemplates.C"
203 #endif
204 
205 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
206 
207 #endif
208 
209 // ************************************************************************* //
virtual bool write()
Write the fieldMinMax.
Definition: fieldMinMax.C:144
dictionary dict
mode_t mode(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file mode.
Definition: POSIX.C:461
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:158
scalar minValue
engineTime & runTime
fieldMinMax(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: fieldMinMax.C:100
wordList fieldSet_
Fields to assess min/max.
Definition: fieldMinMax.H:142
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 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
void operator=(const fieldMinMax &)=delete
Disallow default bitwise assignment.
virtual ~fieldMinMax()
Destructor.
Definition: fieldMinMax.C:119
Switch location_
Switch to write location of min/max values.
Definition: fieldMinMax.H:136
static const NamedEnum< modeType, 2 > modeTypeNames_
Mode type names.
Definition: fieldMinMax.H:133
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 mode_
Mode for min/max - only applicable for ranks > 0.
Definition: fieldMinMax.H:139
Calculates the value and location of scalar minimum and maximum for a list of user-specified fields...
Definition: fieldMinMax.H:115
TypeName("fieldMinMax")
Runtime type information.
Namespace for OpenFOAM.