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