OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

distribution.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 2008-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     Foam::distribution
00027 
00028 Description
00029 
00030 SourceFiles
00031     distributionI.H
00032     distribution.C
00033 
00034 \*---------------------------------------------------------------------------*/
00035 
00036 #ifndef distribution_H
00037 #define distribution_H
00038 
00039 #include "Map.H"
00040 #include "Pair.H"
00041 
00042 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00043 
00044 namespace Foam
00045 {
00046 
00047 /*---------------------------------------------------------------------------*\
00048                         Class distribution Declaration
00049 \*---------------------------------------------------------------------------*/
00050 
00051 class distribution
00052 :
00053     public Map<label>
00054 {
00055     // Private data
00056 
00057         scalar binWidth_;
00058 
00059 
00060 public:
00061 
00062     // Constructors
00063 
00064         //- Construct null
00065         distribution();
00066 
00067         //- Construct from binWidth
00068         distribution(const scalar binWidth);
00069 
00070         //- Construct as copy
00071         distribution(const distribution&);
00072 
00073 
00074     // Destructor
00075 
00076         ~distribution();
00077 
00078 
00079     // Member Functions
00080 
00081         label totalEntries() const;
00082 
00083         scalar approxTotalEntries() const;
00084 
00085         scalar mean() const;
00086 
00087         scalar median();
00088 
00089         //- Add a value to the appropriate bin of the distribution.
00090         void add(const scalar valueToAdd);
00091 
00092         void add(const label valueToAdd);
00093 
00094         void insertMissingKeys();
00095 
00096         List<Pair<scalar> > normalised();
00097 
00098         List<Pair<scalar> > normalisedMinusMean();
00099 
00100         List<Pair<scalar> > normalisedShifted(const scalar shiftValue);
00101 
00102         List<Pair<scalar> > raw();
00103 
00104 
00105         // Access
00106 
00107             inline scalar binWidth() const;
00108 
00109 
00110     // Member Operators
00111 
00112         void operator=(const distribution&);
00113 
00114 
00115     // IOstream Operators
00116 
00117         friend Ostream& operator<<(Ostream&, const distribution&);
00118 };
00119 
00120 
00121 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00122 
00123 } // End namespace Foam
00124 
00125 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00126 
00127 #include "distributionI.H"
00128 
00129 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00130 
00131 #endif
00132 
00133 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd