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-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::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
108  (
109  const word& name,
110  const unitConversions& units,
111  const dictionary& dict
112  );
113 
114 
115  // Member Functions
116 
117  //- Evaluate the function and return the result
118  virtual Type value(scalar x) const;
119 
120  //- Integrate between two scalar values
121  virtual Type integral(const scalar x1, const scalar x2) const;
122 
123  //- Write the function coefficients
124  void write(Ostream& os, const unitConversions& units) const;
125 };
126 
127 
128 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
129 
130 } // End namespace Function1s
131 } // End namespace Foam
132 
133 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
134 
135 #ifdef NoRepository
136  #include "UniformTable1.C"
137 #endif
138 
139 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
140 
141 #endif
142 
143 // ************************************************************************* //
const word & name() const
Return the name of the entry.
Definition: Function1.C:78
TypeName("uniformTable")
Runtime type information.
UniformTable(const word &name, const unitConversions &units, const dictionary &dict)
Construct from name and dictionary.
Definition: UniformTable1.C:32
virtual Type integral(const scalar x1, const scalar x2) const
Integrate between two scalar values.
Definition: UniformTable1.C:87
void write(Ostream &os, const unitConversions &units) const
Write the function coefficients.
Definition: UniformTable1.C:99
virtual Type value(scalar x) const
Evaluate the function and return the result.
Definition: UniformTable1.C:64
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
A class for handling words, derived from string.
Definition: word.H:62
Namespace for OpenFOAM.
const HashTable< unitConversion > & units()
Get the table of unit conversions.
dictionary dict