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 -------------------------------------------------------------------------------
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 "distributionModel.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35  defineTypeNameAndDebug(distributionModel, 0);
36  defineRunTimeSelectionTable(distributionModel, dictionary);
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 :
84  distributionModelDict_(dict),
85  rndGen_(rndGen),
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_),
98  minValue_(p.minValue_),
99  maxValue_(p.maxValue_)
100 {}
101 
102 
103 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
104 
106 {
107  return minValue_;
108 }
109 
110 
112 {
113  return maxValue_;
114 }
115 
116 
117 // ************************************************************************* //
Foam::distributionModel::check
virtual void check() const
Check that the distribution model is valid.
Definition: distributionModel.C:42
Foam::Random
Random number generator.
Definition: Random.H:59
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::defineRunTimeSelectionTable
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::distributionModel
A library of runtime-selectable doubly-truncated probability distribution models. Returns random samp...
Definition: distributionModel.H:72
Foam::distributionModel::minValue
virtual scalar minValue() const
Return the minimum of the distribution.
Definition: distributionModel.C:105
Foam::distributionModel::distributionModel
distributionModel(const word &name, const dictionary &dict, Random &rndGen)
Construct from dictionary.
Definition: distributionModel.C:78
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:144
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Foam::distributionModel::maxValue
virtual scalar maxValue() const
Return the maximum of the distribution.
Definition: distributionModel.C:111
Foam::nl
constexpr char nl
Definition: Ostream.H:404
Foam::type
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:590
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
rndGen
Random rndGen
Definition: createFields.H:23
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
WarningInFunction
#define WarningInFunction
Report a warning using Foam::Warning.
Definition: messageStream.H:328
distributionModel.H