distribution.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) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2019 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::distribution
29 
30 Description
31  Accumulating histogram of values. Specified bin resolution
32  automatic generation of bins.
33 
34 SourceFiles
35  distributionI.H
36  distribution.C
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef distribution_H
41 #define distribution_H
42 
43 #include "Map.H"
44 #include "Pair.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 // Forward declaration of friend functions and operators
52 
53 class distribution;
54 
55 Ostream& operator<<(Ostream&, const distribution&);
56 
57 
58 /*---------------------------------------------------------------------------*\
59  Class distribution Declaration
60 \*---------------------------------------------------------------------------*/
61 
62 class distribution
63 :
64  public Map<label>
65 {
66  // Private data
67 
68  scalar binWidth_;
69 
70 
71 public:
72 
73  //- Runtime type information
74 
75  TypeName("distribution");
76 
77  // Static functions
78 
79  //- Write to file
80 
81  static void write
82  (
83  const fileName& file,
84  const List<Pair<scalar>>& pairs
85  );
86 
87 
88  // Constructors
89 
90  //- Construct null
91  distribution();
92 
93  //- Construct from binWidth
94  distribution(const scalar binWidth);
95 
96  //- Construct as copy
97  distribution(const distribution&);
98 
99 
100  //- Destructor
101  virtual ~distribution();
102 
103 
104  // Member Functions
105 
106  label totalEntries() const;
107 
108  scalar approxTotalEntries() const;
109 
110  scalar mean() const;
111 
112  scalar median();
113 
114  //- Add a value to the appropriate bin of the distribution.
115  void add(const scalar valueToAdd);
116 
117  void add(const label valueToAdd);
118 
119  void insertMissingKeys();
120 
122 
124 
125  List<Pair<scalar>> normalisedShifted(scalar shiftValue);
126 
128 
129 
130  // Access
131 
132  inline scalar binWidth() const;
133 
134 
135  // Member Operators
136 
137  void operator=(const distribution&);
138 
139 
140  // IOstream Operators
141 
142  friend Ostream& operator<<(Ostream&, const distribution&);
143 };
144 
145 
146 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
147 
148 } // End namespace Foam
149 
150 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
151 
152 #include "distributionI.H"
153 
154 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
155 
156 #endif
157 
158 // ************************************************************************* //
Foam::distribution::mean
scalar mean() const
Definition: distribution.C:128
Foam::distribution::binWidth
scalar binWidth() const
Definition: distributionI.H:30
Foam::distribution
Accumulating histogram of values. Specified bin resolution automatic generation of bins.
Definition: distribution.H:61
Foam::distribution::add
void add(const scalar valueToAdd)
Add a value to the appropriate bin of the distribution.
Definition: distribution.C:215
Foam::fileName
A class for handling file names.
Definition: fileName.H:73
Foam::distribution::operator<<
friend Ostream & operator<<(Ostream &, const distribution &)
Foam::distribution::operator=
void operator=(const distribution &)
Definition: distribution.C:433
Foam::Map
A HashTable to objects of type <T> with a label key.
Definition: lumpedPointController.H:69
Foam::distribution::normalisedMinusMean
List< Pair< scalar > > normalisedMinusMean()
Definition: distribution.C:293
Pair.H
Foam::distribution::TypeName
TypeName("distribution")
Runtime type information.
Foam::distribution::median
scalar median()
Definition: distribution.C:151
Foam::distribution::totalEntries
label totalEntries() const
Definition: distribution.C:87
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Map.H
Foam::distribution::insertMissingKeys
void insertMissingKeys()
Definition: distribution.C:251
Foam::distribution::approxTotalEntries
scalar approxTotalEntries() const
Definition: distribution.C:115
Foam::distribution::raw
List< Pair< scalar > > raw()
Definition: distribution.C:411
Foam::distribution::write
static void write(const fileName &file, const List< Pair< scalar >> &pairs)
Write to file.
Definition: distribution.C:42
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::distribution::~distribution
virtual ~distribution()
Destructor.
Definition: distribution.C:81
Foam::distribution::distribution
distribution()
Construct null.
Definition: distribution.C:58
Foam::Pair< scalar >
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:63
Foam::distribution::normalised
List< Pair< scalar > > normalised()
Definition: distribution.C:266
distributionI.H
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::distribution::normalisedShifted
List< Pair< scalar > > normalisedShifted(scalar shiftValue)
Definition: distribution.C:300