UniformTable1.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) 2019-2021 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::Function1s::UniformTable
26 
27 Description
28  Tabulated property function that linearly interpolates between
29  the UniformTable values.
30 
31 Usage
32  \table
33  Property | Description
34  low | Lower limit of the table
35  high | Upper limit of the table
36  values | Values, assumed uniformly distributed
37  \endtable
38 
39  Example for the density of water between 280 and 350K
40  \verbatim
41  rho
42  {
43  type uniformTable;
44 
45  low 280;
46  high 350;
47 
48  values
49  (
50  999.87
51  991.53
52  973.7
53  );
54  }
55  \endverbatim
56 
57 \*---------------------------------------------------------------------------*/
58 
59 #ifndef UniformTable1_H
60 #define UniformTable1_H
61 
62 #include "Function1.H"
63 
64 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
65 
66 namespace Foam
67 {
68 namespace Function1s
69 {
70 
71 /*---------------------------------------------------------------------------*\
72  Class UniformTable Declaration
73 \*---------------------------------------------------------------------------*/
74 
75 template<class Type>
76 class UniformTable
77 :
78  public FieldFunction1<Type, UniformTable<Type>>
79 {
80  // Private member data
81 
82  //- Name of dictionary from which this function is instantiated
83  fileName dictName_;
84 
85  //- Lowest value in the table
86  scalar low_;
87 
88  //- Highest value in the table
89  scalar high_;
90 
91  //- Table values
92  List<Type> values_;
93 
94  //- Increment derived from low_, high_ and values_.size()
95  scalar delta_;
96 
97 
98 public:
99 
100  //- Runtime type information
101  TypeName("uniformTable");
102 
103 
104  // Constructors
105 
106  //- Construct from name and dictionary
107  UniformTable(const word& name, const dictionary& dict);
108 
109 
110  // Member Functions
111 
112  //- Evaluate the function and return the result
113  virtual Type value(scalar x) const;
114 
115  //- Integrate between two scalar values
116  virtual Type integral(const scalar x1, const scalar x2) const;
117 
118  //- Write the function coefficients
119  void write(Ostream& os) const;
120 };
121 
122 
123 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
124 
125 } // End namespace Function1s
126 } // End namespace Foam
127 
128 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
129 
130 #ifdef NoRepository
131  #include "UniformTable1.C"
132 #endif
133 
134 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
135 
136 #endif
137 
138 // ************************************************************************* //
UniformTable(const word &name, const dictionary &dict)
Construct from name and dictionary.
Definition: UniformTable1.C:32
TypeName("uniformTable")
Runtime type information.
dictionary dict
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
const word & name() const
Return the name of the entry.
Definition: Function1.C:82
virtual Type value(scalar x) const
Evaluate the function and return the result.
Definition: UniformTable1.C:61
virtual Type integral(const scalar x1, const scalar x2) const
Integrate between two scalar values.
Definition: UniformTable1.C:84
A class for handling words, derived from string.
Definition: word.H:59
void write(Ostream &os) const
Write the function coefficients.
Definition: UniformTable1.C:95
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
Namespace for OpenFOAM.