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