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-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::functionObjects::histogram
29
30Group
31 grpFieldFunctionObjects
32
33Description
34 Computes the volume-weighted histogram of an input \c volScalarField.
35
36 Operands:
37 \table
38 Operand | Type | Location
39 input | volScalarField | $FOAM_CASE/<time>/<inpField>
40 output file | dat | $FOAM_CASE/postProcessing/<FO>/<time>/<file>
41 output field | - | -
42 \endtable
43
44 The set written contains two columns, the first the volume averaged values,
45 the second the raw bin count.
46
47Usage
48 Minimal example by using \c system/controlDict.functions:
49 \verbatim
50 histogram1
51 {
52 // Mandatory entries (unmodifiable)
53 type histogram;
54 libs (fieldFunctionObjects);
55
56 // Mandatory (inherited) entries (runtime modifiable)
57 field p;
58 nBins 100;
59 setFormat gnuplot;
60
61 // Optional entries (runtime modifiable)
62 max 5;
63 min -5;
64
65 // Optional (inherited) entries
66 ...
67 }
68 \endverbatim
69
70 where the entries mean:
71 \table
72 Property | Description | Type | Req'd | Dflt
73 type | Type name: histogram | word | yes | -
74 libs | Library name: fieldFunctionObjects | word | yes | -
75 field | Name of operand field | word | yes | -
76 nBins | Number of histogram bins | label | yes | -
77 setFormat | Output format | word | yes | -
78 max | Maximum value sampled | scalar | no | fieldMax
79 min | minimum value sampled | scalar | no | 0.0
80 \endtable
81
82 The inherited entries are elaborated in:
83 - \link functionObject.H \endlink
84 - \link writeFile.H \endlink
85
86 Usage by the \c postProcess utility is not available.
87
88Note
89 If \c max is not provided it will use the field's min and max as the bin
90 extremes. If \c max is provided but not \c min it will use 0.
91
92See also
93 - Foam::functionObject
94 - Foam::functionObjects::fvMeshFunctionObject
95 - Foam::functionObjects::writeFile
96 - ExtendedCodeGuide::functionObjects::field::histogram
97
98SourceFiles
99 histogram.C
100
101\*---------------------------------------------------------------------------*/
102
103#ifndef Foam_functionObjects_histogram_H
104#define Foam_functionObjects_histogram_H
105
106#include "fvMeshFunctionObject.H"
107#include "writeFile.H"
108#include "coordSetWriter.H"
109
110// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
111
112namespace Foam
113{
114namespace functionObjects
115{
116
117/*---------------------------------------------------------------------------*\
118 Class histogram Declaration
119\*---------------------------------------------------------------------------*/
120
121class histogram
122:
123 public functionObjects::fvMeshFunctionObject,
124 public functionObjects::writeFile
125{
126 // Private Data
127
128 //- Number of bins
129 label nBins_;
130
131 //- Name of field
132 word fieldName_;
133
134 //- Maximum value
135 scalar max_;
136
137 //- Minimum value
138 scalar min_;
139
140 //- Output formatter to write
141 mutable autoPtr<coordSetWriter> setWriterPtr_;
142
143
144public:
145
146 //- Runtime type information
147 TypeName("histogram");
148
149
150 // Constructors
151
152 //- Construct from Time and dictionary
154 (
155 const word& name,
156 const Time& runTime,
157 const dictionary& dict
158 );
159
160 //- No copy construct
161 histogram(const histogram&) = delete;
162
163 //- No copy assignment
164 void operator=(const histogram&) = delete;
165
166
167 // Destructor
168 virtual ~histogram() = default;
169
170
171 // Member Functions
172
173 //- Read the histogram data
174 virtual bool read(const dictionary&);
175
176 //- Execute (effectively no-op)
177 virtual bool execute();
178
179 //- Calculate the histogram and write
180 // postProcess overrides the usual writeControl behaviour and
181 // forces writing always (used in post-processing mode)
182 virtual bool write();
183};
185
186// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
187
188} // End namespace functionObjects
189} // End namespace Foam
190
191// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
192
193#endif
194
195// ************************************************************************* //
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:80
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
const word & name() const noexcept
Return the name of this functionObject.
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Computes the volume-weighted histogram of an input volScalarField.
Definition: histogram.H:188
void operator=(const histogram &)=delete
No copy assignment.
TypeName("histogram")
Runtime type information.
histogram(const histogram &)=delete
No copy construct.
virtual bool execute()
Execute (effectively no-op)
Definition: histogram.C:98
virtual bool write()
Calculate the histogram and write.
Definition: histogram.C:104
virtual bool read(const dictionary &)
Read the histogram data.
Definition: histogram.C:67
histogram(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: histogram.C:49
Base class for writing single files from the function objects.
Definition: writeFile.H:120
A class for handling words, derived from Foam::string.
Definition: word.H:68
engineTime & runTime
Namespace for OpenFOAM.
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73