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-2025 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  cellZone all;
40  nBins 100;
41  min -5;
42  max 5;
43  setFormat gnuplot;
44  }
45  \endverbatim
46 
47 Usage
48  \table
49  Property | Description | Required | Default value
50  type | type name: histogram | yes |
51  field | Field to analyse | yes |
52  cellZone | cellZone | yes |
53  nBins | Number of bins for the histogram | yes|
54  max | Maximum value sampled | yes |
55  min | minimum value sampled | no | 0
56  setFormat | Output format | yes |
57  \endtable
58 
59  Where \c cellZone options are:
60  \plaintable
61  cellZone <name> | Looks-up the named cellZone
62  cellZone {type <zoneGeneratorType>;...} | \\
63  Generates the cellZone locally
64  cellZone all | Selects all cells
65  \endplaintable
66 
67 See also
68  Foam::functionObject
69  Foam::functionObjects::fvMeshFunctionObject
70  Foam::functionObjects::writeFile
71 
72 SourceFiles
73  histogram.C
74 
75 \*---------------------------------------------------------------------------*/
76 
77 #ifndef histogram_functionObject_H
78 #define histogram_functionObject_H
79 
80 #include "fvMeshFunctionObject.H"
81 #include "generatedCellZone.H"
82 #include "writeFile.H"
83 
84 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
85 
86 namespace Foam
87 {
88 
89 class setWriter;
90 
91 namespace functionObjects
92 {
93 
94 /*---------------------------------------------------------------------------*\
95  Class histogram Declaration
96 \*---------------------------------------------------------------------------*/
97 
98 class histogram
99 :
100  public fvMeshFunctionObject
101 {
102  // Private Data
103 
104  //- The cellZone to operate on
105  generatedCellZone zone_;
106 
107  writeFile file_;
108 
109  //- Name of field
110  word fieldName_;
111 
112  //- Maximum value
113  scalar max_;
114 
115  //- Minimum value
116  scalar min_;
117 
118  //- Number of bins
119  label nBins_;
120 
121  //- Output formatter to write
122  autoPtr<setWriter> formatterPtr_;
123 
124 
125 public:
126 
127  //- Runtime type information
128  TypeName("histogram");
129 
130 
131  // Constructors
132 
133  //- Construct from Time and dictionary
134  histogram
135  (
136  const word& name,
137  const Time& runTime,
138  const dictionary& dict
139  );
140 
141  //- Disallow default bitwise copy construction
142  histogram(const histogram&) = delete;
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  //- Return the list of fields required
155  virtual wordList fields() const;
156 
157  //- Execute, currently does nothing
158  virtual bool execute();
159 
160  //- Calculate the histogram and write.
161  // foamPostProcess overrides the usual writeControl behaviour and
162  // forces writing always (used in post-processing mode)
163  virtual bool write();
164 
165 
166  // Mesh changes
167 
168  //- Update for mesh motion
169  virtual void movePoints(const polyMesh&);
170 
171  //- Update topology using the given map
172  virtual void topoChange(const polyTopoChangeMap&);
173 
174  //- Update from another mesh using the given map
175  virtual void mapMesh(const polyMeshMap&);
176 
177  //- Redistribute or update using the given distribution map
178  virtual void distribute(const polyDistributionMap&);
179 
180 
181  // Member Operators
182 
183  //- Disallow default bitwise assignment
184  void operator=(const histogram&) = delete;
185 };
186 
187 
188 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
189 
190 } // End namespace functionObjects
191 } // End namespace Foam
192 
193 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
194 
195 #endif
196 
197 // ************************************************************************* //
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
const word & name() const
Return the name of this functionObject.
Write the volume-weighted histogram of a volScalarField.
Definition: histogram.H:151
void operator=(const histogram &)=delete
Disallow default bitwise assignment.
virtual wordList fields() const
Return the list of fields required.
Definition: histogram.C:84
virtual void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
Definition: histogram.C:183
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
Definition: histogram.C:207
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
Definition: histogram.C:195
TypeName("histogram")
Runtime type information.
virtual void movePoints(const polyMesh &)
Update for mesh motion.
Definition: histogram.C:171
virtual bool execute()
Execute, currently does nothing.
Definition: histogram.C:90
virtual bool write()
Calculate the histogram and write.
Definition: histogram.C:96
virtual bool read(const dictionary &)
Read the histogram data.
Definition: histogram.C:71
histogram(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: histogram.C:49
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:51
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:78
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Namespace for OpenFOAM.
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
dictionary dict