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-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::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
123  UniformTable(const word& name, const dictionary& dict);
124 
125 
126  // Member Functions
127 
128  //- Return the non-uniform table of values
129  const RectangularMatrix<Type>& values() const
130  {
131  return values_;
132  }
133 
134  //- Evaluate the function and return the result
135  virtual Type value(scalar x, scalar y) const;
136 
137  //- Evaluate the derivative of the function w.r.t. p
138  Type dfdp(scalar p, scalar T) const;
139 
140  //- Evaluate the derivative of the function w.r.t. T
141  Type dfdT(scalar p, scalar T) const;
142 
143  //- Write the function coefficients
144  void write(Ostream& os) const;
145 };
146 
147 
148 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
149 
150 } // End namespace Function2s
151 } // End namespace Foam
152 
153 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
154 
155 #ifdef NoRepository
156  #include "UniformTable2.C"
157 #endif
158 
159 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
160 
161 #endif
162 
163 // ************************************************************************* //
dictionary dict
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
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
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.
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.
const word & name() const
Return the name of the entry.
Definition: Function2.C:81
TypeName("uniformTable")
Runtime type information.