Loading...
Searching...
No Matches
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-------------------------------------------------------------------------------
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::distribution
29
30Description
31 Accumulating histogram of values. Specified bin resolution
32 automatic generation of bins.
33
34SourceFiles
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
48namespace Foam
49{
50
51// Forward declaration of friend functions and operators
52
53class distribution;
54
56
58/*---------------------------------------------------------------------------*\
59 Class distribution Declaration
60\*---------------------------------------------------------------------------*/
61
62class distribution
63:
64 public Map<label>
65{
66 // Private data
67
68 scalar binWidth_;
69
70
71public:
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
92
93 //- Construct from binWidth
94 distribution(const scalar binWidth);
95
96 //- Construct as copy
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// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
152#include "distributionI.H"
153
154// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
155
156#endif
157
158// ************************************************************************* //
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition List.H:72
constexpr Map() noexcept=default
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
An ordered pair of two objects of type <T> with first() and second() elements.
Definition Pair.H:66
Accumulating histogram of values. Specified bin resolution automatic generation of bins.
void operator=(const distribution &)
List< Pair< scalar > > normalisedMinusMean()
friend Ostream & operator<<(Ostream &, const distribution &)
List< Pair< scalar > > raw()
virtual ~distribution()
Destructor.
List< Pair< scalar > > normalised()
List< Pair< scalar > > normalisedShifted(scalar shiftValue)
TypeName("distribution")
Runtime type information.
label totalEntries() const
void add(const scalar valueToAdd)
Add a value to the appropriate bin of the distribution.
scalar approxTotalEntries() const
distribution()
Construct null.
scalar binWidth() const
scalar mean() const
A class for handling file names.
Definition fileName.H:75
Namespace for OpenFOAM.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
runTime write()
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68