fixedValue.H
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-2024 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 Class
25  Foam::distributions::fixedValue
26 
27 Description
28  Distribution which always takes a specified fixed value
29 
30 Usage
31  Example usage:
32  \verbatim
33  {
34  type fixedValue;
35  value 1e-6;
36  }
37  \endverbatim
38 
39 SourceFiles
40  fixedValue.C
41 
42 See also
43  Foam::distribution
44 
45 \*---------------------------------------------------------------------------*/
46 
47 #ifndef fixedValue_H
48 #define fixedValue_H
49 
50 #include "distribution.H"
51 
52 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53 
54 namespace Foam
55 {
56 namespace distributions
57 {
58 
59 /*---------------------------------------------------------------------------*\
60  Class fixedValue Declaration
61 \*---------------------------------------------------------------------------*/
62 
63 class fixedValue
64 :
65  public FieldDistribution<distribution, fixedValue>
66 {
67  // Private Data
68 
69  //- Fixed value
70  const scalar value_;
71 
72 
73 public:
74 
75  //- Runtime type information
76  TypeName("fixedValue");
77 
78 
79  // Constructors
80 
81  //- Construct from a dictionary
83  (
84  const unitConversion& units,
85  const dictionary& dict,
86  const label sampleQ,
88  );
89 
90  //- Construct copy
91  fixedValue(const fixedValue& d, const label sampleQ);
92 
93  //- Construct and return a clone
94  virtual autoPtr<distribution> clone(const label sampleQ) const
95  {
96  return autoPtr<distribution>(new fixedValue(*this, sampleQ));
97  }
98 
99 
100  //- Destructor
101  virtual ~fixedValue();
102 
103 
104  // Member Functions
105 
106  //- Sample the distribution
107  virtual scalar sample() const;
108 
109  //- Sample the distribution
111 
112  //- Return the minimum value
113  virtual scalar min() const;
114 
115  //- Return the maximum value
116  virtual scalar max() const;
117 
118  //- Return the mean value
119  virtual scalar mean() const;
120 
121  //- Write to a stream
122  virtual void write(Ostream& os, const unitConversion& units) const;
123 
124  //- Return coordinates to plot across the range of the distribution
125  virtual tmp<scalarField> x(const label n) const;
126 
127  //- Return the distribution probability density function
128  virtual tmp<scalarField> PDF(const scalarField& x) const;
129 };
130 
131 
132 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
133 
134 } // End namespace distributions
135 } // End namespace Foam
136 
137 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
138 
139 #endif
140 
141 // ************************************************************************* //
label n
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
autoPtr< distribution > clone() const
Construct and return a clone.
Definition: distribution.H:168
Distribution which always takes a specified fixed value.
Definition: fixedValue.H:65
fixedValue(const unitConversion &units, const dictionary &dict, const label sampleQ, randomGenerator &&rndGen)
Construct from a dictionary.
Definition: fixedValue.C:44
virtual scalar min() const
Return the minimum value.
Definition: fixedValue.C:86
TypeName("fixedValue")
Runtime type information.
virtual scalar sample() const
Sample the distribution.
Definition: fixedValue.C:80
virtual tmp< scalarField > PDF(const scalarField &x) const
Return the distribution probability density function.
Definition: fixedValue.C:135
virtual ~fixedValue()
Destructor.
Definition: fixedValue.C:74
virtual tmp< scalarField > x(const label n) const
Return coordinates to plot across the range of the distribution.
Definition: fixedValue.C:117
virtual void write(Ostream &os, const unitConversion &units) const
Write to a stream.
Definition: fixedValue.C:105
virtual scalar max() const
Return the maximum value.
Definition: fixedValue.C:92
virtual scalar mean() const
Return the mean value.
Definition: fixedValue.C:98
Random number generator.
A class for managing temporary objects.
Definition: tmp.H:55
Unit conversion structure. Contains the associated dimensions and the multiplier with which to conver...
Namespace for OpenFOAM.
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
const HashTable< unitConversion > & units()
Get the table of unit conversions.
dictionary dict
randomGenerator rndGen(653213)