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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2016 OpenFOAM Foundation
9  Copyright (C) 2017-2022 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::histogram
29 
30 Group
31  grpFieldFunctionObjects
32 
33 Description
34  Computes the volume-weighted histogram of an input \c volScalarField.
35 
36  Operands:
37  \table
38  Operand | Type | Location
39  input | volScalarField | <time>/<inpField>
40  output file | dat | postProcessing/<FO>/<time>/histogram
41  output field | - | -
42  \endtable
43 
44  The data written contains four columns (from left to right):
45  - time
46  - mid-point of histogram bin
47  - histogram counts - number of samples in each bin
48  - volume-weighted histogram values
49 
50 Usage
51  Minimal example by using \c system/controlDict.functions:
52  \verbatim
53  histogram1
54  {
55  // Mandatory entries
56  type histogram;
57  libs (fieldFunctionObjects);
58  field <word>;
59  model <word>;
60 
61  // Conditional entries
62 
63  // Option-1: when model == equalBinWidth
64 
65  // Option-2: when model == unequalBinWidth
66 
67  // Inherited entries
68  ...
69  }
70  \endverbatim
71 
72  where the entries mean:
73  \table
74  Property | Description | Type | Reqd | Deflt
75  type | Type name: histogram | word | yes | -
76  libs | Library name: fieldFunctionObjects | word | yes | -
77  field | Name of operand field | word | yes | -
78  model | Name of the histogram model | word | yes | -
79  \endtable
80 
81  Options for the \c model entry:
82  \verbatim
83  equalBinWidth | Use equal-bin width
84  unequalBinWidth | Use unequal-bin widths
85  \endverbatim
86 
87  The inherited entries are elaborated in:
88  - \link functionObject.H \endlink
89  - \link writeFile.H \endlink
90 
91 SourceFiles
92  histogram.C
93 
94 \*---------------------------------------------------------------------------*/
95 
96 #ifndef Foam_functionObjects_histogram_H
97 #define Foam_functionObjects_histogram_H
98 
99 #include "fvMeshFunctionObject.H"
100 
101 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
102 
103 namespace Foam
104 {
105 
106 // Forward Declarations
107 class histogramModel;
108 
109 namespace functionObjects
110 {
111 
112 /*---------------------------------------------------------------------------*\
113  Class histogram Declaration
114 \*---------------------------------------------------------------------------*/
115 
116 class histogram
117 :
118  public fvMeshFunctionObject
119 {
120  // Private Data
121 
122  //- Histogram model
123  autoPtr<histogramModel> histogramModelPtr_;
124 
125 
126 public:
127 
128  //- Runtime type information
129  TypeName("histogram");
130 
131 
132  // Constructors
133 
134  //- Construct from Time and dictionary
135  histogram
136  (
137  const word& name,
138  const Time& runTime,
139  const dictionary& dict
140  );
141 
142  //- No copy construct
143  histogram(const histogram&) = delete;
144 
145  //- No copy assignment
146  void operator=(const histogram&) = delete;
147 
148 
149  // Destructor
150  virtual ~histogram() = default;
151 
152 
153  // Member Functions
154 
155  //- Read the top-level dictionary
156  virtual bool read(const dictionary& dict);
158  //- Execute (effectively no-op)
159  virtual bool execute();
160 
161  //- Calculate the histogram and write
162  // postProcess overrides the usual writeControl behaviour and
163  // forces writing always (used in post-processing mode)
164  virtual bool write();
165 };
166 
167 
168 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
169 
170 } // End namespace functionObjects
171 } // End namespace Foam
172 
173 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
174 
175 #endif
176 
177 // ************************************************************************* //
virtual bool read(const dictionary &dict)
Read the top-level dictionary.
Definition: histogram.C:56
dictionary dict
virtual bool write()
Calculate the histogram and write.
Definition: histogram.C:77
engineTime & runTime
TypeName("histogram")
Runtime type information.
virtual bool execute()
Execute (effectively no-op)
Definition: histogram.C:71
const word & name() const noexcept
Return the name of this functionObject.
histogram(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: histogram.C:41
void operator=(const histogram &)=delete
No copy assignment.
Namespace for OpenFOAM.