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-2017 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  Calculates the value and location of scalar minimum and maximum for a list
35  of user-specified fields.
36 
37  For variables with a rank greater than zero, either the min/max of a
38  component value or the magnitude is reported. When operating in parallel,
39  the processor owning the value is also given.
40 
41 Usage
42  Example of function object specification:
43  \verbatim
44  fieldMinMax1
45  {
46  type fieldMinMax;
47  libs ("libfieldFunctionObjects.so");
48  ...
49  writeToFile yes;
50  log yes;
51  location yes;
52  mode magnitude;
53  fields (U p);
54  }
55  \endverbatim
56 
57  Where the entries comprise:
58  \table
59  Property | Description | Required | Default value
60  type | type name: fieldMinMax | yes |
61  writeToFile | write min/max data to file | no | yes
62  log | write min/max data to standard output | no | yes
63  location | write location of the min/max value | no | yes
64  mode | calculation mode: magnitude or component | no | magnitude
65  fields | list of fields to process | yes |
66  \endtable
67 
68  Output data is written to the file <timeDir>/fieldMinMax.dat
69 
70 See also
71  Foam::functionObjects::fvMeshFunctionObject
72  Foam::functionObjects::writeFile
73 
74 SourceFiles
75  fieldMinMax.C
76  fieldMinMaxTemplates.C
77 
78 \*---------------------------------------------------------------------------*/
79 
80 #ifndef functionObjects_fieldMinMax_H
81 #define functionObjects_fieldMinMax_H
82 
83 #include "Switch.H"
84 #include "Enum.H"
85 #include "fvMeshFunctionObject.H"
86 #include "writeFile.H"
87 #include "vector.H"
88 #include "volFieldSelection.H"
89 
90 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
91 
92 namespace Foam
93 {
94 namespace functionObjects
95 {
96 
97 /*---------------------------------------------------------------------------*\
98  Class fieldMinMax Declaration
99 \*---------------------------------------------------------------------------*/
100 
101 class fieldMinMax
102 :
103  public fvMeshFunctionObject,
104  public writeFile
105 {
106 public:
107 
108  // Public enumerations
109 
110  enum modeType
111  {
112  mdMag,
113  mdCmpt
114  };
115 
116 
117 protected:
118 
119  // Protected data
120 
121  //- Mode type names
122  static const Enum<modeType> modeTypeNames_;
123 
124  //- Write location of min/max values?
125  bool location_;
126 
127  //- Mode for min/max - only applicable for ranks > 0
128  modeType mode_;
129 
130  //- Fields to assess min/max
131  volFieldSelection fieldSet_;
132 
133 
134  // Protected Member Functions
135 
136  //- Helper function to write the output
137  template<class Type>
138  void output
139  (
140  const word& fieldName,
141  const word& outputName,
142  const label minCell,
143  const label maxCell,
144  const vector& minC,
145  const vector& maxC,
146  const label minProci,
147  const label maxProci,
148  const Type& minValue,
149  const Type& maxValue
150  );
151 
152 
153  //- Output file header information
154  virtual void writeFileHeader(Ostream& os);
155 
156  //- No copy construct
157  fieldMinMax(const fieldMinMax&) = delete;
158 
159  //- No copy assignment
160  void operator=(const fieldMinMax&) = delete;
161 
162  //- Calculate the field min/max for a given field type
163  template<class Type>
165  (
167  const word& outputFieldName
168  );
169 
170  //- Calculate the field min/max
171  template<class Type>
172  void calcMinMaxFields
173  (
174  const word& fieldName,
175  const modeType& mode
176  );
177 
178 
179 public:
180 
181  //- Runtime type information
182  TypeName("fieldMinMax");
183 
184 
185  // Constructors
186 
187  //- Construct from Time and dictionary
189  (
190  const word& name,
191  const Time& runTime,
192  const dictionary& dict
193  );
194 
195 
196  //- Destructor
197  virtual ~fieldMinMax() = default;
198 
199 
200  // Member Functions
201 
202  //- Read the field min/max data
203  virtual bool read(const dictionary&);
204 
205  //- Execute, currently does nothing
206  virtual bool execute();
207 
208  //- Write the fieldMinMax
209  virtual bool write();
210 };
211 
212 
213 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
214 
215 } // End namespace functionObjects
216 } // End namespace Foam
217 
218 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
219 
220 #ifdef NoRepository
221  #include "fieldMinMaxTemplates.C"
222 #endif
223 
224 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
225 
226 #endif
227 
228 // ************************************************************************* //
runTime
engineTime & runTime
Definition: createEngineTime.H:13
Foam::functionObjects::fieldMinMax::mdCmpt
component
Definition: fieldMinMax.H:147
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:62
Foam::functionObjects::fieldMinMax
Calculates the value and location of scalar minimum and maximum for a list of user-specified fields.
Definition: fieldMinMax.H:135
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:165
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
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:62
Foam::functionObjects::fieldMinMax::fieldMinMax
fieldMinMax(const fieldMinMax &)=delete
No copy construct.
Foam::functionObjects::fieldMinMax::modeType
modeType
Definition: fieldMinMax.H:144
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:162
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::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:121
Foam::functionObjects::fieldMinMax::mdMag
magnitude
Definition: fieldMinMax.H:146
Foam::functionObjects::fieldMinMax::modeTypeNames_
static const Enum< modeType > modeTypeNames_
Mode type names.
Definition: fieldMinMax.H:156
Foam::functionObjects::fieldMinMax::location_
bool location_
Write location of min/max values?
Definition: fieldMinMax.H:159
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
volFieldSelection.H
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
Return the name of this functionObject.
Definition: functionObject.C:131
Foam::Vector< scalar >
Foam::functionObjects::fieldMinMax::~fieldMinMax
virtual ~fieldMinMax()=default
Destructor.
vector.H
minValue
scalar minValue
Definition: LISASMDCalcMethod2.H:12
Foam::functionObjects::writeFile
functionObject base class for writing single files
Definition: writeFile.H:59
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