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 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 between 280 and 350K
40  \verbatim
41  rho
42  {
43  type uniformTable;
44 
45  pLow 1000;
46  pHigh 1e6;
47 
48  Tlow 280;
49  Thigh 350;
50 
51  values
52  (
53  999.87
54  991.53
55  973.7
56  );
57  }
58  \endverbatim
59 
60 \*---------------------------------------------------------------------------*/
61 
62 #ifndef UniformTable2_H
63 #define UniformTable2_H
64 
65 #include "Function2.H"
66 #include "RectangularMatrix.H"
67 #include "Pair.H"
68 
69 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
70 
71 namespace Foam
72 {
73 namespace Function2s
74 {
75 
76 /*---------------------------------------------------------------------------*\
77  Class UniformTable Declaration
78 \*---------------------------------------------------------------------------*/
79 
80 template<class Type>
81 class UniformTable
82 :
83  public FieldFunction2<Type, UniformTable<Type>>
84 {
85  // Private member data
86 
87  //- Lowest values in the table
88  Pair<scalar> low_;
89 
90  //- Highest values in the table
91  Pair<scalar> high_;
92 
93  //- Table values
95 
96  //- x increment derived from low_, high_ and values_.m()
97  scalar deltax_;
98 
99  //- y increment derived from low_, high_ and values_.n()
100  scalar deltay_;
101 
102 
103  // Private member functions
104 
105  inline void checkRange
106  (
107  scalar x,
108  scalar ndx,
109  label ix,
110  scalar y,
111  scalar ndy,
112  label iy
113  ) const;
114 
115 
116 public:
117 
118  //- Runtime type information
119  TypeName("uniformTable");
120 
121 
122  // Constructors
123 
124  //- Construct from name and dictionary
125  UniformTable(const word& name, const dictionary& dict);
126 
127 
128  // Member Functions
129 
130  //- Return the non-uniform table of values
131  const RectangularMatrix<Type>& values() const
132  {
133  return values_;
134  }
135 
136  //- Evaluate the function and return the result
137  virtual Type value(scalar x, scalar y) const;
138 
139  //- Evaluate the derivative of the function w.r.t. p
140  Type dfdp(scalar p, scalar T) const;
141 
142  //- Evaluate the derivative of the function w.r.t. T
143  Type dfdT(scalar p, scalar T) const;
144 
145  //- Write the function coefficients
146  void write(Ostream& os) const;
147 };
148 
149 
150 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
151 
152 } // End namespace Function2s
153 } // End namespace Foam
154 
155 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
156 
157 #ifdef NoRepository
158  #include "UniformTable2.C"
159 #endif
160 
161 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
162 
163 #endif
164 
165 // ************************************************************************* //
virtual Type value(scalar x, scalar y) const
Evaluate the function and return the result.
Definition: UniformTable2.C:93
UniformTable(const word &name, const dictionary &dict)
Construct from name and dictionary.
Definition: UniformTable2.C:32
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
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
const word const dictionary & dict
Definition: Function2.H:84
Type dfdT(scalar p, scalar T) const
Evaluate the derivative of the function w.r.t. T.
Type dfdp(scalar p, scalar T) const
Evaluate the derivative of the function w.r.t. p.
const word & name() const
Return the name of the entry.
void write(Ostream &os) const
Write the function coefficients.
scalar y
A class for handling words, derived from string.
Definition: word.H:59
const RectangularMatrix< Type > & values() const
Return the non-uniform table of values.
A templated 2D rectangular m x n matrix of objects of <Type>.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
volScalarField & p
Namespace for OpenFOAM.
TypeName("uniformTable")
Runtime type information.