All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
UniformTable2.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) 2020-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::Function2s::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  Tlow | Lower temperature limit of the uniformTable
35  Thigh | Upper temperature limit of the uniformTable
36  values | Property values, assumed uniformly distributed
37  \endtable
38 
39  Example for the density of water from 1 to 3bar and 280 to 350K
40  \verbatim
41  rho
42  {
43  type uniformTable;
44 
45  low (1e5 280);
46  high (3e5 350);
47 
48  values
49  3 2
50  (
51  (991 992)
52  (993 994)
53  (995 996)
54  );
55  }
56  \endverbatim
57 
58 \*---------------------------------------------------------------------------*/
59 
60 #ifndef UniformTable2_H
61 #define UniformTable2_H
62 
63 #include "Function2.H"
64 #include "RectangularMatrix.H"
65 #include "Pair.H"
66 
67 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
68 
69 namespace Foam
70 {
71 namespace Function2s
72 {
73 
74 /*---------------------------------------------------------------------------*\
75  Class UniformTable Declaration
76 \*---------------------------------------------------------------------------*/
77 
78 template<class Type>
79 class UniformTable
80 :
81  public FieldFunction2<Type, UniformTable<Type>>
82 {
83  // Private member data
84 
85  //- Lowest values in the table
86  Pair<scalar> low_;
87 
88  //- Highest values in the table
89  Pair<scalar> high_;
90 
91  //- Table values
93 
94  //- x increment derived from low_, high_ and values_.m()
95  scalar deltax_;
96 
97  //- y increment derived from low_, high_ and values_.n()
98  scalar deltay_;
99 
100 
101  // Private member functions
102 
103  inline void checkRange
104  (
105  scalar x,
106  scalar ndx,
107  label ix,
108  scalar y,
109  scalar ndy,
110  label iy
111  ) const;
112 
113 
114 public:
115 
116  //- Runtime type information
117  TypeName("uniformTable");
118 
119 
120  // Constructors
121 
122  //- Construct from name and dictionary
124  (
125  const word& name,
126  const unitConversions& units,
127  const dictionary& dict
128  );
129 
130 
131  // Member Functions
132 
133  //- Return the non-uniform table of values
134  const RectangularMatrix<Type>& values() const
135  {
136  return values_;
137  }
138 
139  //- Evaluate the function and return the result
140  virtual Type value(scalar x, scalar y) const;
141 
142  //- Evaluate the derivative of the function w.r.t. p
143  Type dfdp(scalar p, scalar T) const;
144 
145  //- Evaluate the derivative of the function w.r.t. T
146  Type dfdT(scalar p, scalar T) const;
147 
148  //- Write the function coefficients
149  void write(Ostream& os, const unitConversions& units) const;
150 };
151 
152 
153 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
154 
155 } // End namespace Function2s
156 } // End namespace Foam
157 
158 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
159 
160 #ifdef NoRepository
161  #include "UniformTable2.C"
162 #endif
163 
164 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
165 
166 #endif
167 
168 // ************************************************************************* //
scalar y
const word & name() const
Return the name of the entry.
Definition: Function2.C:78
TypeName("uniformTable")
Runtime type information.
UniformTable(const word &name, const unitConversions &units, const dictionary &dict)
Construct from name and dictionary.
Definition: UniformTable2.C:32
virtual Type value(scalar x, scalar y) const
Evaluate the function and return the result.
Definition: UniformTable2.C:96
void write(Ostream &os, const unitConversions &units) const
Write the function coefficients.
const RectangularMatrix< Type > & values() const
Return the non-uniform table of values.
Type dfdp(scalar p, scalar T) const
Evaluate the derivative of the function w.r.t. p.
Type dfdT(scalar p, scalar T) const
Evaluate the derivative of the function w.r.t. T.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
A templated 2D rectangular m x n matrix of objects of <Type>.
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.
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.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
dictionary dict
volScalarField & p