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 | Copyright (C) 2015 OpenCFD Ltd.
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 position 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  writeToFile yes;
45  log yes;
46  writeLocation yes;
47  mode magnitude;
48  fields (U p);
49  }
50  \endverbatim
51 
52  \heading Function object usage
53  \table
54  Property | Description | Required | Default value
55  type | type name: fieldMinMax | yes |
56  writeToFile | write min/max data to file | no | yes
57  log | write min/max data to standard output | no | yes
58  writeLocation | write location of the min/max value | no | yes
59  mode | calculation mode: magnitude or component | no | magnitude
60  fields | list of fields to process | yes |
61  \endtable
62 
63  Output data is written to the file <timeDir>/fieldMinMax.dat
64 
65 SeeAlso
66  Foam::functionObject
67  Foam::functionObjectFile
68  Foam::functionObjectState
69  Foam::OutputFilterFunctionObject
70 
71 SourceFiles
72  fieldMinMax.C
73  fieldMinMaxTemplates.C
74  IOfieldMinMax.H
75 
76 \*---------------------------------------------------------------------------*/
77 
78 #ifndef fieldMinMax_H
79 #define fieldMinMax_H
80 
81 #include "functionObjectState.H"
82 #include "functionObjectFile.H"
83 #include "Switch.H"
84 #include "NamedEnum.H"
85 #include "vector.H"
86 
87 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
88 
89 namespace Foam
90 {
91 
92 // Forward declaration of classes
93 class objectRegistry;
94 class dictionary;
95 class polyMesh;
96 class mapPolyMesh;
97 
98 /*---------------------------------------------------------------------------*\
99  Class fieldMinMax Declaration
100 \*---------------------------------------------------------------------------*/
101 
102 class fieldMinMax
103 :
104  public functionObjectState,
105  public functionObjectFile
106 {
107 public:
108 
109  // Public enumerations
110 
111  enum modeType
112  {
113  mdMag, // magnitude
114  mdCmpt // component
115  };
116 
117 
118 protected:
119 
120  // Protected data
121 
122  //- Mode type names
123  static const NamedEnum<modeType, 2> modeTypeNames_;
124 
125  //- Reference to the database
126  const objectRegistry& obr_;
127 
128  //- Switch to send output to Info as well
129  Switch log_;
130 
131  //- Switch to write location of min/max values
132  Switch writeLocation_;
133 
134  //- Mode for min/max - only applicable for ranks > 0
135  modeType mode_;
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 
158  //- Output file header information
159  virtual void writeFileHeader(Ostream& os) const;
160 
161  //- Disallow default bitwise copy construct
162  fieldMinMax(const fieldMinMax&);
163 
164  //- Disallow default bitwise assignment
165  void operator=(const fieldMinMax&);
166 
167 
168 public:
169 
170  //- Runtime type information
171  TypeName("fieldMinMax");
172 
173 
174  // Constructors
175 
176  //- Construct for given objectRegistry and dictionary.
177  // Allow the possibility to load fields from files
179  (
180  const word& name,
181  const objectRegistry&,
182  const dictionary&,
183  const bool loadFromFiles = false
184  );
185 
186 
187  //- Destructor
188  virtual ~fieldMinMax();
189 
190 
191  // Member Functions
192 
193  //- Read the field min/max data
194  virtual void read(const dictionary&);
195 
196  //- Execute, currently does nothing
197  virtual void execute();
198 
199  //- Execute at the final time-loop, currently does nothing
200  virtual void end();
201 
202  //- Called when time was set at the end of the Time::operator++
203  virtual void timeSet();
204 
205  //- Calculate the field min/max
206  template<class Type>
207  void calcMinMaxFields
208  (
209  const word& fieldName,
210  const modeType& mode
211  );
212 
213  //- Write the fieldMinMax
214  virtual void write();
215 
216  //- Update for changes of mesh
217  virtual void updateMesh(const mapPolyMesh&)
218  {}
219 
220  //- Update for changes of mesh
221  virtual void movePoints(const polyMesh&)
222  {}
223 };
224 
225 
226 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
227 
228 } // End namespace Foam
229 
230 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
231 
232 #ifdef NoRepository
233 # include "fieldMinMaxTemplates.C"
234 #endif
235 
236 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
237 
238 #endif
239 
240 // ************************************************************************* //
fieldMinMaxTemplates.C
Foam::Switch
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:60
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::fieldMinMax::timeSet
virtual void timeSet()
Called when time was set at the end of the Time::operator++.
Definition: fieldMinMax.C:153
Foam::functionObjectState
Base class for function objects, adding functionality to read/write state information (data required ...
Definition: functionObjectState.H:54
Foam::fieldMinMax::obr_
const objectRegistry & obr_
Reference to the database.
Definition: fieldMinMax.H:160
Foam::fieldMinMax::calcMinMaxFields
void calcMinMaxFields(const word &fieldName, const modeType &mode)
Calculate the field min/max.
Definition: fieldMinMaxTemplates.C:112
Foam::fieldMinMax::~fieldMinMax
virtual ~fieldMinMax()
Destructor.
Definition: fieldMinMax.C:120
NamedEnum.H
functionObjectState.H
Foam::fieldMinMax::output
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.
Definition: fieldMinMaxTemplates.C:33
Foam::fieldMinMax::mdMag
@ mdMag
Definition: fieldMinMax.H:147
Foam::fieldMinMax::modeType
modeType
Definition: fieldMinMax.H:145
Foam::mode
mode_t mode(const fileName &)
Return the file mode.
Definition: POSIX.C:573
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Foam::fieldMinMax::updateMesh
virtual void updateMesh(const mapPolyMesh &)
Update for changes of mesh.
Definition: fieldMinMax.H:251
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:50
Foam::label
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
Foam::fieldMinMax::fieldSet_
wordList fieldSet_
Fields to assess min/max.
Definition: fieldMinMax.H:172
Foam::fieldMinMax::mode_
modeType mode_
Mode for min/max - only applicable for ranks > 0.
Definition: fieldMinMax.H:169
Foam::fieldMinMax
This function object calculates the value and position of scalar minimim and maximum for a list of us...
Definition: fieldMinMax.H:136
Foam::fieldMinMax::read
virtual void read(const dictionary &)
Read the field min/max data.
Definition: fieldMinMax.C:126
Switch.H
Foam::fieldMinMax::movePoints
virtual void movePoints(const polyMesh &)
Update for changes of mesh.
Definition: fieldMinMax.H:255
Foam::fieldMinMax::execute
virtual void execute()
Execute, currently does nothing.
Definition: fieldMinMax.C:141
Foam::fieldMinMax::end
virtual void end()
Execute at the final time-loop, currently does nothing.
Definition: fieldMinMax.C:147
Foam::fieldMinMax::write
virtual void write()
Write the fieldMinMax.
Definition: fieldMinMax.C:159
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::fieldMinMax::operator=
void operator=(const fieldMinMax &)
Disallow default bitwise assignment.
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::fieldMinMax::log_
Switch log_
Switch to send output to Info as well.
Definition: fieldMinMax.H:163
Foam::fieldMinMax::mdCmpt
@ mdCmpt
Definition: fieldMinMax.H:148
functionObjectFile.H
Foam::fieldMinMax::fieldMinMax
fieldMinMax(const fieldMinMax &)
Disallow default bitwise copy construct.
Foam::Vector< scalar >
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::functionObjectFile
Base class for output file data handling.
Definition: functionObjectFile.H:57
vector.H
minValue
scalar minValue
Definition: LISASMDCalcMethod2.H:12
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::fieldMinMax::writeLocation_
Switch writeLocation_
Switch to write location of min/max values.
Definition: fieldMinMax.H:166
Foam::fieldMinMax::TypeName
TypeName("fieldMinMax")
Runtime type information.
Foam::fieldMinMax::modeTypeNames_
static const NamedEnum< modeType, 2 > modeTypeNames_
Mode type names.
Definition: fieldMinMax.H:157
Foam::functionObjectState::name
const word & name() const
Return the name.
Definition: functionObjectState.C:58
Foam::fieldMinMax::writeFileHeader
virtual void writeFileHeader(Ostream &os) const
Output file header information.
Definition: fieldMinMax.C:54
Foam::NamedEnum< modeType, 2 >
maxValue
scalar maxValue
Definition: LISASMDCalcMethod1.H:5