general.H
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-2015 OpenFOAM Foundation
9  Copyright (C) 2016 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 Class
28  Foam::distributionModels::general
29 
30 Description
31  general distribution model
32 
33 SourceFiles
34  general.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef distributionModels_general_H
39 #define distributionModels_general_H
40 
41 #include "distributionModel.H"
42 #include "Vector.H"
43 #include "VectorSpace.H"
44 #include "Field.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 // Forward declaration of classes
52 class Istream;
53 class Ostream;
54 
55 namespace distributionModels
56 {
57  class general;
58 }
59 
60 // Forward declaration of friend functions and operators
61 Istream& operator>>(Istream&, distributionModels::general&);
62 Ostream& operator<<(Ostream&, const distributionModels::general&);
63 
64 namespace distributionModels
65 {
66 
67 /*---------------------------------------------------------------------------*\
68  Class general Declaration
69 \*---------------------------------------------------------------------------*/
70 
71 class general
72 :
73  public distributionModel
74 {
75  // Private data
76 
77  typedef VectorSpace<Vector<scalar>, scalar, 2> pair;
78 
79  // List of (bin probability)
80  List<pair> xy_;
81 
82  scalar meanValue_;
83 
84  List<scalar> integral_;
85 
86 
87  // Private member functions
88 
89  //- Initialise the distribution parameters
90  void initialise();
91 
92 
93 public:
94 
95  //- Runtime type information
96  TypeName("general");
97 
98 
99  // Constructors
100 
101  //- Construct from components
102  general(const dictionary& dict, Random& rndGen);
103 
104  //- Construct from components
105  general
106  (
107  const UList<scalar>& sampleData,
108  const scalar binWidth,
109  Random& rndGen
110  );
111 
112  //- Construct copy
113  general(const general& p);
114 
115  //- Construct and return a clone
116  virtual autoPtr<distributionModel> clone() const
117  {
118  return autoPtr<distributionModel>(new general(*this));
119  }
120 
121 
122  //- Destructor
123  virtual ~general();
124 
125 
126  // Member Functions
127 
128  //- Bin boundaries
129  virtual tmp<Field<scalar>> x() const;
130 
131  //- Probabilities
132  virtual tmp<Field<scalar>> y() const;
133 
134  //- Sample the distributionModel
135  virtual scalar sample() const;
136 
137  //- Return the minimum value
138  virtual scalar minValue() const;
139 
140  //- Return the maximum value
141  virtual scalar maxValue() const;
142 
143  //- Return the mean value
144  virtual scalar meanValue() const;
145 
146  //- Write data to stream
147  virtual void writeData(Ostream& os) const;
148 
149  //- Read data from stream
150  virtual void readData(Istream& os);
151 
152  //- Write data in dictionary format
153  virtual dictionary writeDict(const word& dictName) const;
154 
155  //- Read data from dictionary
156  virtual void readDict(const dictionary& dict);
157 };
158 
159 
160 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
161 
162 } // End namespace distributionModels
163 } // End namespace Foam
164 
165 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
166 
167 #endif
168 
169 // ************************************************************************* //
Foam::Random
Random number generator.
Definition: Random.H:59
VectorSpace.H
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::distributionModels::general::x
virtual tmp< Field< scalar > > x() const
Bin boundaries.
Definition: general.C:279
Foam::distributionModels::general::~general
virtual ~general()
Destructor.
Definition: general.C:164
Foam::distributionModels::general::meanValue
virtual scalar meanValue() const
Return the mean value.
Definition: general.C:226
Foam::distributionModels::general::minValue
virtual scalar minValue() const
Return the minimum value.
Definition: general.C:214
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:59
Vector.H
dictName
const word dictName("blockMeshDict")
Foam::operator>>
Istream & operator>>(Istream &, directionInfo &)
Definition: directionInfo.C:230
Foam::distributionModel
A library of runtime-selectable distribution models.
Definition: distributionModel.H:70
Foam::distributionModels::general
general distribution model
Definition: general.H:70
Foam::distributionModels::general::y
virtual tmp< Field< scalar > > y() const
Probabilities.
Definition: general.C:293
Foam::VectorSpace
Templated vector space.
Definition: VectorSpace.H:56
Foam::distributionModels::general::sample
virtual scalar sample() const
Sample the distributionModel.
Definition: general.C:170
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
general
General relative velocity model.
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::distributionModels::general::readDict
virtual void readDict(const dictionary &dict)
Read data from dictionary.
Definition: general.C:261
Field.H
Foam::distributionModels::general::TypeName
TypeName("general")
Runtime type information.
Foam::distributionModels::general::writeDict
virtual dictionary writeDict(const word &dictName) const
Write data in dictionary format.
Definition: general.C:248
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::distributionModels::general::general
general(const dictionary &dict, Random &rndGen)
Construct from components.
Definition: general.C:82
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::distributionModels::general::maxValue
virtual scalar maxValue() const
Return the maximum value.
Definition: general.C:220
Foam::distributionModels::general::clone
virtual autoPtr< distributionModel > clone() const
Construct and return a clone.
Definition: general.H:115
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:102
Foam::UList
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:103
Foam::distributionModels::general::readData
virtual void readData(Istream &os)
Read data from stream.
Definition: general.C:232
rndGen
Random rndGen
Definition: createFields.H:23
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::distributionModels::general::writeData
virtual void writeData(Ostream &os) const
Write data to stream.
Definition: general.C:240
distributionModel.H