Loading...
Searching...
No Matches
distributionModel.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-2017 OpenFOAM Foundation
9 Copyright (C) 2021 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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\*---------------------------------------------------------------------------*/
30
31// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32
33namespace Foam
34{
37}
38
39
40// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
41
43{
44 if (minValue() < 0)
45 {
47 << type() << "Distribution: "
48 << "Minimum value must be greater than zero." << nl
49 << "Supplied minValue = " << minValue()
50 << abort(FatalError);
51 }
52
53 if (maxValue() < minValue())
54 {
56 << type() << "Distribution: "
57 << "Maximum value cannot be smaller than minimum value" << nl
58 << " maxValue = " << maxValue()
59 << ", minValue = " << minValue()
60 << abort(FatalError);
61 }
62
63 if (maxValue() == minValue())
64 {
66 << type() << "Distribution: "
67 << "Maximum and minimum values are equal to each other" << nl
68 << " maxValue = " << maxValue()
69 << ", minValue = " << minValue()
70 << endl;
71 }
72}
73
74
75// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
76
78(
79 const word& name,
80 const dictionary& dict,
81 Random& rndGen
82)
83:
86 minValue_(distributionModelDict_.getOrDefault<scalar>("minValue", GREAT)),
87 maxValue_(distributionModelDict_.getOrDefault<scalar>("maxValue", -GREAT))
88{}
89
90
92(
93 const distributionModel& p
94)
95:
96 distributionModelDict_(p.distributionModelDict_),
97 rndGen_(p.rndGen_),
102
103// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
105Foam::scalar Foam::distributionModel::minValue() const
106{
107 return minValue_;
108}
109
110
111Foam::scalar Foam::distributionModel::maxValue() const
112{
113 return maxValue_;
114}
115
116
117// ************************************************************************* //
Random number generator.
Definition Random.H:56
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
A library of runtime-selectable doubly-truncated probability distribution models. Returns random samp...
const dictionary distributionModelDict_
Coefficients dictionary.
virtual void check() const
Check that the distribution model is valid.
Random & rndGen_
Reference to the random number generator.
virtual scalar maxValue() const
Return the maximum of the distribution.
scalar minValue_
Minimum of the distribution.
scalar maxValue_
Maximum of the distribution.
distributionModel(const word &name, const dictionary &dict, Random &rndGen)
Construct from dictionary.
virtual scalar minValue() const
Return the minimum of the distribution.
A class for handling words, derived from Foam::string.
Definition word.H:66
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
volScalarField & p
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition error.H:600
auto & name
#define WarningInFunction
Report a warning using Foam::Warning.
Namespace for OpenFOAM.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition POSIX.C:801
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
errorManip< error > abort(error &err)
Definition errorManip.H:139
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50
#define defineRunTimeSelectionTable(baseType, argNames)
Define run-time selection table.
dictionary dict
Random rndGen