binned.H 4.19 KB
Newer Older
1 2 3 4
/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     |
OpenFOAM bot's avatar
OpenFOAM bot committed
5
    \\  /    A nd           | www.openfoam.com
6
     \\/     M anipulation  |
OpenFOAM bot's avatar
OpenFOAM bot committed
7 8
-------------------------------------------------------------------------------
    Copyright (C) 2015-2016 OpenCFD Ltd.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
-------------------------------------------------------------------------------
License
    This file is part of OpenFOAM.

    OpenFOAM is free software: you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    for more details.

    You should have received a copy of the GNU General Public License
    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.

Class
27
    Foam::distributionModels::binned
28 29

Description
30 31
    A binned distribution model where the random sample is taken from a
    discrete set of bins
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

SourceFiles
    binned.C

\*---------------------------------------------------------------------------*/

#ifndef distributionModels_binned_H
#define distributionModels_binned_H

#include "distributionModel.H"
#include "Field.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

namespace Foam
{

// Forward declaration of classes
class Istream;
class Ostream;

namespace distributionModels
{
    class binned;
}

// Forward declaration of friend functions and operators
Istream& operator>>(Istream&, distributionModels::binned&);
Ostream& operator<<(Ostream&, const distributionModels::binned&);

namespace distributionModels
{

/*---------------------------------------------------------------------------*\
                           Class binned Declaration
\*---------------------------------------------------------------------------*/

class binned
:
    public distributionModel
{
    // Private data

75
        typedef VectorSpace<Vector<scalar>, scalar, 2> pair;
76

77 78
        // List of (bin probability)
        List<pair> xy_;
79 80 81 82 83

        //- Distribution mean value
        scalar meanValue_;


84
    // Private member functions
85

86 87
        //- Initialise the distribution parameters
        void initialise();
88 89 90 91 92 93 94 95 96 97 98 99 100


public:

    //- Runtime type information
    TypeName("binned");

    static const char* header;


    // Constructors

        //- Construct from dictionary
101
        binned(const dictionary& dict, Random& rndGen);
102 103 104 105

        //- Construct from components
        binned
        (
106
            const UList<scalar>& sampleData,
107
            const scalar binWidth,
108
            Random& rndGen
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
        );

        //- Construct copy
        binned(const binned& p);

        //- Construct and return a clone
        virtual autoPtr<distributionModel> clone() const
        {
            return autoPtr<distributionModel>(new binned(*this));
        }


    //- Destructor
    virtual ~binned();


    // Member Functions

        //- Sample the distributionModel
        virtual scalar sample() const;

        //- Return the minimum value
        virtual scalar minValue() const;

        //- Return the maximum value
        virtual scalar maxValue() const;

        //- Return the mean value
        virtual scalar meanValue() const;

        //- Write data to stream
        virtual void writeData(Ostream& os) const;

        //- Read data from stream
        virtual void readData(Istream& os);

        //- Write data in dictionary format
        virtual dictionary writeDict(const word& dictName) const;

        //- Read data from dictionary
        virtual void readDict(const dictionary& dict);
};


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

} // End namespace distributionModels
} // End namespace Foam

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

#endif

// ************************************************************************* //