uniform.C
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) 2021 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
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 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "uniform.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 namespace distributionModels
37 {
38  defineTypeNameAndDebug(uniform, 0);
40 }
41 }
42 
43 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
44 
46 (
47  const dictionary& dict,
48  Random& rndGen
49 )
50 :
51  distributionModel(typeName, dict, rndGen)
52 {
53  check();
54 }
55 
56 
58 :
60 {}
61 
62 
63 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
64 
66 {
67  return rndGen_.position<scalar>(minValue_, maxValue_);
68 }
69 
70 
72 {
73  return 0.5*(minValue_ + maxValue_);
74 }
75 
76 
77 // ************************************************************************* //
Foam::distributionModel::rndGen_
Random & rndGen_
Definition: distributionModel.H:79
Foam::Random
Random number generator.
Definition: Random.H:55
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::distributionModels::addToRunTimeSelectionTable
addToRunTimeSelectionTable(distributionModel, binned, dictionary)
Foam::distributionModel
A library of runtime-selectable doubly-truncated probability distribution models. Returns random samp...
Definition: distributionModel.H:69
Foam::distributionModel::maxValue_
scalar maxValue_
Definition: distributionModel.H:85
Foam::distributionModels::uniform::sample
virtual scalar sample() const
Definition: uniform.C:58
Foam::check
static void check(const int retVal, const char *what)
Definition: ptscotchDecomp.C:73
Foam::distributionModel::minValue_
scalar minValue_
Definition: distributionModel.H:82
uniform.H
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:119
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Definition: atmBoundaryLayer.C:26
Foam::distributionModels::uniform::uniform
uniform(const dictionary &dict, Random &rndGen)
Definition: uniform.C:39
Foam::distributionModels::uniform
Particle-size distribution model wherein random samples are drawn from the doubly-truncated uniform p...
Definition: uniform.H:157
Foam::Random::position
Type position(const Type &start, const Type &end)
Definition: RandomTemplates.C:55
Foam::distributionModels::defineTypeNameAndDebug
defineTypeNameAndDebug(binned, 0)
rndGen
Random rndGen
Definition: createFields.H:23
Foam::distributionModels::uniform::meanValue
virtual scalar meanValue() const
Definition: uniform.C:64