fixedValue.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "fixedValue.H"
28 
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33 namespace distributions
34 {
37 }
38 }
39 
40 
41 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
42 
44 (
45  const dictionary& dict,
46  Random& rndGen,
47  const label
48 )
49 :
51  value_(dict.lookup<scalar>("value"))
52 {
53  report();
54 }
55 
56 
58 (
59  const fixedValue& d,
60  const label sampleQ
61 )
62 :
64  value_(d.value_)
65 {}
66 
67 
68 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
69 
71 {}
72 
73 
74 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
75 
77 {
78  return value_;
79 }
80 
81 
83 {
84  return value_;
85 }
86 
87 
89 {
90  return value_;
91 }
92 
93 
95 {
96  return value_;
97 }
98 
99 
102 {
103  const scalar d = 0.1*mag(value_);
104 
105  tmp<scalarField> tResult(new scalarField(5));
106  scalarField& result = tResult.ref();
107 
108  result[0] = value_ - d;
109  result[1] = value_*(1 - sign(value_)*rootVSmall);
110  result[2] = value_;
111  result[3] = value_*(1 + sign(value_)*rootVSmall);
112  result[4] = value_ + d;
113 
114  return tResult;
115 }
116 
117 
120 {
121  tmp<scalarField> tResult(new scalarField(5, 0));
122  scalarField& result = tResult.ref();
123 
124  result[2] = 1/rootVSmall;
125 
126  return tResult;
127 }
128 
129 
130 // ************************************************************************* //
label n
Macros for easy insertion into run-time selection tables.
Random number generator.
Definition: Random.H:58
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
Accumulating histogram of values. Specified bin resolution automatic generation of bins.
Definition: distribution.H:61
void report() const
Report.
Definition: distribution.C:133
Distribution which always takes a specified fixed value.
Definition: fixedValue.H:65
virtual scalar min() const
Return the minimum value.
Definition: fixedValue.C:82
virtual scalar sample() const
Sample the distribution.
Definition: fixedValue.C:76
virtual tmp< scalarField > PDF(const scalarField &x) const
Return the distribution probability density function.
Definition: fixedValue.C:119
virtual ~fixedValue()
Destructor.
Definition: fixedValue.C:70
virtual tmp< scalarField > x(const label n) const
Return coordinates to plot across the range of the distribution.
Definition: fixedValue.C:101
fixedValue(const dictionary &dict, Random &rndGen, const label sampleQ)
Construct from a dictionary.
Definition: fixedValue.C:44
virtual scalar max() const
Return the maximum value.
Definition: fixedValue.C:88
virtual scalar mean() const
Return the mean value.
Definition: fixedValue.C:94
A class for managing temporary objects.
Definition: tmp.H:55
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:181
defineTypeNameAndDebug(exponential, 0)
addToRunTimeSelectionTable(distribution, exponential, dictionary)
Namespace for OpenFOAM.
dimensionedScalar sign(const dimensionedScalar &ds)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
dimensioned< scalar > mag(const dimensioned< Type > &)
static const label labelMax
Definition: label.H:62
dictionary dict
Random rndGen(label(0))