mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
80 lines
2.3 KiB
C
80 lines
2.3 KiB
C
/*---------------------------------------------------------------------------*\
|
|
========= |
|
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
\\ / O peration |
|
|
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
|
|
\\/ M anipulation |
|
|
-------------------------------------------------------------------------------
|
|
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/>.
|
|
|
|
\*---------------------------------------------------------------------------*/
|
|
|
|
#include "uniform.H"
|
|
#include "addToRunTimeSelectionTable.H"
|
|
|
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
|
|
|
namespace Foam
|
|
{
|
|
namespace pdfs
|
|
{
|
|
defineTypeNameAndDebug(uniform, 0);
|
|
addToRunTimeSelectionTable(pdf, uniform, dictionary);
|
|
}
|
|
}
|
|
|
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
|
|
|
Foam::pdfs::uniform::uniform(const dictionary& dict, Random& rndGen)
|
|
:
|
|
pdf(typeName, dict, rndGen),
|
|
minValue_(readScalar(pdfDict_.lookup("minValue"))),
|
|
maxValue_(readScalar(pdfDict_.lookup("maxValue"))),
|
|
range_(maxValue_ - minValue_)
|
|
{
|
|
check();
|
|
}
|
|
|
|
|
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
|
|
|
Foam::pdfs::uniform::~uniform()
|
|
{}
|
|
|
|
|
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
|
|
|
Foam::scalar Foam::pdfs::uniform::sample() const
|
|
{
|
|
return (minValue_ + rndGen_.scalar01()*range_);
|
|
}
|
|
|
|
|
|
Foam::scalar Foam::pdfs::uniform::minValue() const
|
|
{
|
|
return minValue_;
|
|
}
|
|
|
|
|
|
Foam::scalar Foam::pdfs::uniform::maxValue() const
|
|
{
|
|
return maxValue_;
|
|
}
|
|
|
|
|
|
// ************************************************************************* //
|