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 {
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 * * * * * * * * * * * * * //
105 Foam::scalar Foam::distributionModel::minValue() const
106 {
107  return minValue_;
108 }
109 
110 
111 Foam::scalar Foam::distributionModel::maxValue() const
112 {
113  return maxValue_;
114 }
115 
116 
117 // ************************************************************************* //
dictionary dict
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:598
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:50
Random rndGen
Definition: createFields.H:23
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: POSIX.C:799
virtual scalar maxValue() const
Return the maximum of the distribution.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition: exprTraits.C:127
virtual scalar minValue() const
Return the minimum of the distribution.
distributionModel(const word &name, const dictionary &dict, Random &rndGen)
Construct from dictionary.
virtual void check() const
Check that the distribution model is valid.
errorManip< error > abort(error &err)
Definition: errorManip.H:139
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
defineTypeNameAndDebug(combustionModel, 0)
#define WarningInFunction
Report a warning using Foam::Warning.
A library of runtime-selectable doubly-truncated probability distribution models. Returns random samp...
volScalarField & p
Namespace for OpenFOAM.