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::writeFile
63 
64 SourceFiles
65  histogram.C
66 
67 \*---------------------------------------------------------------------------*/
68 
69 #ifndef functionObjects_histogram_H
70 #define functionObjects_histogram_H
71 
72 #include "writer.H"
73 #include "writeFile.H"
74 
75 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
76 
77 namespace Foam
78 {
79 namespace functionObjects
80 {
81 
82 /*---------------------------------------------------------------------------*\
83  Class histogram Declaration
84 \*---------------------------------------------------------------------------*/
85 
86 class histogram
87 :
88  public writeFile
89 {
90  // Private data
91 
92  //- Name of field
93  word fieldName_;
94 
95  //- Maximum value
96  scalar max_;
97 
98  //- Minimum value
99  scalar min_;
100 
101  //- Mumber of bins
102  label nBins_;
103 
104  //- Output formatter to write
105  autoPtr<writer<scalar>> formatterPtr_;
106 
107 
108  // Private Member Functions
109 
110  void writeGraph
111  (
112  const coordSet& coords,
113  const word& valueName,
114  const scalarField& values
115  ) const;
116 
117  //- Disallow default bitwise copy construct
118  histogram(const histogram&);
119 
120  //- Disallow default bitwise assignment
121  void operator=(const histogram&);
122 
123 
124 public:
125 
126  //- Runtime type information
127  TypeName("histogram");
128 
129 
130  // Constructors
131 
132  //- Construct from Time and dictionary
133  histogram
134  (
135  const word& name,
136  const Time& runTime,
137  const dictionary& dict
138  );
139 
140 
141  // Destructor
142  virtual ~histogram();
143 
144 
145  // Member Functions
146 
147  //- Read the histogram data
148  virtual bool read(const dictionary&);
149 
150  //- Execute, currently does nothing
151  virtual bool execute();
152 
153  //- Calculate the histogram and write.
154  // postProcess overrides the usual writeControl behaviour and
155  // forces writing always (used in post-processing mode)
156  virtual bool write();
157 };
158 
159 
160 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
161 
162 } // End namespace functionObjects
163 } // End namespace Foam
164 
165 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
166 
167 #endif
168 
169 // ************************************************************************* //
dictionary dict
virtual bool write()
Calculate the histogram and write.
Definition: histogram.C:118
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 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:112
virtual bool read(const dictionary &)
Read the histogram data.
Definition: histogram.C:98
const word & name() const
Return the name of this functionObject.
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:120
Namespace for OpenFOAM.