histogram.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) 2016 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::histogram
26 
27 Group
28  grpFieldFunctionObjects
29 
30 Description
31  Write the volume-weighted histogram of a volScalarField.
32 
33  Example:
34  \verbatim
35  histogram1
36  {
37  type histogram;
38 
39  libs ("libfieldFunctionObjects.so");
40 
41  field p;
42  nBins 100;
43  min -5;
44  max 5;
45  setFormat gnuplot;
46  }
47  \endverbatim
48 
49 Usage
50  \table
51  Property | Description | Required | Default value
52  type | type name: histogram | yes |
53  field | Field to analyse | yes |
54  nBins | Number of bins for the histogram | yes|
55  max | Maximum value sampled | yes |
56  min | minimum value sampled | no | 0
57  setFormat | Output format | yes |
58  \endtable
59 
60 See also
61  Foam::functionObject
62  Foam::functionObjects::fvMeshFunctionObject
63  Foam::functionObjects::writeFile
64 
65 SourceFiles
66  histogram.C
67 
68 \*---------------------------------------------------------------------------*/
69 
70 #ifndef functionObjects_histogram_H
71 #define functionObjects_histogram_H
72 
73 #include "fvMeshFunctionObject.H"
74 #include "writeFile.H"
75 #include "writer.H"
76 
77 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
78 
79 namespace Foam
80 {
81 namespace functionObjects
82 {
83 
84 /*---------------------------------------------------------------------------*\
85  Class histogram Declaration
86 \*---------------------------------------------------------------------------*/
87 
88 class histogram
89 :
90  public fvMeshFunctionObject
91 {
92  // Private data
93 
94  writeFile file_;
95 
96  //- Name of field
97  word fieldName_;
98 
99  //- Maximum value
100  scalar max_;
101 
102  //- Minimum value
103  scalar min_;
104 
105  //- Mumber of bins
106  label nBins_;
107 
108  //- Output formatter to write
109  autoPtr<writer<scalar>> formatterPtr_;
110 
111 
112  // Private Member Functions
113 
114  void writeGraph
115  (
116  const coordSet& coords,
117  const word& valueName,
118  const scalarField& values
119  ) const;
120 
121  //- Disallow default bitwise copy construct
123 
124  //- Disallow default bitwise assignment
125  void operator=(const histogram&);
126 
127 
128 public:
129 
130  //- Runtime type information
131  TypeName("histogram");
132 
133 
134  // Constructors
135 
136  //- Construct from Time and dictionary
137  histogram
138  (
139  const word& name,
140  const Time& runTime,
141  const dictionary& dict
142  );
143 
144 
145  // Destructor
146  virtual ~histogram();
147 
148 
149  // Member Functions
150 
151  //- Read the histogram data
152  virtual bool read(const dictionary&);
153 
154  //- Execute, currently does nothing
155  virtual bool execute();
156 
157  //- Calculate the histogram and write.
158  // postProcess overrides the usual writeControl behaviour and
159  // forces writing always (used in post-processing mode)
160  virtual bool write();
161 };
162 
163 
164 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
165 
166 } // End namespace functionObjects
167 } // End namespace Foam
168 
169 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
170 
171 #endif
172 
173 // ************************************************************************* //
dictionary dict
virtual bool write()
Calculate the histogram and write.
Definition: histogram.C:113
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
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
TypeName("histogram")
Runtime type information.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
virtual bool execute()
Execute, currently does nothing.
Definition: histogram.C:107
virtual bool read(const dictionary &)
Read the histogram data.
Definition: histogram.C:93
A class for handling words, derived from string.
Definition: word.H:59
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Write the volume-weighted histogram of a volScalarField.
Definition: histogram.H:122
Namespace for OpenFOAM.