uniform.C 2.74 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
-------------------------------------------------------------------------------
OpenFOAM bot's avatar
OpenFOAM bot committed
8
    Copyright (C) 2011-2016 OpenFOAM Foundation
9 10 11 12
-------------------------------------------------------------------------------
License
    This file is part of OpenFOAM.

13 14 15 16
    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.
17 18 19 20 21 22 23

    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
24
    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
25 26 27 28 29 30 31 32

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

#include "uniform.H"
#include "addToRunTimeSelectionTable.H"

// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //

Andrew Heather's avatar
Andrew Heather committed
33 34
namespace Foam
{
35 36 37 38 39
namespace distributionModels
{
    defineTypeNameAndDebug(uniform, 0);
    addToRunTimeSelectionTable(distributionModel, uniform, dictionary);
}
Andrew Heather's avatar
Andrew Heather committed
40
}
41 42 43

// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //

44 45 46
Foam::distributionModels::uniform::uniform
(
    const dictionary& dict,
47
    Random& rndGen
48
)
49
:
50
    distributionModel(typeName, dict, rndGen),
51 52
    minValue_(distributionModelDict_.get<scalar>("minValue")),
    maxValue_(distributionModelDict_.get<scalar>("maxValue"))
53 54 55
{
    check();
}
56 57


58
Foam::distributionModels::uniform::uniform(const uniform& p)
59
:
60
    distributionModel(p),
61 62 63 64 65
    minValue_(p.minValue_),
    maxValue_(p.maxValue_)
{}


66 67
// * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //

68
Foam::distributionModels::uniform::~uniform()
69 70 71 72 73
{}


// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //

74
Foam::scalar Foam::distributionModels::uniform::sample() const
75
{
76
    return rndGen_.position<scalar>(minValue_, maxValue_);
77 78
}

Andrew Heather's avatar
Andrew Heather committed
79

80
Foam::scalar Foam::distributionModels::uniform::minValue() const
81 82 83 84
{
    return minValue_;
}

Andrew Heather's avatar
Andrew Heather committed
85

86
Foam::scalar Foam::distributionModels::uniform::maxValue() const
87 88 89 90 91
{
    return maxValue_;
}


andy's avatar
andy committed
92 93 94 95 96 97
Foam::scalar Foam::distributionModels::uniform::meanValue() const
{
    return 0.5*(minValue_ + maxValue_);
}


Andrew Heather's avatar
Andrew Heather committed
98
// ************************************************************************* //